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 package-config # args: $1 = dir, $2 = distdir, $3 = GHC stage
15$(call trace, package-config($1,$2,$3))
16$(call profStart, package-config($1,$2,$3))
17
18$1_$2_HC = $$(GHC_STAGE$3)
19$1_$2_CC = $$(CC_STAGE$3)
20$1_$2_AS = $$(AS_STAGE$3)
21$1_$2_AR = $$(AR_STAGE$3)
22$1_$2_AR_OPTS = $$(AR_OPTS_STAGE$3)
23$1_$2_EXTRA_AR_ARGS = $$(EXTRA_AR_ARGS_STAGE$3)
24$1_$2_ArSupportsAtFile = $$(ArSupportsAtFile_STAGE$3)
25
26# configuration stuff that depends on which GHC we're building with
27ifeq "$3" "0"
28$1_$2_HC_CONFIG = $$(GHC_STAGE0)
29$1_$2_HC_CONFIG_DEP =
30$1_$2_GHC_PKG = $$(GHC_PKG)
31$1_$2_GHC_PKG_DEP =
32$1_$2_HC_MK_DEPEND = $$($1_$2_HC)
33# We can't make rules depend on the bootstrapping compiler, as then
34# on cygwin we get a dep on c:/ghc/..., and make gets confused by the :
35$1_$2_HC_MK_DEPEND_DEP =
36$1_$2_HC_DEP =
37$1_$2_HC_PKGCONF = -package-db $$(BOOTSTRAPPING_CONF)
38$1_$2_GHC_PKG_OPTS = --package-db=$$(BOOTSTRAPPING_CONF)
39$1_$2_CONFIGURE_OPTS += --package-db=$$(TOP)/$$(BOOTSTRAPPING_CONF)
40$1_$2_MORE_HC_OPTS += -no-user-package-db
41$1_$2_MORE_HC_OPTS += -rtsopts
42else
43$1_$2_HC_PKGCONF =
44$1_$2_HC_CONFIG = $$(TOP)/$$(GHC_STAGE1)
45$1_$2_HC_CONFIG_DEP = $$(GHC_STAGE1)
46$1_$2_GHC_PKG = $$(TOP)/$$(ghc-pkg_INPLACE)
47$1_$2_GHC_PKG_DEP = $$$$(ghc-pkg_INPLACE)
48$1_$2_GHC_PKG_OPTS =
49# If stage is not 0 then we always use stage1 for making .depend, as later
50# stages aren't available early enough
51$1_$2_HC_MK_DEPEND = $$(GHC_STAGE1)
52$1_$2_HC_MK_DEPEND_DEP = $$($1_$2_HC_MK_DEPEND)
53$1_$2_HC_DEP = $$($1_$2_HC)
54$1_$2_MORE_HC_OPTS += -no-user-package-db
55$1_$2_MORE_HC_OPTS += -rtsopts
56endif
57
58# Used by pretty_commands.mk
59label_$1_$2_CC=CC
60label_$1_$2_AS=AS
61label_$1_$2_AR=AR
62label_$1_$2_HC=HC [stage $3]
63label_$1_$2_GHC_PKG=GHC PKG
64
65# Useful later
66$1_$2_SLASH_MODS = $$(subst .,/,$$($1_$2_MODULES))
67
68$(call profEnd, package-config($1,$2,$3))
69endef
70