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