-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Makefile
282 lines (256 loc) · 11.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
BUILDDIR := .
JULIAHOME := $(abspath $(SRCDIR)/..)
include $(JULIAHOME)/deps/Versions.make
include $(JULIAHOME)/Make.inc
TAGGED_RELEASE_BANNER := ""
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)
PCRE_CONST := 0x[0-9a-fA-F]+|[0-9]+|\([\-0-9]+\)
ifeq ($(USE_SYSTEM_PCRE), 1)
PCRE_INCL_PATH := $(shell $(PCRE_CONFIG) --prefix)/include/pcre2.h
else
PCRE_INCL_PATH := $(build_includedir)/pcre2.h
endif
define parse_features
@echo "# $(2) features" >> $@
@$(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*(?:\/\/.*)?$$/' >> $@)
@echo >> $@
endef
$(BUILDDIR)/features_h.jl: $(SRCDIR)/../src/features_x86.h $(SRCDIR)/../src/features_aarch32.h $(SRCDIR)/../src/features_aarch64.h
@-rm -f $@
@$(call parse_features,x86,X86)
@$(call parse_features,aarch32,AArch32)
@$(call parse_features,aarch64,AArch64)
$(BUILDDIR)/pcre_h.jl: $(PCRE_INCL_PATH)
@$(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 > $@)
$(BUILDDIR)/errno_h.jl:
@$(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 > $@)
$(BUILDDIR)/file_constants.jl: $(SRCDIR)/../src/file_constants.h
@$(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*$$/' > $@)
$(BUILDDIR)/uv_constants.jl: $(SRCDIR)/../src/uv_constants.h $(LIBUV_INC)/uv/errno.h
@$(call PRINT_PERL, $(CPP_STDOUT) "-I$(LIBUV_INC)" -DJULIA $< | tail -n 16 > $@)
$(BUILDDIR)/build_h.jl.phony:
@echo "# This file is automatically generated in base/Makefile" > $@
ifeq ($(XC_HOST),)
@echo "const MACHINE = \"$(BUILD_MACHINE)\"" >> $@
else
@echo "const MACHINE = \"$(XC_HOST)\"" >> $@
endif
@echo "const libm_name = \"$(LIBMNAME)\"" >> $@
@echo "const libblas_name = \"$(LIBBLASNAME)\"" >> $@
@echo "const liblapack_name = \"$(LIBLAPACKNAME)\"" >> $@
ifeq ($(USE_BLAS64), 1)
@echo "const USE_BLAS64 = true" >> $@
else
@echo "const USE_BLAS64 = false" >> $@
endif
ifeq ($(USE_GPL_LIBS), 1)
@echo "const USE_GPL_LIBS = true" >> $@
else
@echo "const USE_GPL_LIBS = false" >> $@
endif
@echo "const libllvm_version_string = \"$$($(LLVM_CONFIG_HOST) --version)\"" >> $@
@echo "const VERSION_STRING = \"$(JULIA_VERSION)\"" >> $@
@echo "const TAGGED_RELEASE_BANNER = \"$(TAGGED_RELEASE_BANNER)\"" >> $@
ifeq ($(OS),WINNT)
@printf 'const SYSCONFDIR = "%s"\n' '$(subst /,\\,$(sysconfdir_rel))' >> $@
@printf 'const DATAROOTDIR = "%s"\n' '$(subst /,\\,$(datarootdir_rel))' >> $@
@printf 'const DOCDIR = "%s"\n' '$(subst /,\\,$(docdir_rel))' >> $@
@printf 'const LIBDIR = "%s"\n' '$(subst /,\\,$(libdir_rel))' >> $@
@printf 'const LIBEXECDIR = "%s"\n' '$(subst /,\\,$(libexecdir_rel))' >> $@
@printf 'const PRIVATE_LIBDIR = "%s"\n' '$(subst /,\\,$(private_libdir_rel))' >> $@
@printf 'const INCLUDEDIR = "%s"\n' '$(subst /,\\,$(includedir_rel))' >> $@
else
@echo "const SYSCONFDIR = \"$(sysconfdir_rel)\"" >> $@
@echo "const DATAROOTDIR = \"$(datarootdir_rel)\"" >> $@
@echo "const DOCDIR = \"$(docdir_rel)\"" >> $@
@echo "const LIBDIR = \"$(libdir_rel)\"" >> $@
@echo "const LIBEXECDIR = \"$(libexecdir_rel)\"" >> $@
@echo "const PRIVATE_LIBDIR = \"$(private_libdir_rel)\"" >> $@
@echo "const INCLUDEDIR = \"$(includedir_rel)\"" >> $@
endif
ifeq ($(DARWIN_FRAMEWORK), 1)
@echo "const DARWIN_FRAMEWORK = true" >> $@
@echo "const DARWIN_FRAMEWORK_NAME = \"$(FRAMEWORK_NAME)\"" >> $@
else
@echo "const DARWIN_FRAMEWORK = false" >> $@
endif
@echo "const BUILD_TRIPLET = \"$(BB_TRIPLET_LIBGFORTRAN_CXXABI)\"" >> $@
@# This to ensure that we always rebuild this file, but only when it is modified do we touch build_h.jl,
@# ensuring we rebuild the system image as infrequently as possible
@if ! cmp -s $@ build_h.jl; then \
$(call PRINT_PERL,) \
mv $@ build_h.jl; \
else \
rm -f $@; \
fi
$(BUILDDIR)/version_git.jl.phony: $(SRCDIR)/version_git.sh
ifneq ($(NO_GIT), 1)
sh $< $(SRCDIR) > $@
@# This to avoid touching git_version.jl when it is not modified,
@# so that the system image does not need to be rebuilt.
@if ! cmp -s $@ version_git.jl; then \
$(call PRINT_PERL,) \
mv $@ version_git.jl; \
else \
rm -f $@; \
fi
else
ifeq ($(shell [ -f $(BUILDDIR)/version_git.jl ] && echo "true"), true)
@# Give warning if boilerplate git is used
@if grep -q "Default output if git is not available" $(BUILDDIR)/version_git.jl; then \
echo "WARNING: Using boilerplate git version info" >&2; \
fi
else
$(warning "WARNING: Generating boilerplate git version info")
@sh $(SRCDIR)/version_git.sh $(SRCDIR) NO_GIT > $(BUILDDIR)/version_git.jl
endif
endif
ifeq (,$(filter $(OS), WINNT emscripten))
# For any USE_SYSTEM_* libraries that will be dynamically loaded by libjulia,
# put a symlink in the private libdir.
# System package managers may want to install these links manually,
# but if not, this will try to create the proper symlink to the right minor version.
all: symlink_system_libraries
SYMLINK_SYSTEM_LIBRARIES :=
# if it's a symlink, pick up the symlink target instead, for one level of indirection
resolve_path = \
$1_wd="`pwd`" && \
$1_=`readlink -n $${$1} || true` && \
if [ -n "$${$1_}" ]; then $1_wd=`dirname "$${$1}"`; $1="$${$1_}"; fi
## if it's a relative path, make it an absolute path
resolve_path += && \
if [ -z "`echo $${$1} | grep '^/'`" ]; then $1=$${$1_wd}/$${$1}; fi
ifeq ($(OS), Darwin)
# try to use the install_name id instead (unless it is an @rpath or such)
# if it's a relative path, make it an absolute path using the working directory from $1,
# while in theory incorrect, this has been observed to be a common build mistake for many libraries
resolve_path += && \
$1_=`otool -D $${$1} | tail -n +2 | sed -e 's/^@.*$$//'` && \
if [ -n "$${$1_}" ]; then \
$1_wd=`dirname "$${$1}"`; $1=$${$1_}; \
if [ -z "`echo $${$1} | grep '^/'`" ]; then $1=$${$1_wd}/$${$1}; fi; \
fi
else
# try to use the SO_NAME (if the named file exists)
resolve_path += && \
$1_=`objdump -p "$${$1}" | awk '/SONAME/ {print $$2}'` && \
if [ -n "$${$1_}" ]; then \
$1_=$$(dirname "$${$1}")/$${$1_}; \
if [ -e "$${$1_}" ]; then $1=$${$1_}; fi; \
fi
endif
## debug code: `make resolve-path P=<path to test>`
#resolve_path += && \
# echo "$${$1_wd} $${$1}"
#resolve-path:
# $(call resolve_path,P) && \
# echo "$$P"
define symlink_system_library
libname_$2 := $$(notdir $(call versioned_libname,$2,$3))
libpath_$2 := $$(shell $$(call spawn,$$(LIBWHICH)) -p $$(libname_$2) 2>/dev/null)
symlink_$2: $$(build_private_libdir)/$$(libname_$2)
$$(build_private_libdir)/$$(libname_$2):
@if [ -e "$$(libpath_$2)" ]; then \
REALPATH=$$(libpath_$2); \
$$(call resolve_path,REALPATH) && \
[ -e "$$$$REALPATH" ] && \
([ ! -e "$$@" ] || rm "$$@") && \
echo ln -sf "$$$$REALPATH" "$$@" && \
ln -sf "$$$$REALPATH" "$$@"; \
else \
if [ "$4" != "ALLOW_FAILURE" ]; then \
echo "System library symlink failure: Unable to locate $$(libname_$2) on your system!" >&2; \
false; \
fi; \
fi
ifneq ($$(USE_SYSTEM_$1),0)
SYMLINK_SYSTEM_LIBRARIES += symlink_$2
endif
endef
# libexec executables
symlink_p7zip: $(build_bindir)/7z$(EXE)
ifneq ($(USE_SYSTEM_P7ZIP),0)
SYMLINK_SYSTEM_LIBRARIES += symlink_p7zip
7Z_PATH := $(shell which 7z$(EXE))
endif
$(build_bindir)/7z$(EXE):
[ -e "$(7Z_PATH)" ] && \
([ ! -e "$@" ] || rm "$@") && \
ln -svf "$(7Z_PATH)" "$@"
# the following excludes: libuv.a, libutf8proc.a
ifneq ($(USE_SYSTEM_LIBM),0)
$(eval $(call symlink_system_library,LIBM,$(LIBMNAME)))
else ifneq ($(USE_SYSTEM_OPENLIBM),0)
$(eval $(call symlink_system_library,OPENLIBM,$(LIBMNAME)))
endif
$(eval $(call symlink_system_library,CSL,libgcc_s,1))
ifneq (,$(LIBGFORTRAN_VERSION))
$(eval $(call symlink_system_library,CSL,libgfortran,$(LIBGFORTRAN_VERSION)))
endif
$(eval $(call symlink_system_library,CSL,libquadmath,0))
$(eval $(call symlink_system_library,CSL,libstdc++,6))
# We allow libssp, libatomic and libgomp to fail as they are not available on all systems
$(eval $(call symlink_system_library,CSL,libssp,0,ALLOW_FAILURE))
$(eval $(call symlink_system_library,CSL,libatomic,1,ALLOW_FAILURE))
$(eval $(call symlink_system_library,CSL,libgomp,1,ALLOW_FAILURE))
$(eval $(call symlink_system_library,PCRE,libpcre2-8))
$(eval $(call symlink_system_library,DSFMT,libdSFMT))
$(eval $(call symlink_system_library,LIBBLASTRAMPOLINE,libblastrampoline))
$(eval $(call symlink_system_library,BLAS,$(LIBBLASNAME)))
ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
$(eval $(call symlink_system_library,LAPACK,$(LIBLAPACKNAME)))
endif
$(eval $(call symlink_system_library,GMP,libgmp))
$(eval $(call symlink_system_library,MPFR,libmpfr))
$(eval $(call symlink_system_library,MBEDTLS,libmbedtls))
$(eval $(call symlink_system_library,MBEDTLS,libmbedcrypto))
$(eval $(call symlink_system_library,MBEDTLS,libmbedx509))
$(eval $(call symlink_system_library,LIBSSH2,libssh2))
$(eval $(call symlink_system_library,NGHTTP2,libnghttp2))
$(eval $(call symlink_system_library,CURL,libcurl))
$(eval $(call symlink_system_library,LIBGIT2,libgit2))
$(eval $(call symlink_system_library,LIBSUITESPARSE,libamd))
$(eval $(call symlink_system_library,LIBSUITESPARSE,libcamd))
$(eval $(call symlink_system_library,LIBSUITESPARSE,libccolamd))
$(eval $(call symlink_system_library,LIBSUITESPARSE,libcholmod))
$(eval $(call symlink_system_library,LIBSUITESPARSE,libcolamd))
$(eval $(call symlink_system_library,LIBSUITESPARSE,libumfpack))
$(eval $(call symlink_system_library,LIBSUITESPARSE,libspqr))
$(eval $(call symlink_system_library,LIBSUITESPARSE,libsuitesparseconfig))
# EXCLUDED LIBRARIES (installed/used, but not vendored for use with dlopen):
# libunwind
endif # WINNT
symlink_libLLVM: $(build_private_libdir)/libLLVM.$(SHLIB_EXT)
ifneq ($(USE_SYSTEM_LLVM),0)
LLVM_CONFIG_HOST_LIBS := $(shell $(LLVM_CONFIG_HOST) --libfiles)
# HACK: llvm-config doesn't correctly point to shared libs on all platforms
# https://github.com/JuliaLang/julia/issues/29981
else
LLVM_CONFIG_HOST_LIBS := $(shell $(LLVM_CONFIG_HOST) --libdir)/libLLVM.$(SHLIB_EXT)
endif
$(build_private_libdir)/libLLVM.$(SHLIB_EXT):
REALPATH=$(LLVM_CONFIG_HOST_LIBS) && \
$(call resolve_path,REALPATH) && \
[ -e "$$REALPATH" ] && \
([ ! -e "$@" ] || rm "$@") && \
echo ln -sf "$$REALPATH" "$@" && \
ln -sf "$$REALPATH" "$@"
ifneq ($(USE_SYSTEM_LLVM),0)
ifneq ($(USE_LLVM_SHLIB),0)
SYMLINK_SYSTEM_LIBRARIES += symlink_libLLVM
endif
endif
symlink_system_libraries: $(SYMLINK_SYSTEM_LIBRARIES)
.PHONY: $(BUILDDIR)/build_h.jl.phony $(BUILDDIR)/version_git.jl.phony clean all symlink_*
clean:
-rm -f $(BUILDDIR)/pcre_h.jl
-rm -f $(BUILDDIR)/errno_h.jl
-rm -f $(BUILDDIR)/build_h.jl
-rm -f $(BUILDDIR)/build_h.jl.phony
-rm -f $(BUILDDIR)/features_h.jl
-rm -f $(BUILDDIR)/uv_constants.jl
-rm -f $(BUILDDIR)/file_constants.jl
-rm -f $(BUILDDIR)/version_git.jl
-rm -f $(BUILDDIR)/version_git.jl.phony
-rm -f $(build_private_libdir)/lib*.$(SHLIB_EXT)*