5aa091f18fa2633d483a2b977b637d2cf568a94d
[ghc-hetmet.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)" $(RM_OPTS) $@
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)" $(INPLACE_PACKAGE_CONF)
35         "$(RM)" $(RM_OPTS) $(INPLACE_PACKAGE_CONF)/*
36 ifeq "$(Windows)" "YES"
37         cp $< $@
38 else
39         "$(RM)" $(RM_OPTS) $@
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 # The binary package is not warning-clean, so we need a few -fno-warns here.
50 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)
51         "$(MKDIRHIER)" bootstrapping
52         "$(MKDIRHIER)" utils/ghc-pkg/dist/build
53         "$(GHC)" $(SRC_HC_OPTS) --make utils/ghc-pkg/Main.hs -o $@ \
54                -Wall -fno-warn-unused-imports \
55                -DCABAL_VERSION=$(CABAL_VERSION) \
56                -odir  bootstrapping \
57                -hidir bootstrapping \
58                -iutils/ghc-pkg \
59                -XCPP -XExistentialQuantification -XDeriveDataTypeable \
60                -ilibraries/Cabal \
61                -ilibraries/filepath \
62                -ilibraries/extensible-exceptions \
63                -ilibraries/hpc \
64                -ilibraries/binary/src \
65                -ilibraries/bin-package-db
66
67
68 utils/ghc-pkg/Version.hs: mk/project.mk
69         "$(RM)" $(RM_OPTS) $@
70         echo "module Version where"                    >> $@
71         echo "version, targetOS, targetARCH :: String" >> $@
72         echo "version    = \"$(ProjectVersion)\""      >> $@
73         echo "targetOS   = \"$(TargetOS_CPP)\""        >> $@
74         echo "targetARCH = \"$(TargetArch_CPP)\""      >> $@
75
76 $(eval $(call clean-target,utils/ghc-pkg,dist,\
77    utils/ghc-pkg/dist \
78    utils/ghc-pkg/Version.hs))
79
80 # -----------------------------------------------------------------------------
81 # Building ghc-pkg with stage 1
82
83 utils/ghc-pkg_dist-install_PROG = ghc-pkg
84 utils/ghc-pkg_dist-install_MODULES = Main Version
85 utils/ghc-pkg_dist-install_DEPS = Cabal terminfo bin-package-db
86 utils/ghc-pkg_dist-install_SHELL_WRAPPER = YES
87 utils/ghc-pkg_dist-install_INSTALL_SHELL_WRAPPER = YES
88 utils/ghc-pkg_dist-install_INSTALL_SHELL_WRAPPER_NAME = ghc-pkg-$(ProjectVersion)
89 utils/ghc-pkg_dist-install_INSTALL_INPLACE = NO
90
91 ifeq "$(BootingFromHc)" "YES"
92 utils/ghc-pkg_dist-install_OTHER_OBJS += $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_RTS_LIBS) $(libffi_STATIC_LIB)
93 endif
94
95 $(eval $(call build-prog,utils/ghc-pkg,dist-install,1))
96
97 ifeq "$(Windows)" "NO"
98 install: install_utils/ghc-pkg_link
99
100 .PNONY: install_utils/ghc-pkg_link
101 install_utils/ghc-pkg_link: 
102         $(INSTALL_DIR) $(DESTDIR)$(bindir)
103         "$(RM)" $(RM_OPTS) $(DESTDIR)$(bindir)/ghc-pkg
104         $(LN_S) ghc-pkg-$(ProjectVersion) $(DESTDIR)$(bindir)/ghc-pkg
105 endif
106