Skip to content

Commit

Permalink
normalize deps Makefile targets
Browse files Browse the repository at this point in the history
using a consistent mapping between target names reduces the coupling between targets
and should make it easier to add features like reinstall, uninstall, etc.

and it fixes #17671 and #17282
  • Loading branch information
vtjnash committed Aug 8, 2016
1 parent 2277270 commit c11af2d
Show file tree
Hide file tree
Showing 26 changed files with 652 additions and 667 deletions.
5 changes: 2 additions & 3 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -979,9 +979,8 @@ endif
# ATLAS
# ATLAS must have been previously built with "make -C deps compile-atlas" (without -jN),
# or installed to usr/lib/libatlas from some another source (built as
# a shared library, for your platform, single threaded)
# ATLAS must have been previously installed to usr/lib/libatlas
# (built as a shared library, for your platform, single threaded)
USE_ATLAS := 0
ATLAS_LIBDIR := $(build_libdir)
#or ATLAS_LIBDIR := /path/to/system/atlas/lib
Expand Down
9 changes: 3 additions & 6 deletions contrib/windows/msys_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ echo 'override LIBLAPACKNAME = $(LIBBLASNAME)' >> Make.user
# libuv since its static lib is no longer included in the binaries
# openlibm since we need it as a static library to work properly
# utf8proc since its headers are not in the binary download
echo 'override STAGE1_DEPS = libuv' >> Make.user
echo 'override STAGE2_DEPS = utf8proc' >> Make.user
echo 'override STAGE3_DEPS = ' >> Make.user
echo 'override STAGE4_DEPS = ' >> Make.user
echo 'override DEP_LIBS = libuv utf8proc' >> Make.user

if [ -n "$USEMSVC" ]; then
# Openlibm doesn't build well with MSVC right now
Expand All @@ -188,14 +185,14 @@ if [ -n "$USEMSVC" ]; then
make -C deps install-libuv install-utf8proc
cp usr/lib/uv.lib usr/lib/libuv.a
echo 'override CC += -TP' >> Make.user
echo 'override STAGE1_DEPS += dsfmt' >> Make.user
echo 'override DEP_LIBS += dsfmt' >> Make.user

# Create a modified version of compile for wrapping link
sed -e 's/-link//' -e 's/cl/link/g' -e 's/ -Fe/ -OUT:/' \
-e 's|$dir/$lib|$dir/lib$lib|g' deps/srccache/libuv/compile > linkld
chmod +x linkld
else
echo 'override STAGE1_DEPS += openlibm' >> Make.user
echo 'override DEP_LIBS += openlibm' >> Make.user
make check-whitespace
make VERBOSE=1 -C base version_git.jl.phony
echo 'NO_GIT = 1' >> Make.user
Expand Down
157 changes: 31 additions & 126 deletions deps/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## high-level setup ##
default: install
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
JULIAHOME := $(abspath $(SRCDIR)/..)
ifeq ($(abspath .),$(abspath $(SRCDIR)))
Expand All @@ -8,12 +9,13 @@ BUILDDIR := .
endif
include $(SRCDIR)/Versions.make
include $(JULIAHOME)/Make.inc
include $(SRCDIR)/llvm-ver.make
include $(SRCDIR)/tools/common.mk
include $(SRCDIR)/tools/git-external.mk

# Special comments:
#
# all targets in here should follow the same structure,
# and provide a get-a, configure-a, compile-a, check-a, and install-a
# and provide a get-a, extract-a, configure-a, compile-a, check-a, and install-a
# additionally all targets should be listed in the getall target for easier off-line compilation
# if you are adding a new target, it can help to copy an similar, existing target
#
Expand All @@ -30,89 +32,34 @@ include $(SRCDIR)/llvm-ver.make
# be rebuilt in a single invocation
#

## Some shared configuration options ##

CONFIGURE_COMMON := --prefix=$(abspath $(build_prefix)) --build=$(BUILD_MACHINE) --libdir=$(abspath $(build_libdir)) --bindir=$(abspath $(build_depsbindir)) $(CUSTOM_LD_LIBRARY_PATH)
ifneq ($(XC_HOST),)
CONFIGURE_COMMON += --host=$(XC_HOST)
endif
ifeq ($(OS),WINNT)
ifneq ($(USEMSVC), 1)
CONFIGURE_COMMON += LDFLAGS="$(LDFLAGS) -Wl,--stack,8388608"
endif
endif
CONFIGURE_COMMON += F77="$(FC)" CC="$(CC) $(DEPS_CFLAGS)" CXX="$(CXX) $(DEPS_CXXFLAGS)"

CMAKE_CC_ARG := $(CC_ARG) $(DEPS_CFLAGS)
CMAKE_CXX_ARG := $(CXX_ARG) $(DEPS_CXXFLAGS)

