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