Build fix
[ghc.git] / rules / manual-package-config.mk
index 5a24141..848fe1b 100644 (file)
 
 
 define manual-package-config # args: $1 = dir
+$(call trace, manual-package-config($1))
+$(call profStart, manual-package-config($1))
 
 $1/package.conf.inplace : $1/package.conf.in $(GHC_PKG_INPLACE)
        $$(CPP) $$(RAWCPP_FLAGS) -P \
                -DTOP='"$$(TOP)"' \
                $$($1_PACKAGE_CPP_OPTS) \
-               -x c -I$$(GHC_INCLUDE_DIR) $$< | \
-       grep -v '^#pragma GCC' | \
-       sed -e 's/""//g' -e 's/:[       ]*,/: /g' >$$@
+               -x c $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) $$< -o $$@.raw
+       grep -v '^#pragma GCC' $$@.raw | \
+           sed -e 's/""//g' -e 's/:[   ]*,/: /g' > $$@
 
        "$$(GHC_PKG_INPLACE)" update --force $$@
 
@@ -29,16 +31,17 @@ $1/package.conf.inplace : $1/package.conf.in $(GHC_PKG_INPLACE)
 $1/package.conf.install:
        $$(CPP) $$(RAWCPP_FLAGS) -P \
                -DINSTALLING \
-               -DLIB_DIR='"$$(ghclibdir)"' \
-               -DINCLUDE_DIR='"$$(ghclibdir)/include"' \
+               -DLIB_DIR='"$$(if $$(filter YES,$$(RelocatableBuild)),$$$$topdir,$$(ghclibdir))"' \
+               -DINCLUDE_DIR='"$$(if $$(filter YES,$$(RelocatableBuild)),$$$$topdir,$$(ghclibdir))/include"' \
                $$($1_PACKAGE_CPP_OPTS) \
-               -x c -I$$(GHC_INCLUDE_DIR) $1/package.conf.in | \
-       grep -v '^#pragma GCC' | \
-       sed -e 's/""//g' -e 's/:[       ]*,/: /g' >$$@
+               -x c $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) $1/package.conf.in -o $$@.raw
+       grep -v '^#pragma GCC' $$@.raw | \
+           sed -e 's/""//g' -e 's/:[   ]*,/: /g' >$$@
 
 distclean : clean_$1_package.conf
 .PHONY: clean_$1_package.conf
 clean_$1_package.conf :
-       "$$(RM)" $$(RM_OPTS) $1/package.conf.install $1/package.conf.inplace
+       $$(call removeFiles,$1/package.conf.install $1/package.conf.inplace)
 
+$(call profEnd, manual-package-config($1))
 endef