CMAKE_COMMON := -DCMAKE_INSTALL_PREFIX:PATH=$(build_prefix) -DCMAKE_PREFIX_PATH=$(build_prefix)
ifneq ($(VERBOSE), 0)
CMAKE_COMMON += -DCMAKE_VERBOSE_MAKEFILE=ON
endif
# The call to which here is to work around https://cmake.org/Bug/view.php?id=14366
CMAKE_COMMON += -DCMAKE_C_COMPILER="$$(which $(CC_BASE))"
ifneq ($(strip $(CMAKE_CC_ARG)),)
CMAKE_COMMON += -DCMAKE_C_COMPILER_ARG1="$(CMAKE_CC_ARG)"
endif
CMAKE_COMMON += -DCMAKE_CXX_COMPILER="$(CXX_BASE)"
ifneq ($(strip $(CMAKE_CXX_ARG)),)
CMAKE_COMMON += -DCMAKE_CXX_COMPILER_ARG1="$(CMAKE_CXX_ARG)"
endif

ifeq ($(OS),WINNT)
CMAKE_COMMON += -DCMAKE_SYSTEM_NAME=Windows
ifneq ($(BUILD_OS),WINNT)
CMAKE_COMMON += -DCMAKE_RC_COMPILER="$$(which $(CROSS_COMPILE)windres)"
endif
endif

# For now this is LLVM specific, but I expect it won't be in the future
ifeq ($(LLVM_USE_CMAKE),1)
ifeq ($(CMAKE_GENERATOR),Ninja)
CMAKE_GENERATOR_COMMAND := -G Ninja
else ifeq ($(CMAKE_GENERATOR),make)
CMAKE_GENERATOR_COMMAND := -G "Unix Makefiles"
else
$(error Unknown CMake generator '$(CMAKE_GENERATOR)'. Options are 'Ninja' and 'make')
endif
endif

# If the top-level Makefile is called with environment variables,
# they will override the values passed above to ./configure
MAKE_COMMON := DESTDIR="" prefix=$(build_prefix) bindir=$(build_depsbindir) libdir=$(build_libdir) shlibdir=$(build_shlibdir) libexecdir=$(build_libexecdir) datarootdir=$(build_datarootdir) includedir=$(build_includedir) sysconfdir=$(build_sysconfdir) O=


## Overall configuration of which rules exist and should be run by default ##

# prevent installing libs into usr/lib64 on opensuse
unexport CONFIG_SITE

STAGE1_DEPS :=
STAGE2_DEPS :=
DEP_LIBS :=
ifeq ($(USE_GPL_LIBS), 1)
STAGE3_DEPS := suitesparse-wrapper
else
STAGE3_DEPS :=
DEP_LIBS += suitesparse-wrapper
endif

ifeq ($(USE_SYSTEM_LIBUV), 0)
STAGE1_DEPS += libuv
DEP_LIBS += libuv
endif

ifeq ($(USE_SYSTEM_LIBUNWIND), 0)
ifeq ($(OS), Linux)
STAGE1_DEPS += unwind
DEP_LIBS += unwind
else ifeq ($(OS), FreeBSD)
STAGE1_DEPS += unwind
DEP_LIBS += unwind
else ifeq ($(OS), Darwin)
STAGE1_DEPS += osxunwind
DEP_LIBS += osxunwind
endif
endif

ifeq ($(OS), Linux)
ifeq ($(USE_SYSTEM_PATCHELF), 0)
STAGE1_DEPS += patchelf
DEP_LIBS += patchelf
PATCHELF:=$(build_depsbindir)/patchelf
else
PATCHELF:=patchelf
Expand All @@ -124,79 +71,79 @@ PATCHELF_BIN := $(CUSTOM_LD_LIBRARY_PATH) $(PATCHELF)

ifeq ($(USE_SYSTEM_OPENLIBM), 0)
ifeq ($(USE_SYSTEM_LIBM), 0)
STAGE1_DEPS += openlibm
DEP_LIBS += openlibm
endif
endif

ifeq ($(USE_SYSTEM_OPENSPECFUN), 0)
STAGE1_DEPS += openspecfun
DEP_LIBS += openspecfun
endif

ifeq ($(USE_SYSTEM_DSFMT), 0)
STAGE1_DEPS += dsfmt
DEP_LIBS += dsfmt
endif

ifeq ($(USE_SYSTEM_LLVM), 0)
STAGE1_DEPS += llvm
DEP_LIBS += llvm
endif

ifeq ($(USE_SYSTEM_PCRE), 0)
STAGE1_DEPS += pcre
DEP_LIBS += pcre
endif

ifeq ($(USE_SYSTEM_BLAS), 0)
STAGE1_DEPS += openblas
DEP_LIBS += openblas
ifeq ($(USE_BLAS64), 1)
ifeq ($(OS), Darwin)
STAGE1_DEPS += objconv
DEP_LIBS += objconv
endif
endif
endif

ifeq ($(USE_GPL_LIBS), 1)
ifeq ($(USE_SYSTEM_FFTW), 0)
STAGE1_DEPS += fftw
DEP_LIBS += fftw
endif
endif

