[project @ 2005-01-26 15:04:08 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.RawSystem \
49         -optdep--exclude-module=Compat.Directory \
50         -optdep--exclude-module=Distribution.Compat.ReadP \
51         -optdep--exclude-module=Distribution.Extension \
52         -optdep--exclude-module=Distribution.GetOpt \
53         -optdep--exclude-module=Distribution.InstalledPackageInfo \
54         -optdep--exclude-module=Distribution.License \
55         -optdep--exclude-module=Distribution.Package \
56         -optdep--exclude-module=Distribution.ParseUtils \
57         -optdep--exclude-module=Distribution.Setup \
58         -optdep--exclude-module=Distribution.Version \
59         -optdep--exclude-module=System.Directory.Internals
60
61 # -----------------------------------------------------------------------------=
62 # Create the Version.hs file
63
64 VERSION_HS = Version.hs
65 EXTRA_SRCS += $(VERSION_HS)
66
67 boot :: $(VERSION_HS)
68
69 Version.hs : Makefile $(TOP)/mk/version.mk
70         @$(RM) -f $(VERSION_HS)
71         @echo "Creating $(VERSION_HS) ... "
72         @echo "module Version where" >>$(VERSION_HS)
73         @echo "version    = \"$(ProjectVersion)\"" >> $(VERSION_HS)
74         @echo "targetOS   = \"$(TargetOS_CPP)\"" >> $(VERSION_HS)
75         @echo "targetARCH = \"$(TargetArch_CPP)\"" >> $(VERSION_HS)
76
77 # -----------------------------------------------------------------------------
78 # ghc-pkg script
79
80 ifeq "$(INSTALLING)" "1"
81 ifeq "$(BIN_DIST)"   "1"
82 GHCPKGBIN=$$\"\"libexecdir/$(HS_PROG)
83 PKGCONF=$$\"\"libdir/package.conf
84 else
85 GHCPKGBIN=$(libexecdir)/$(HS_PROG)
86 PKGCONF=$(libdir)/package.conf
87 endif # BIN_DIST
88 else
89 GHCPKGBIN=$(FPTOOLS_TOP_ABS)/ghc/utils/ghc-pkg/$(HS_PROG)
90 PKGCONF=$(FPTOOLS_TOP_ABS_PLATFORM)/ghc/driver/package.conf.inplace
91 endif
92
93 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
94 INSTALLED_SCRIPT_PROG  = ghc-pkg-$(ProjectVersion)
95 endif
96 INPLACE_SCRIPT_PROG    = ghc-pkg-inplace
97
98 SCRIPT_OBJS       = ghc-pkg.sh
99 INTERP            = $(SHELL)
100 SCRIPT_SUBST_VARS = GHCPKGBIN PKGCONFOPT
101 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
102 INSTALL_SCRIPTS  += $(SCRIPT_PROG)
103 endif
104 PKGCONFOPT        = --global-conf $(PKGCONF)
105
106 ifeq "$(INSTALLING)" "1"
107 SCRIPT_PROG     =  $(INSTALLED_SCRIPT_PROG)
108 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
109 LINK            =  ghc-pkg
110 endif
111 else
112 SCRIPT_PROG     =  $(INPLACE_SCRIPT_PROG)
113 endif
114
115 # -----------------------------------------------------------------------------
116 # don't recurse on 'make install'
117 #
118 ifeq "$(INSTALLING)" "1"
119 all :: $(HS_PROG)
120         $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
121 clean distclean maintainer-clean ::
122         $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
123 endif
124
125 # ghc-pkg is needed to boot in ghc/rts and library dirs
126 # Do a recursive 'make all' after generating dependencies, because this
127 # will work with 'make -j'.
128 ifneq "$(BootingFromHc)" "YES"
129 boot :: depend
130         $(MAKE) all
131 endif
132
133 include $(TOP)/mk/target.mk