summaryrefslogtreecommitdiff
path: root/rules
diff options
context:
space:
mode:
Diffstat (limited to 'rules')
-rw-r--r--rules/build-package.mk7
-rw-r--r--rules/build-prog.mk40
-rw-r--r--rules/shell-wrapper.mk61
3 files changed, 65 insertions, 43 deletions
diff --git a/rules/build-package.mk b/rules/build-package.mk
index c97f8c4b2c..d21f449d93 100644
--- a/rules/build-package.mk
+++ b/rules/build-package.mk
@@ -115,6 +115,13 @@ $$(foreach way,$$($1_$2_WAYS),$$(eval \
$$(call build-package-way,$1,$2,$$(way),$3) \
))
+# Programs will need to depend on either the vanilla lib (if -static
+# is the default) or the dyn lib (if -dynamic is the default). We
+# conservatively make them depend on both, to keep things simple.
+# If dyn libs are not being built then $$($1_$2_dyn_LIB) will just
+# expand to the empty string, and be ignored.
+$1_$2_PROGRAM_DEP_LIB = $$($1_$2_v_LIB) $$($1_$2_dyn_LIB)
+
# C and S files are possibly built the "dyn" way.
ifeq "$$(BuildSharedLibs)" "YES"
$(call c-objs,$1,$2,dyn)
diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index 462dcf7fcb..6e6d1c11f1 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -54,6 +54,26 @@ ifeq "$$($1_USES_CABAL)" "YES"
$1_$2_USES_CABAL = YES
endif
+ifeq "$$(Windows)" "YES"
+$1_$2_WANT_INPLACE_WRAPPER = NO
+else ifneq "$$($1_$2_INSTALL_INPLACE)" "YES"
+$1_$2_WANT_INPLACE_WRAPPER = NO
+else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
+$1_$2_WANT_INPLACE_WRAPPER = YES
+else
+$1_$2_WANT_INPLACE_WRAPPER = NO
+endif
+
+ifeq "$$(Windows)" "YES"
+$1_$2_WANT_INSTALLED_WRAPPER = NO
+else ifneq "$$($1_$2_INSTALL)" "YES"
+$1_$2_WANT_INSTALLED_WRAPPER = NO
+else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
+$1_$2_WANT_INSTALLED_WRAPPER = YES
+else
+$1_$2_WANT_INSTALLED_WRAPPER = NO
+endif
+
$(call package-config,$1,$2,$3)
$1_$2_depfile_base = $1/$2/build/.depend
@@ -66,7 +86,7 @@ $1_$2_INPLACE =
endif
else
# Where do we install the inplace version?
-ifeq "$$($1_$2_SHELL_WRAPPER) $$(Windows)" "YES NO"
+ifeq "$$($1_$2_WANT_INPLACE_WRAPPER)" "YES"
$1_$2_INPLACE = $$(INPLACE_LIB)/bin/$$($1_$2_PROG)
else
ifeq "$$($1_$2_TOPDIR)" "YES"
@@ -93,7 +113,7 @@ $(call all-target,$1_$2,$1/$2/build/tmp/$$($1_$2_PROG))
# INPLACE_BIN might be empty if we're distcleaning
ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
-ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
+ifeq "$$($1_$2_INSTALL_INPLACE)" "YES"
$$($1_$2_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG) | $$$$(dir $$$$@)/.
"$$(CP)" -p $$< $$@
endif
@@ -142,17 +162,25 @@ ifeq "$$($1_$2_v_HS_OBJS)" ""
$1_$2_GHC_LD_OPTS = -no-auto-link-packages -no-hs-main
endif
+ifneq "$3" "0"
+ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+$1_$2_GHC_LD_OPTS = \
+ -fno-use-rpaths \
+ $$(addprefix -optl-Wl$$(comma)-rpath -optl-Wl$$(comma),$$($1_$2_RPATHS))
+endif
+endif
+
ifneq "$$(BINDIST)" "YES"
# The quadrupled $'s here are because the _v_LIB variables aren't
# necessarily set when this part of the makefile is read
$1/$2/build/tmp/$$($1_$2_PROG) : \
$$(foreach dep,$$($1_$2_DEP_NAMES),\
$$(if $$(filter ghc,$$(dep)),\
- $(if $(filter 0,$3),$$(compiler_stage1_v_LIB),\
- $(if $(filter 1,$3),$$(compiler_stage2_v_LIB),\
- $(if $(filter 2,$3),$$(compiler_stage2_v_LIB),\
+ $(if $(filter 0,$3),$$(compiler_stage1_PROGRAM_DEP_LIB),\
+ $(if $(filter 1,$3),$$(compiler_stage2_PROGRAM_DEP_LIB),\
+ $(if $(filter 2,$3),$$(compiler_stage2_PROGRAM_DEP_LIB),\
$$(error Bad build stage)))),\
- $$$$(libraries/$$(dep)_dist-$(if $(filter 0,$3),boot,install)_v_LIB)))
+ $$$$(libraries/$$(dep)_dist-$(if $(filter 0,$3),boot,install)_PROGRAM_DEP_LIB)))
ifeq "$$($1_$2_LINK_WITH_GCC)" "NO"
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
diff --git a/rules/shell-wrapper.mk b/rules/shell-wrapper.mk
index 34b803e063..8085ad150a 100644
--- a/rules/shell-wrapper.mk
+++ b/rules/shell-wrapper.mk
@@ -16,56 +16,43 @@ $(call profStart, shell-wrapper($1,$2))
# $1 = dir
# $2 = distdir
-ifeq "$$(Windows)" "YES"
-$1_$2_WANT_INPLACE_WRAPPER = NO
-else ifeq "$$($1_$2_INSTALL_INPLACE)" "NO"
-$1_$2_WANT_INPLACE_WRAPPER = NO
-else ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
-# We need to set LD_LIBRARY_PATH for all programs, so always need
-# a shell wrapper
-$1_$2_WANT_INPLACE_WRAPPER = YES
-else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
-$1_$2_WANT_INPLACE_WRAPPER = YES
-else
-$1_$2_WANT_INPLACE_WRAPPER = NO
-endif
-
-ifeq "$$(Windows)" "YES"
-$1_$2_WANT_INSTALLED_WRAPPER = NO
-else ifeq "$$($1_$2_INSTALL)" "NO"
-$1_$2_WANT_INSTALLED_WRAPPER = NO
-else ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
-$1_$2_WANT_INSTALLED_WRAPPER = YES
-else
-$1_$2_WANT_INSTALLED_WRAPPER = NO
+ifeq "$$($1_$2_SHELL_WRAPPER_NAME)" ""
+$1_$2_SHELL_WRAPPER_NAME = $1/$$($1_$2_PROG).wrapper
endif
-
ifeq "$$($1_$2_WANT_INPLACE_WRAPPER)" "YES"
-ifeq "$$($1_$2_SHELL_WRAPPER_NAME)" ""
-$1_$2_SHELL_WRAPPER_NAME = $1/$$($1_$2_PROG).wrapper
+ifeq "$$($1_$2_TOPDIR)" "YES"
+INPLACE_WRAPPER = $$(INPLACE_LIB)/$$($1_$2_PROG)
+else
+INPLACE_WRAPPER = $$(INPLACE_BIN)/$$($1_$2_PROG)
endif
-all_$1_$2 : $$(INPLACE_BIN)/$$($1_$2_PROG)
+all_$1_$2 : $$(INPLACE_WRAPPER)
$$(INPLACE_BIN)/$$($1_$2_PROG): WRAPPER=$$@
-$$(INPLACE_BIN)/$$($1_$2_PROG): $$($1_$2_INPLACE) $$($1_$2_SHELL_WRAPPER_NAME)
- $$(call removeFiles, $$@)
- echo '#!$$(SHELL)' >> $$@
- echo 'executablename="$$(TOP)/$$<"' >> $$@
- echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"' >> $$@
- echo 'bindir="$$(TOP)/$$(INPLACE_BIN)"' >> $$@
- echo 'topdir="$$(TOP)/$$(INPLACE_TOPDIR)"' >> $$@
- echo 'pgmgcc="$$(WhatGccIsCalled)"' >> $$@
+ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
+$$(INPLACE_WRAPPER): $$($1_$2_SHELL_WRAPPER_NAME)
+endif
+$$(INPLACE_WRAPPER): $$($1_$2_INPLACE)
+ $$(call removeFiles, $$@)
+ echo '#!$$(SHELL)' >> $$@
+ echo 'executablename="$$(TOP)/$$<"' >> $$@
+ echo 'datadir="$$(TOP)/$$(INPLACE_LIB)"' >> $$@
+ echo 'bindir="$$(TOP)/$$(INPLACE_BIN)"' >> $$@
+ echo 'topdir="$$(TOP)/$$(INPLACE_TOPDIR)"' >> $$@
+ echo 'pgmgcc="$$(WhatGccIsCalled)"' >> $$@
$$($1_$2_SHELL_WRAPPER_EXTRA)
$$($1_$2_INPLACE_SHELL_WRAPPER_EXTRA)
+ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+ echo 'export LD_LIBRARY_PATH="$$($1_$2_DEP_LIB_DIRS_SEARCHPATH)"' >> $$@
+endif
ifeq "$$($1_$2_SHELL_WRAPPER)" "YES"
- cat $$($1_$2_SHELL_WRAPPER_NAME) >> $$@
+ cat $$($1_$2_SHELL_WRAPPER_NAME) >> $$@
else
- echo 'exec "$executablename" $$$${1+"$$$$@"}' >> $$@
+ echo 'exec "$$$$executablename" $$$${1+"$$$$@"}' >> $$@
endif
- $$(EXECUTABLE_FILE) $$@
+ $$(EXECUTABLE_FILE) $$@
endif