ifeq ($(USE_SYSTEM_GMP), 0)
STAGE1_DEPS += gmp
DEP_LIBS += gmp
endif

ifeq ($(USE_SYSTEM_MBEDTLS), 0)
STAGE1_DEPS += mbedtls
DEP_LIBS += mbedtls
endif

ifeq ($(USE_SYSTEM_LIBSSH2), 0)
STAGE2_DEPS += libssh2
DEP_LIBS += libssh2
endif

ifneq ($(OS), WINNT)
ifeq ($(USE_SYSTEM_CURL), 0)
STAGE3_DEPS += curl
DEP_LIBS += curl
endif
endif

ifeq ($(USE_SYSTEM_LIBGIT2), 0)
STAGE4_DEPS += libgit2
DEP_LIBS += libgit2
endif

ifeq ($(USE_SYSTEM_MPFR), 0)
STAGE2_DEPS += mpfr
DEP_LIBS += mpfr
endif

ifeq ($(USE_SYSTEM_ARPACK), 0)
STAGE2_DEPS += arpack
DEP_LIBS += arpack
endif

ifeq ($(USE_GPL_LIBS), 1)
ifeq ($(USE_SYSTEM_SUITESPARSE), 0)
STAGE2_DEPS += suitesparse
DEP_LIBS += suitesparse
endif
endif

ifeq ($(USE_SYSTEM_UTF8PROC), 0)
STAGE2_DEPS += utf8proc
DEP_LIBS += utf8proc
endif

# Only compile standalone LAPACK if we are not using OpenBLAS.
Expand All @@ -205,22 +152,15 @@ endif
# build LAPACK as the vendor LAPACK may be too old (eg. Apple vecLib)
ifeq ($(USE_SYSTEM_BLAS), 1)
ifeq ($(USE_SYSTEM_LAPACK), 0)
STAGE2_DEPS += lapack
endif
DEP_LIBS += lapack
endif

#Platform specific flags

ifeq ($(OS), WINNT)
LIBTOOL_CCLD := CCLD="$(CC) -no-undefined -avoid-version"
endif

## Common build target prefixes

DEP_LIBS := $(STAGE1_DEPS) $(STAGE2_DEPS) $(STAGE3_DEPS) $(STAGE4_DEPS)

default: install | $(build_prefix)
default: | $(build_prefix)
get: $(addprefix get-, $(DEP_LIBS))
extract: $(addprefix extract-, $(DEP_LIBS))
configure: $(addprefix configure-, $(DEP_LIBS))
compile: $(addprefix compile-, $(DEP_LIBS))
check: $(addprefix check-, $(DEP_LIBS))
Expand All @@ -230,35 +170,6 @@ distcleanall: $(addprefix distclean-, $(DEP_LIBS))
rm -rf $(build_prefix)
getall: get-llvm get-libuv get-pcre get-openlibm get-openspecfun get-dsfmt get-openblas get-lapack get-fftw get-suitesparse get-arpack get-unwind get-osxunwind get-gmp get-mpfr get-patchelf get-utf8proc get-virtualenv get-objconv get-mbedtls get-libssh2 get-curl get-libgit2

## PATHS ##
# sort is used to remove potential duplicates
DIRS := $(sort $(build_bindir) $(build_depsbindir) $(build_libdir) $(build_includedir) $(build_sysconfdir) $(build_datarootdir) $(build_staging))

$(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir))))

$(build_prefix): | $(DIRS)
$(eval $(call dir_target,$(SRCDIR)/srccache))

## A rule for calling `make install` ##
# rule: dependencies
# $(call make-install,rel-build-directory,add-args)
# touch -c $@
# this rule ensures that make install is more nearly atomic
# so it's harder to get half-installed (or half-reinstalled) dependencies
MAKE_DESTDIR = "$(build_staging)/$1"
define staged-install
rm -rf $(build_staging)/$1
$2
mkdir -p $(build_prefix)
cp -af $(build_staging)/$1$(build_prefix)/* $(build_prefix)
endef

define make-install
$(call staged-install,$1,+$(MAKE) -C $(BUILDDIR)/$1 install $(MAKE_COMMON) $2 DESTDIR=$(call MAKE_DESTDIR,$1))
endef

include $(SRCDIR)/tools/git-external.mk

include $(SRCDIR)/llvm.mk
include $(SRCDIR)/libuv.mk
include $(SRCDIR)/pcre.mk
Expand All @@ -280,9 +191,3 @@ include $(SRCDIR)/libssh2.mk
include $(SRCDIR)/curl.mk
include $(SRCDIR)/libgit2.mk
include $(SRCDIR)/virtualenv.mk

## phony targets ##

.PHONY: default compile install cleanall distcleanall \
get-* configure-* compile-* check-* install-* \
clean-* distclean-* reinstall-* update-llvm
Loading

0 comments on commit c11af2d

Please sign in to comment.