Refactor gcc.c, pulling out the reusable code
[ghc-hetmet.git] / rules / manual-package-config.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 #      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13
14 define manual-package-config # args: $1 = dir
15
16 $1/package.conf.inplace : $1/package.conf.in $(GHC_PKG_INPLACE)
17         $$(CPP) $$(RAWCPP_FLAGS) -P \
18                 -DTOP='"$$(TOP)"' \
19                 $$($1_PACKAGE_CPP_OPTS) \
20                 -x c -I$$(GHC_INCLUDE_DIR) $$< | \
21         grep -v '^#pragma GCC' | \
22         sed -e 's/""//g' -e 's/:[       ]*,/: /g' >$$@
23
24         "$$(GHC_PKG_INPLACE)" update --force $$@
25
26 # This is actually a real file, but we need to recreate it on every
27 # "make install", so we declare it as phony
28 .PHONY: $1/package.conf.install
29 $1/package.conf.install:
30         $$(CPP) $$(RAWCPP_FLAGS) -P \
31                 -DINSTALLING \
32                 -DLIB_DIR='"$$(if $$(filter YES,$$(RelocatableBuild)),$$$$topdir,$$(ghclibdir))"' \
33                 -DINCLUDE_DIR='"$$(if $$(filter YES,$$(RelocatableBuild)),$$$$topdir,$$(ghclibdir))/include"' \
34                 $$($1_PACKAGE_CPP_OPTS) \
35                 -x c -I$$(GHC_INCLUDE_DIR) $1/package.conf.in | \
36         grep -v '^#pragma GCC' | \
37         sed -e 's/""//g' -e 's/:[       ]*,/: /g' >$$@
38
39 distclean : clean_$1_package.conf
40 .PHONY: clean_$1_package.conf
41 clean_$1_package.conf :
42         "$$(RM)" $$(RM_OPTS) $1/package.conf.install $1/package.conf.inplace
43
44 endef