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
|
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
BUILDDIR := .
JULIAHOME := $(abspath $(SRCDIR)/..)
include $(JULIAHOME)/deps/Versions.make
include $(JULIAHOME)/Make.inc
TAGGED_RELEASE_BANNER := ""
ifneq ($(USEMSVC), 1)
CPP_STDOUT := $(CPP) -P
else
CPP_STDOUT := $(CPP) -E
endif
all: $(addprefix $(BUILDDIR)/,pcre_h.jl errno_h.jl build_h.jl.phony file_constants.jl uv_constants.jl version_git.jl.phony)
PCRE_CONST := 0x[0-9a-fA-F]+|[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
$(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 "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 $(build_includedir)/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 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 PRIVATE_LIBDIR = \"$(private_libdir_rel)\"" >> $@
@echo "const INCLUDEDIR = \"$(includedir_rel)\"" >> $@
endif
@# 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
ifneq ($(OS), WINNT)
# 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
symlink_$1: $$(build_private_libdir)/$1.$$(SHLIB_EXT)
$$(build_private_libdir)/$1.$$(SHLIB_EXT):
REALPATH=`$$(call spawn,$$(build_depsbindir)/libwhich) -p $$(notdir $$@)` && \
$$(call resolve_path,REALPATH) && \
[ -e "$$$$REALPATH" ] && \
([ ! -e "$$@" ] || rm "$$@") && \
echo ln -sf "$$$$REALPATH" "$$@" && \
ln -sf "$$$$REALPATH" "$$@"
ifneq ($2,)
ifneq ($$(USE_SYSTEM_$2),0)
SYMLINK_SYSTEM_LIBRARIES += symlink_$1
endif
endif
endef
# the following excludes: libuv.a, libutf8proc.a
$(eval $(call symlink_system_library,$(LIBMNAME)))
ifneq ($(USE_SYSTEM_LIBM),0)
SYMLINK_SYSTEM_LIBRARIES += symlink_$(LIBMNAME)
else ifneq ($(USE_SYSTEM_OPENLIBM),0)
SYMLINK_SYSTEM_LIBRARIES += symlink_$(LIBMNAME)
endif
$(eval $(call symlink_system_library,libpcre2-8,PCRE))
$(eval $(call symlink_system_library,libdSFMT,DSFMT))
$(eval $(call symlink_system_library,$(LIBBLASNAME),BLAS))
ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
$(eval $(call symlink_system_library,$(LIBLAPACKNAME),LAPACK))
endif
$(eval $(call symlink_system_library,libgmp,GMP))
$(eval $(call symlink_system_library,libmpfr,MPFR))
$(eval $(call symlink_system_library,libmbedtls,MBEDTLS))
$(eval $(call symlink_system_library,libssh2,LIBSSH2))
$(eval $(call symlink_system_library,libcurl,CURL))
$(eval $(call symlink_system_library,libgit2,LIBGIT2))
$(eval $(call symlink_system_library,libamd,SUITESPARSE))
$(eval $(call symlink_system_library,libcamd,SUITESPARSE))
$(eval $(call symlink_system_library,libccolamd,SUITESPARSE))
$(eval $(call symlink_system_library,libcholmod,SUITESPARSE))
$(eval $(call symlink_system_library,libcolamd,SUITESPARSE))
$(eval $(call symlink_system_library,libumfpack,SUITESPARSE))
$(eval $(call symlink_system_library,libspqr,SUITESPARSE))
$(eval $(call symlink_system_library,libsuitesparseconfig,SUITESPARSE))
ifneq ($(DISABLE_LIBUNWIND), 1)
$(eval $(call symlink_system_library,libunwind,LIBUNWIND))
endif
endif # WINNT
symlink_libLLVM: $(build_private_libdir)/libLLVM.dylib
$(build_private_libdir)/libLLVM.dylib:
REALPATH=`$(LLVM_CONFIG_HOST) --libdir`/libLLVM.$(SHLIB_EXT) && \
$(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)/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)*
|