Enable building Cabal with parsec
[ghc.git] / rules / build-package-way.mk
index a10e538..3b4d1c9 100644 (file)
@@ -27,7 +27,7 @@ $1_$2_$3_LIB_FILE = libHS$$($1_$2_COMPONENT_ID)$$($3_libsuf)
 $1_$2_$3_LIB = $1/$2/build/$$($1_$2_$3_LIB_FILE)
 $$($1_$2_COMPONENT_ID)_$2_$3_LIB = $$($1_$2_$3_LIB)
 
-ifeq "$$(HostOS_CPP)" "mingw32"
+ifeq "$$(TargetOS_CPP)" "mingw32"
 ifneq "$$($1_$2_dll0_HS_OBJS)" ""
 $1_$2_$3_LIB0_ROOT = HS$$($1_$2_COMPONENT_ID)-0$$($3_libsuf)
 $1_$2_$3_LIB0_NAME = lib$$($1_$2_$3_LIB0_ROOT)
@@ -75,7 +75,7 @@ $1/$2/dll-split.stamp: $$($1_$2_depfile_haskell) $$$$(dll-split_INPLACE)
 
 # Link a dynamic library
 # On windows we have to supply the extra libs this one links to when building it.
-ifeq "$$(HostOS_CPP)" "mingw32"
+ifeq "$$(TargetOS_CPP)" "mingw32"
 $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
 ifneq "$$($1_$2_$3_LIB0)" ""
        $$(call build-dll,$1,$2,$3,-L$1/$2/build -l$$($1_$2_$3_LIB0_ROOT),$$(filter-out $$($1_$2_dll0_HS_OBJS),$$($1_$2_$3_HS_OBJS)) $$($1_$2_$3_NON_HS_OBJS),$$@)
@@ -89,14 +89,14 @@ $$($1_$2_$3_LIB0) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS
        $$(call build-dll,$1,$2,$3,,$$($1_$2_dll0_HS_OBJS) $$($1_$2_$3_NON_HS_OBJS),$$($1_$2_$3_LIB0))
 endif
 
-else # ifneq "$$(HostOS_CPP)" "mingw32"
+else # ifneq "$$(TargetOS_CPP)" "mingw32"
 $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
        $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) $$($1_$2_$3_GHC_LD_OPTS) $$($1_$2_$3_ALL_OBJS) \
          -shared -dynamic -dynload deploy \
         $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) $$(addprefix -L,$$($1_$2_EXTRA_LIBDIRS)) \
          -no-auto-link-packages \
          -o $$@
-endif # "$$(HostOS_CPP)" "mingw32"
+endif # "$$(TargetOS_CPP)" "mingw32"
 
 else # ifneq "$3" "dyn"
 
@@ -116,7 +116,7 @@ else
 endif
        $$(call removeFiles,$$@.contents)
 
-ifeq "$$(HostOS_CPP)" "mingw32"
+ifeq "$$(TargetOS_CPP)" "mingw32"
 ifneq "$$($1_$2_$3_LIB0)" ""
 $$($1_$2_$3_LIB) : $$($1_$2_$3_LIB0)
 $$($1_$2_$3_LIB0) :
@@ -136,10 +136,19 @@ BINDIST_LIBS += $$($1_$2_$3_LIB)
 BINDIST_LIBS += $$($1_$2_$3_LIB0)
 endif
 
-# Build the GHCi library
-ifeq "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
-$1_$2_GHCI_LIB = $$($1_$2_dyn_LIB)
+ifeq "$$($1_$2_SplitSections)" "YES"
+ifeq "$(LdIsGNULd)" "YES"
+ifeq "$$(HostOS_CPP)" "mingw32"
+$1_$2_LD_SCRIPT_CMD =
+$1_$2_LD_SCRIPT = driver/utils/merge_sections_pe.ld
 else
+$1_$2_LD_SCRIPT_CMD = -T
+$1_$2_LD_SCRIPT = driver/utils/merge_sections.ld
+endif
+endif
+endif
+
+# Build the GHCi library
 ifeq "$3" "v"
 $1_$2_GHCI_LIB = $1/$2/build/HS$$($1_$2_COMPONENT_ID).$$($3_osuf)
 ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES"
@@ -148,8 +157,8 @@ ifneq "$4" "0"
 BINDIST_LIBS += $$($1_$2_GHCI_LIB)
 endif
 endif
-$$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
-       $$(call cmd,LD) $$(CONF_LD_LINKER_OPTS_STAGE$4) -r -o $$@ $$(EXTRA_LD_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
+$$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) $$($1_$2_LD_SCRIPT)
+       $$(call cmd,LD) $$(CONF_LD_LINKER_OPTS_STAGE$4) -r $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
 
 ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES"
 # Don't bother making ghci libs for bootstrapping packages
@@ -158,7 +167,6 @@ $(call all-target,$1_$2,$$($1_$2_GHCI_LIB))
 endif
 endif # "$$($1_$2_BUILD_GHCI_LIB)" "YES"
 endif # "$3" "v"
-endif # "$$(DYNAMIC_GHC_PROGRAMS)" "YES"
 
 $(call profEnd, build-package-way($1,$2,$3))
 endef # build-package-way