Use SRC_HC_OPTS when making ghc-cabal and ghc-pkg
[ghc.git] / utils / ghc-pkg / ghc.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 # Bootstrapping ghc-pkg
15
16 utils/ghc-pkg_dist_PROG = ghc-pkg
17
18 ifeq "$(BootingFromHc)" "YES"
19
20 inplace/bin/ghc-pkg : utils/ghc-pkg/dist-install/build/tmp/$(utils/ghc-pkg_dist_PROG)$(exeext)
21 ifeq "$(Windows)" "YES"
22 cp $< $@
23 else
24 $(RM) $@
25 echo "#!/bin/sh" >>$@
26 echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@
27 echo '$(TOP)/$< --global-conf $$PKGCONF $${1+"$$@"}' >> $@
28 chmod +x $@
29 endif
30
31 else
32
33 $(GHC_PKG_INPLACE) : utils/ghc-pkg/dist/build/$(utils/ghc-pkg_dist_PROG)$(exeext) $(MKDIRHIER)
34 $(MKDIRHIER) $(dir $(INPLACE_PACKAGE_CONF))
35 echo "[]" > $(INPLACE_PACKAGE_CONF)
36 ifeq "$(Windows)" "YES"
37 cp $< $@
38 else
39 $(RM) $@
40 echo "#!/bin/sh" >>$@
41 echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@
42 echo '$(TOP)/$< --global-conf $$PKGCONF $${1+"$$@"}' >> $@
43 chmod +x $@
44 endif
45
46 endif
47
48 # depend on ghc-cabal, otherwise we build Cabal twice when building in parallel
49 utils/ghc-pkg/dist/build/$(utils/ghc-pkg_dist_PROG)$(exeext): utils/ghc-pkg/Main.hs utils/ghc-pkg/Version.hs $(GHC_CABAL_INPLACE) $(MKDIRHIER)
50 $(MKDIRHIER) bootstrapping
51 $(MKDIRHIER) utils/ghc-pkg/dist/build
52 $(GHC) $(SRC_HC_OPTS) --make utils/ghc-pkg/Main.hs -o $@ \
53 -Wall \
54 -DCABAL_VERSION=$(CABAL_VERSION) \
55 -odir bootstrapping \
56 -hidir bootstrapping \
57 -iutils/ghc-pkg \
58 -XCPP -XExistentialQuantification -XDeriveDataTypeable \
59 -ilibraries/Cabal \
60 -ilibraries/filepath \
61 -ilibraries/extensible-exceptions \
62 -ilibraries/hpc
63
64 utils/ghc-pkg/Version.hs: mk/config.mk
65 $(RM) -f $@
66 echo "module Version where" >> $@
67 echo "version, targetOS, targetARCH :: String" >> $@
68 echo "version = \"$(ProjectVersion)\"" >> $@
69 echo "targetOS = \"$(TargetOS_CPP)\"" >> $@
70 echo "targetARCH = \"$(TargetArch_CPP)\"" >> $@
71
72 $(eval $(call clean-target,utils/ghc-pkg,dist,\
73 utils/ghc-pkg/dist \
74 utils/ghc-pkg/Version.hs))
75
76 # -----------------------------------------------------------------------------
77 # Building ghc-pkg with stage 1
78
79 utils/ghc-pkg_dist-install_PROG = ghc-pkg
80 utils/ghc-pkg_dist-install_MODULES = Main Version
81 utils/ghc-pkg_dist-install_DEPS = Cabal
82 utils/ghc-pkg_dist-install_SHELL_WRAPPER = YES
83 utils/ghc-pkg_dist-install_INSTALL_SHELL_WRAPPER = YES
84 utils/ghc-pkg_dist-install_INSTALL_SHELL_WRAPPER_NAME = ghc-pkg-$(ProjectVersion)
85 utils/ghc-pkg_dist-install_INSTALL_INPLACE = NO
86
87 ifeq "$(BootingFromHc)" "YES"
88 utils/ghc-pkg_dist-install_OTHER_OBJS += $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_RTS_LIBS) $(libffi_STATIC_LIB)
89 endif
90
91 $(eval $(call build-prog,utils/ghc-pkg,dist-install,1))
92
93 ifeq "$(Windows)" "NO"
94 install: install_utils/ghc-pkg_link
95
96 .PNONY: install_utils/ghc-pkg_link
97 install_utils/ghc-pkg_link:
98 $(MKDIRHIER) $(DESTDIR)$(bindir)
99 $(RM) -f $(DESTDIR)$(bindir)/ghc-pkg
100 $(LN_S) ghc-pkg-$(ProjectVersion) $(DESTDIR)$(bindir)/ghc-pkg
101 endif
102