[project @ 2004-11-23 14:24:53 by simonmar]
[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 ghc_ge_504 = $(shell if (test $(GhcCanonVersion) -ge 504); then echo YES; else echo NO; fi)
13 ghc_ge_603 = $(shell if (test $(GhcCanonVersion) -ge 603); then echo YES; else echo NO; fi)
14
15 SRC_HC_OPTS += -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches
16
17 SRC_HC_OPTS += -i$(GHC_LIB_COMPAT_DIR)
18 SRC_LD_OPTS += -L$(GHC_LIB_COMPAT_DIR) -lghccompat
19
20 ifeq "$(Windows)" "YES"
21 # not very nice, but required for -lghccompat on Windows
22 SRC_LD_OPTS += -lshell32
23 endif
24
25 ifeq "$(ghc_ge_504)" "NO"
26 SRC_HC_OPTS +=  -package lang -package util -package text
27 endif
28
29 ifeq "$(ghc_ge_603)" "YES"
30 SRC_HC_OPTS +=  -package Cabal
31 endif
32
33 # On Windows, ghc-pkg is a standalone program
34 # ($bindir/ghc-pkg.exe), whereas on Unix it needs a wrapper script
35 # to pass the appropriate flag to the real binary
36 # ($libexecdir/ghc-pkg.bin) so that it can find package.conf.
37 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
38 HS_PROG           = ghc-pkg.exe
39 INSTALL_PROGS    += $(HS_PROG)
40 else
41 HS_PROG           = ghc-pkg.bin
42 INSTALL_LIBEXECS += $(HS_PROG)
43 endif
44
45 # This is horrible.  We ought to be able to omit the entire directory
46 # from mkDependHS.
47 SRC_MKDEPENDHS_OPTS += \
48         -optdep--exclude-module=Compat.Directory \
49         -optdep--exclude-module=Distribution.Compat.ReadP \
50         -optdep--exclude-module=Distribution.Package \
51         -optdep--exclude-module=Distribution.InstalledPackageInfo \
52         -optdep--exclude-module=Distribution.Package \
53         -optdep--exclude-module=Distribution.License \
54         -optdep--exclude-module=Distribution.Version
55
56 # -----------------------------------------------------------------------------=
57 # Create the Version.hs file
58
59 VERSION_HS = Version.hs
60 EXTRA_SRCS += $(VERSION_HS)
61
62 boot :: $(VERSION_HS)
63
64 Version.hs : Makefile $(TOP)/mk/version.mk
65         @$(RM) -f $(VERSION_HS)
66         @echo "Creating $(VERSION_HS) ... "
67         @echo "module Version where" >>$(VERSION_HS)
68         @echo "version    = \"$(ProjectVersion)\"" >> $(VERSION_HS)
69         @echo "targetOS   = \"$(TargetOS_CPP)\"" >> $(VERSION_HS)
70         @echo "targetARCH = \"$(TargetArch_CPP)\"" >> $(VERSION_HS)
71
72 # -----------------------------------------------------------------------------
73 # ghc-pkg script
74
75 ifeq "$(INSTALLING)" "1"
76 ifeq "$(BIN_DIST)"   "1"
77 GHCPKGBIN=$$\"\"libexecdir/$(HS_PROG)
78 PKGCONF=$$\"\"libdir/package.conf
79 else
80 GHCPKGBIN=$(libexecdir)/$(HS_PROG)
81 PKGCONF=$(libdir)/package.conf
82 endif # BIN_DIST
83 else
84 GHCPKGBIN=$(FPTOOLS_TOP_ABS)/ghc/utils/ghc-pkg/$(HS_PROG)
85 PKGCONF=$(FPTOOLS_TOP_ABS_PLATFORM)/ghc/driver/package.conf.inplace
86 endif
87
88 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
89 INSTALLED_SCRIPT_PROG  = ghc-pkg-$(ProjectVersion)
90 endif
91 INPLACE_SCRIPT_PROG    = ghc-pkg-inplace
92
93 SCRIPT_OBJS       = ghc-pkg.sh
94 INTERP            = $(SHELL)
95 SCRIPT_SUBST_VARS = GHCPKGBIN PKGCONFOPT
96 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
97 INSTALL_SCRIPTS  += $(SCRIPT_PROG)
98 endif
99 PKGCONFOPT        = --global-conf $(PKGCONF)
100
101 ifeq "$(INSTALLING)" "1"
102 SCRIPT_PROG     =  $(INSTALLED_SCRIPT_PROG)
103 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
104 LINK            =  ghc-pkg
105 endif
106 else
107 SCRIPT_PROG     =  $(INPLACE_SCRIPT_PROG)
108 endif
109
110 # -----------------------------------------------------------------------------
111 # don't recurse on 'make install'
112 #
113 ifeq "$(INSTALLING)" "1"
114 all :: $(HS_PROG)
115         $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
116 clean distclean maintainer-clean ::
117         $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
118 endif
119
120 # ghc-pkg is needed to boot in ghc/rts and library dirs
121 # Do a recursive 'make all' after generating dependencies, because this
122 # will work with 'make -j'.
123 ifneq "$(BootingFromHc)" "YES"
124 boot :: depend
125         $(MAKE) all
126 endif
127
128 include $(TOP)/mk/target.mk