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