2e09ab0470894a88c2f795c9742e754df8a3f91c
[ghc-hetmet.git] / ghc / utils / ghc-pkg / Makefile
1 # -----------------------------------------------------------------------------
2
3 TOP=../..
4 include $(TOP)/mk/boilerplate.mk
5
6 # hack for ghci-inplace script, see below
7 INSTALLING=1
8
9 # -----------------------------------------------------------------------------
10 # ghc-pkg.bin
11
12 SRC_HC_OPTS += -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches
13
14 # This causes libghccompat.a to be used:
15 include $(GHC_LIB_COMPAT_DIR)/compat.mk
16
17 # This is required because libghccompat.a must be built with
18 # $(GhcHcOpts) because it is linked to the compiler, and hence
19 # we must also build with $(GhcHcOpts) here:
20 SRC_HC_OPTS += $(GhcHcOpts)
21
22 ifeq "$(ghc_ge_504)" "NO"
23 SRC_HC_OPTS +=  -package lang -package util -package text
24 endif
25
26 ifeq "$(ghc_ge_603)" "YES"
27 SRC_HC_OPTS +=  -package Cabal
28 endif
29
30 # On Windows, ghc-pkg is a standalone program
31 # ($bindir/ghc-pkg.exe), whereas on Unix it needs a wrapper script
32 # to pass the appropriate flag to the real binary
33 # ($libexecdir/ghc-pkg.bin) so that it can find package.conf.
34 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
35 HS_PROG           = ghc-pkg.exe
36 INSTALL_PROGS    += $(HS_PROG)
37 else
38 HS_PROG           = ghc-pkg.bin
39 INSTALL_LIBEXECS += $(HS_PROG)
40 endif
41
42 # -----------------------------------------------------------------------------=
43 # Create the Version.hs file
44
45 VERSION_HS = Version.hs
46 EXTRA_SRCS += $(VERSION_HS)
47
48 boot :: $(VERSION_HS)
49
50 Version.hs : Makefile $(TOP)/mk/version.mk
51         @$(RM) -f $(VERSION_HS)
52         @echo "Creating $(VERSION_HS) ... "
53         @echo "module Version where" >>$(VERSION_HS)
54         @echo "version, targetOS, targetARCH :: String" >>$(VERSION_HS)
55         @echo "version    = \"$(ProjectVersion)\"" >> $(VERSION_HS)
56         @echo "targetOS   = \"$(TargetOS_CPP)\"" >> $(VERSION_HS)
57         @echo "targetARCH = \"$(TargetArch_CPP)\"" >> $(VERSION_HS)
58
59 DIST_CLEAN_FILES += $(VERSION_HS)
60
61 # -----------------------------------------------------------------------------
62 # ghc-pkg script
63
64 ifeq "$(INSTALLING)" "1"
65 ifeq "$(BIN_DIST)"   "1"
66 GHCPKGBIN=$$\"\"libexecdir/$(HS_PROG)
67 PKGCONF=$$\"\"libdir/package.conf
68 else
69 GHCPKGBIN=$(libexecdir)/$(HS_PROG)
70 PKGCONF=$(libdir)/package.conf
71 endif # BIN_DIST
72 else
73 GHCPKGBIN=$(FPTOOLS_TOP_ABS)/ghc/utils/ghc-pkg/$(HS_PROG)
74 PKGCONF=$(FPTOOLS_TOP_ABS_PLATFORM)/ghc/driver/package.conf.inplace
75 endif
76
77 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
78 INSTALLED_SCRIPT_PROG  = ghc-pkg-$(ProjectVersion)
79 endif
80 INPLACE_SCRIPT_PROG    = ghc-pkg-inplace
81
82 SCRIPT_OBJS       = ghc-pkg.sh
83 INTERP            = $(SHELL)
84 SCRIPT_SUBST_VARS = GHCPKGBIN PKGCONFOPT
85 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
86 INSTALL_SCRIPTS  += $(SCRIPT_PROG)
87 endif
88 PKGCONFOPT        = --global-conf $(PKGCONF)
89
90 ifeq "$(INSTALLING)" "1"
91 SCRIPT_PROG     =  $(INSTALLED_SCRIPT_PROG)
92 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
93 LINK            =  ghc-pkg
94 endif
95 else
96 SCRIPT_PROG     =  $(INPLACE_SCRIPT_PROG)
97 endif
98
99 # -----------------------------------------------------------------------------
100 # don't recurse on 'make install'
101 #
102 ifeq "$(INSTALLING)" "1"
103 all :: $(HS_PROG)
104         $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
105 clean distclean maintainer-clean ::
106         $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
107 endif
108
109 # ghc-pkg is needed to boot in ghc/rts and library dirs
110 # Do a recursive 'make all' after generating dependencies, because this
111 # will work with 'make -j'.
112 ifneq "$(BootingFromHc)" "YES"
113 boot :: depend
114         $(MAKE) all
115 endif
116
117 include $(TOP)/mk/target.mk