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#      https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture
9#      https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying
10#
11# -----------------------------------------------------------------------------
12
13
14define manual-package-config
15# args:
16# $1 = dir
17# $2 = stage
18$(call trace, manual-package-config($1, $2))
19$(call profStart, manual-package-config($1, $2))
20
21$1/dist/package.conf.inplace : $1/package.conf.in $$$$(ghc-pkg_INPLACE) | $$$$(dir $$$$@)/.
22	$$(HS_CPP) -P \
23		-DTOP='"$$(TOP)"' \
24		$$($1_PACKAGE_CPP_OPTS) \
25		$$(addprefix -I,$$(GHC_INCLUDE_DIRS)) \
26		-I$$(BUILD_$2_INCLUDE_DIR) \
27		-x c $$< -o $$@.raw
28	grep -v '^#pragma GCC' $$@.raw | \
29	    sed -e 's/""//g' -e 's/:[ 	]*,/: /g' > $$@
30
31	"$$(ghc-pkg_INPLACE)" update --force $$@
32
33# This is actually a real file, but we need to recreate it on every
34# "make install", so we declare it as phony
35.PHONY: $1/dist/package.conf.install
36$1/dist/package.conf.install: | $$$$(dir $$$$@)/.
37	$$(HS_CPP) -P \
38		-DINSTALLING \
39		-DLIB_DIR='"$$(if $$(filter YES,$$(RelocatableBuild)),$$$$topdir,$$(ghclibdir))"' \
40		-DINCLUDE_DIR='"$$(if $$(filter YES,$$(RelocatableBuild)),$$$$topdir,$$(ghclibdir))/include"' \
41		$$($1_PACKAGE_CPP_OPTS) \
42		$$(addprefix -I,$$(GHC_INCLUDE_DIRS)) \
43		-I$$(BUILD_$2_INCLUDE_DIR) \
44		-x c $1/package.conf.in -o $$@.raw
45	grep -v '^#pragma GCC' $$@.raw | \
46	    sed -e 's/""//g' -e 's/:[ 	]*,/: /g' >$$@
47
48$(call profEnd, manual-package-config($1, $2))
49endef
50