[project @ 2005-06-16 09:45:28 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 # This causes libghccompat.a to be used:
15 include $(GHC_LIB_COMPAT_DIR)/compat.mk
16
17 # This is required because libghccompat.a must be built with
18 # $(GhcHcOpts) because it is linked to the compiler, and hence
19 # we must also build with $(GhcHcOpts) here:
20 SRC_HC_OPTS += $(GhcHcOpts)
21
22 ifeq "$(Windows)" "YES"
23 # not very nice, but required for -lghccompat on Windows
24 SRC_LD_OPTS += -lshell32
25 HC_BOOT_LIBS += -lshell32
26 endif
27
28 ifeq "$(ghc_ge_504)" "NO"
29 SRC_HC_OPTS +=  -package lang -package util -package text
30 endif
31
32 ifeq "$(ghc_ge_603)" "YES"
33 SRC_HC_OPTS +=  -package Cabal
34 endif
35
36 # On Windows, ghc-pkg is a standalone program
37 # ($bindir/ghc-pkg.exe), whereas on Unix it needs a wrapper script
38 # to pass the appropriate flag to the real binary
39 # ($libexecdir/ghc-pkg.bin) so that it can find package.conf.
40 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
41 HS_PROG           = ghc-pkg.exe
42 INSTALL_PROGS    += $(HS_PROG)
43 else
44 HS_PROG           = ghc-pkg.bin
45 INSTALL_LIBEXECS += $(HS_PROG)
46 endif
47
48 # -----------------------------------------------------------------------------=
49 # Create the Version.hs file
50
51 VERSION_HS = Version.hs
52 EXTRA_SRCS += $(VERSION_HS)
53
54 boot :: $(VERSION_HS)
55
56 Version.hs : Makefile $(TOP)/mk/version.mk
57         @$(RM) -f $(VERSION_HS)
58         @echo "Creating $(VERSION_HS) ... "
59         @echo "module Version where" >>$(VERSION_HS)
60         @echo "version, targetOS, targetARCH :: String" >>$(VERSION_HS)
61         @echo "version    = \"$(ProjectVersion)\"" >> $(VERSION_HS)
62         @echo "targetOS   = \"$(TargetOS_CPP)\"" >> $(VERSION_HS)
63         @echo "targetARCH = \"$(TargetArch_CPP)\"" >> $(VERSION_HS)
64
65 DIST_CLEAN_FILES += $(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