summaryrefslogtreecommitdiff
path: root/rules
diff options
context:
space:
mode:
Diffstat (limited to 'rules')
-rw-r--r--rules/build-prog.mk4
-rw-r--r--rules/distdir-way-opts.mk49
2 files changed, 30 insertions, 23 deletions
diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index c6780d1bde..399369ecfb 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -259,11 +259,11 @@ $1/$2/build/tmp/$$($1_$2_PROG).dll : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$(
else
ifeq "$$($1_$2_LINK_WITH_GCC)" "NO"
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
- $$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_GHC_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
+ $$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_GHC_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
else
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
- $$(call cmd,$1_$2_CC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_CC_OPTS) $$(LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
+ $$(call cmd,$1_$2_CC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_CC_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
endif
endif
diff --git a/rules/distdir-way-opts.mk b/rules/distdir-way-opts.mk
index 8c0377eff8..93bc60b6b1 100644
--- a/rules/distdir-way-opts.mk
+++ b/rules/distdir-way-opts.mk
@@ -131,20 +131,6 @@ endif
endif
endif
-ifeq "$3" "dyn"
-ifneq "$4" "0"
-ifeq "$$(TargetElf)" "YES"
-$1_$2_$3_GHC_LD_OPTS += \
- -fno-use-rpaths \
- $$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'$$$$ORIGIN/../$$d') -optl-Wl,-zorigin
-else ifeq "$$(TargetOS_CPP)" "darwin"
-$1_$2_$3_GHC_LD_OPTS += \
- -fno-use-rpaths \
- $$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'@loader_path/../$$d')
-endif
-endif
-endif
-
$1_$2_$3_ALL_CC_OPTS = \
$$(WAY_$3_CC_OPTS) \
$$($1_$2_DIST_GCC_CC_OPTS) \
@@ -154,13 +140,20 @@ $1_$2_$3_ALL_CC_OPTS = \
$$(EXTRA_CC_OPTS)
$1_$2_$3_GHC_CC_OPTS = \
- $$(addprefix -optc, \
- $$(WAY_$3_CC_OPTS) \
- $$($1_$2_DIST_CC_OPTS) \
- $$($1_$2_$3_CC_OPTS) \
- $$($$(basename $$<)_CC_OPTS) \
- $$($1_$2_EXTRA_CC_OPTS) \
- $$(EXTRA_CC_OPTS)) \
+ $$(addprefix -optc, $$($1_$2_$3_ALL_CC_OPTS)) \
+ $$($1_$2_$3_MOST_HC_OPTS)
+
+# Options for passing to plain ld
+$1_$2_$3_ALL_LD_OPTS = \
+ $$(WAY_$3_LD_OPTS) \
+ $$($1_$2_DIST_LD_OPTS) \
+ $$($1_$2_$3_LD_OPTS) \
+ $$($1_$2_EXTRA_LD_OPTS) \
+ $$(EXTRA_LD_OPTS)
+
+# Options for passing to GHC when we use it for linking
+$1_$2_$3_GHC_LD_OPTS = \
+ $$(addprefix -optl, $$($1_$2_$3_ALL_LD_OPTS)) \
$$($1_$2_$3_MOST_HC_OPTS)
$1_$2_$3_ALL_AS_OPTS = \
@@ -172,5 +165,19 @@ $1_$2_$3_ALL_AS_OPTS = \
$$($1_$2_$3_AS_OPTS) \
$$(EXTRA_AS_OPTS)
+ifeq "$3" "dyn"
+ifneq "$4" "0"
+ifeq "$$(TargetElf)" "YES"
+$1_$2_$3_GHC_LD_OPTS += \
+ -fno-use-rpaths \
+ $$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'$$$$ORIGIN/../$$d') -optl-Wl,-zorigin
+else ifeq "$$(TargetOS_CPP)" "darwin"
+$1_$2_$3_GHC_LD_OPTS += \
+ -fno-use-rpaths \
+ $$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'@loader_path/../$$d')
+endif
+endif
+endif
+
endef