@@ -6,7 +6,22 @@ include $(JULIAHOME)/Make.inc
6
6
7
7
TAGGED_RELEASE_BANNER := ""
8
8
9
- all : $(addprefix $(BUILDDIR ) /,pcre_h.jl errno_h.jl build_h.jl.phony features_h.jl file_constants.jl uv_constants.jl version_git.jl.phony)
9
+ all :
10
+
11
+ BASE_SRCS := $(patsubst ./% ,% ,$(shell cd $(SRCDIR ) && find . -name \* .jl -and -not -name version_git.jl -and -not -name '* .phony') )
12
+ GENERATED_SRCS := pcre_h.jl errno_h.jl build_h.jl.phony features_h.jl file_constants.jl uv_constants.jl version_git.jl.phony
13
+
14
+ GENERATED_DSTS := $(addprefix $(build_datarootdir ) /julia/src/,$(GENERATED_SRCS ) )
15
+ BASE_DSTS := $(addprefix $(build_datarootdir ) /julia/src/base/,$(BASE_SRCS ) ) $(GENERATED_DSTS )
16
+ BASE_DIRS := $(sort $(dir $(BASE_DSTS ) ) )
17
+ $(foreach dir,$(BASE_DIRS),$(eval $(call dir_target,$(dir))))
18
+
19
+ # we might like to add "| $(BASE_DIRS)" here, but that causes many version of 'make' to get confused and fail to build consistently
20
+ $(build_datarootdir ) /julia/src/base/% .jl : $(SRCDIR ) /% .jl
21
+ @mkdir -p $(dir $@ )
22
+ cp $< $@
23
+
24
+ all : $(BASE_DSTS )
10
25
11
26
PCRE_CONST := 0x[0-9a-fA-F]+|[0-9]+|\([\-0-9]+\)
12
27
ifeq ($(USE_SYSTEM_PCRE ) , 1)
@@ -17,29 +32,37 @@ endif
17
32
18
33
define parse_features
19
34
@echo "# $(2) features" >> $@
20
- @$(call PRINT_PERL, cat $(SRCDIR ) /../src/features_$(1 ) .h | perl -lne 'print "const JL_$(2 ) _$$1 = UInt32($$2) " if /^\s*JL_FEATURE_DEF(?:_NAME)?\(\s*(\w+)\s*,\s*([^,]+)\s*,.*\)\s*(?:\/\/.*)?$$/' >> $@ )
35
+ @$(call PRINT_PERL, cat $(JULIAHOME ) /src/features_$(1 ) .h | \
36
+ perl -lne 'print "const JL_$(2 ) _$$1 = UInt32($$2) " if /^\s*JL_FEATURE_DEF(?:_NAME)?\(\s*(\w+)\s*,\s*([^,]+)\s*,.*\)\s*(?:\/\/.*)?$$/' >> $@ )
21
37
@echo >> $@
22
38
endef
23
39
24
- $(BUILDDIR ) /features_h.jl : $(SRCDIR ) /../src/features_x86.h $(SRCDIR ) /../src/features_aarch32.h $(SRCDIR ) /../src/features_aarch64.h
40
+ $(build_datarootdir ) /julia/src/features_h.jl : $(JULIAHOME ) /src/features_x86.h $(JULIAHOME ) /src/features_aarch32.h $(JULIAHOME ) /src/features_aarch64.h
41
+ @mkdir -p $(dir $@ )
25
42
@-rm -f $@
26
43
@$(call parse_features,x86,X86)
27
44
@$(call parse_features,aarch32,AArch32)
28
45
@$(call parse_features,aarch64,AArch64)
29
46
30
- $(BUILDDIR ) /pcre_h.jl : $(PCRE_INCL_PATH )
47
+ $(build_datarootdir ) /julia/src/pcre_h.jl : $(PCRE_INCL_PATH )
48
+ @mkdir -p $(dir $@ )
31
49
@$(call PRINT_PERL, $(CPP ) -D PCRE2_CODE_UNIT_WIDTH=8 -dM $< | perl -nle '/^\s* #define\s+PCRE2_(\w* ) \s * \( ? ($( PCRE_CONST) )\) ? u? \s * $$ / and print index($$ 1, " ERROR_" ) == 0 ? " const $$ 1 = Cint($$ 2)" : " const $$ 1 = UInt32($$ 2)" ' | LC_ALL=C sort > $@)
32
50
33
- $(BUILDDIR ) /errno_h.jl :
51
+ $(build_datarootdir ) /julia/src/errno_h.jl :
52
+ @mkdir -p $(dir $@ )
34
53
@$(call PRINT_PERL, echo '#include <errno.h>' | $(CPP ) -dM - | perl -nle 'print "const $$1 = Int32($$2) " if /^#define\s+(E\w+)\s+(\d+)\s*$$ /' | LC_ALL=C sort > $@ )
35
54
36
- $(BUILDDIR ) /file_constants.jl : $(SRCDIR ) /../src/file_constants.h
55
+ $(build_datarootdir ) /julia/src/file_constants.jl : $(JULIAHOME ) /src/file_constants.h
56
+ @mkdir -p $(dir $@ )
37
57
@$(call PRINT_PERL, $(CPP_STDOUT ) -DJULIA $< | perl -nle 'print "$$1 0o$$2" if /^(\s* const\s+[A-z_]+\s+=) \s + (0[0-9]* )\s * $$ /; print " $$ 1" if /^\s * (const\s +[A-z_]+\s +=\s + ([1-9]| 0x)[0-9A-z]* )\s * $$ /' > $@)
38
58
39
- $(BUILDDIR ) /uv_constants.jl : $(SRCDIR ) /../src/uv_constants.h $(LIBUV_INC ) /uv/errno.h
59
+ $(build_datarootdir ) /julia/src/uv_constants.jl : $(JULIAHOME ) /src/uv_constants.h $(LIBUV_INC ) /uv/errno.h
60
+ @mkdir -p $(dir $@ )
40
61
@$(call PRINT_PERL, $(CPP_STDOUT ) "-I$(LIBUV_INC ) " -DJULIA $< | tail -n 16 > $@ )
41
62
63
+ $(build_datarootdir ) /julia/src/build_h.jl.phony : $(BUILDDIR ) /build_h.jl.phony
42
64
$(BUILDDIR ) /build_h.jl.phony :
65
+ @mkdir -p $(build_datarootdir ) /julia/src
43
66
@echo " # This file is automatically generated in base/Makefile" > $@
44
67
ifeq ($(XC_HOST ) ,)
45
68
@echo "const MACHINE = \"$(BUILD_MACHINE)\"" >> $@
@@ -87,35 +110,44 @@ endif
87
110
88
111
@# This to ensure that we always rebuild this file, but only when it is modified do we touch build_h.jl,
89
112
@# ensuring we rebuild the system image as infrequently as possible
90
- @if ! cmp -s $@ build_h.jl; then \
113
+ @if ! cmp -s $@ $(build_datarootdir)/julia/src/ build_h.jl; then \
91
114
$(call PRINT_PERL,) \
92
- mv $@ build_h.jl; \
115
+ mv $@ $(build_datarootdir)/julia/src/ build_h.jl; \
93
116
else \
94
117
rm -f $@; \
95
118
fi
96
119
120
+ $(build_datarootdir ) /julia/src/version_git.jl.phony : $(BUILDDIR ) /version_git.jl.phony
97
121
$(BUILDDIR ) /version_git.jl.phony : $(SRCDIR ) /version_git.sh
98
- ifneq ($(NO_GIT ) , 1)
99
- sh $< $(SRCDIR) > $@
100
- @# This to avoid touching version_git.jl when it is not modified,
101
- @# so that the system image does not need to be rebuilt.
102
- @if ! cmp -s $@ version_git.jl; then \
103
- $(call PRINT_PERL,) \
104
- mv $@ version_git.jl; \
105
- else \
106
- rm -f $@; \
107
- fi
108
- else
109
- ifeq ($(shell [ -f $(BUILDDIR ) /version_git.jl ] && echo "true") , true)
110
- @# Give warning if boilerplate git is used
122
+ @mkdir -p $(build_datarootdir ) /julia/src
123
+ ifneq ($(NO_GIT ) ,1)
124
+ @sh $< $(SRCDIR) > $@
125
+ else ifeq ($(shell [ -f $(BUILDDIR)/version_git.jl ] && echo "true"), true)
126
+ @# Give warning if boilerplate git is found here
111
127
@if grep -q "Default output if git is not available" $(BUILDDIR)/version_git.jl; then \
112
128
echo "WARNING: Using boilerplate git version info" >&2; \
113
129
fi
130
+ @cp $(BUILDDIR)/version_git.jl $@
131
+ else ifeq ($(shell [ -f $(SRCDIR)/version_git.jl ] && echo "true"), true)
132
+ @# Give warning if boilerplate git is found here
133
+ @if grep -q "Default output if git is not available" $(SRCDIR)/version_git.jl; then \
134
+ echo "WARNING: Using boilerplate git version info" >&2; \
135
+ fi
136
+ @cp $(SRCDIR)/version_git.jl $@
114
137
else
115
138
$(warning "WARNING: Generating boilerplate git version info")
116
- @sh $(SRCDIR)/version_git.sh $(SRCDIR) NO_GIT > $(BUILDDIR)/version_git.jl
117
- endif
139
+ @sh $< $(SRCDIR) NO_GIT > $@
118
140
endif
141
+ @# This to avoid touching version_git.jl when it is not modified,
142
+ @# so that the system image does not need to be rebuilt.
143
+ @if ! cmp -s $@ $(build_datarootdir)/julia/src/version_git.jl; then \
144
+ $(call PRINT_PERL,) \
145
+ mv $@ $(build_datarootdir)/julia/src/version_git.jl; \
146
+ else \
147
+ rm -f $@; \
148
+ fi
149
+ $(BUILDDIR ) /version_git.jl : $(SRCDIR ) /version_git.sh
150
+ sh $< $(SRCDIR ) > $@
119
151
120
152
ifeq (,$(filter $(OS ) , WINNT emscripten) )
121
153
# For any USE_SYSTEM_* libraries that will be dynamically loaded by libjulia,
@@ -163,7 +195,7 @@ endif
163
195
define symlink_system_library
164
196
libname_$2 := $$(notdir $(call versioned_libname,$2,$3) )
165
197
libpath_$2 := $$(shell $$(call spawn,$$(LIBWHICH ) ) -p $$(libname_$2 ) 2>/dev/null)
166
- symlink_$2: $$(build_private_libdir ) /$$(libname_$2 )
198
+ symlink_$2: $$(build_private_libdir ) /$$(libname_$2 ) .FORCE
167
199
$$(build_private_libdir ) /$$(libname_$2 ) :
168
200
@if [ -e "$$(libpath_$2 ) " ]; then \
169
201
REALPATH=$$(libpath_$2 ) ; \
@@ -269,7 +301,10 @@ endif
269
301
270
302
symlink_system_libraries : $(SYMLINK_SYSTEM_LIBRARIES )
271
303
272
- .PHONY : $(BUILDDIR ) /build_h.jl.phony $(BUILDDIR ) /version_git.jl.phony clean all symlink_*
304
+ .FORCE :
305
+ .PHONY : $(BUILDDIR ) /version_git.jl $(BUILDDIR ) /version_git.jl.phony $(build_datarootdir ) /julia/src/version_git.jl.phony \
306
+ $(BUILDDIR ) /build_h.jl.phony $(build_datarootdir ) /julia/src/build_h.jl.phony \
307
+ clean all .FORCE
273
308
274
309
clean :
275
310
-rm -f $(BUILDDIR ) /pcre_h.jl
@@ -281,4 +316,5 @@ clean:
281
316
-rm -f $(BUILDDIR ) /file_constants.jl
282
317
-rm -f $(BUILDDIR ) /version_git.jl
283
318
-rm -f $(BUILDDIR ) /version_git.jl.phony
319
+ -rm -rf $(build_datarootdir ) /julia/src/*
284
320
-rm -f $(build_private_libdir ) /lib* .$(SHLIB_EXT ) *
0 commit comments