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