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