f8ae77e8919fc3d1000bb23942c32ee79f1c39fb
[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    = \"$(ProjectVersion)\"" >> $(VERSION_HS)
80         @echo "targetOS   = \"$(TargetOS_CPP)\"" >> $(VERSION_HS)
81         @echo "targetARCH = \"$(TargetArch_CPP)\"" >> $(VERSION_HS)
82
83 # -----------------------------------------------------------------------------
84 # ghc-pkg script
85
86 ifeq "$(INSTALLING)" "1"
87 ifeq "$(BIN_DIST)"   "1"
88 GHCPKGBIN=$$\"\"libexecdir/$(HS_PROG)
89 PKGCONF=$$\"\"libdir/package.conf
90 else
91 GHCPKGBIN=$(libexecdir)/$(HS_PROG)
92 PKGCONF=$(libdir)/package.conf
93 endif # BIN_DIST
94 else
95 GHCPKGBIN=$(FPTOOLS_TOP_ABS)/ghc/utils/ghc-pkg/$(HS_PROG)
96 PKGCONF=$(FPTOOLS_TOP_ABS_PLATFORM)/ghc/driver/package.conf.inplace
97 endif
98
99 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
100 INSTALLED_SCRIPT_PROG  = ghc-pkg-$(ProjectVersion)
101 endif
102 INPLACE_SCRIPT_PROG    = ghc-pkg-inplace
103
104 SCRIPT_OBJS       = ghc-pkg.sh
105 INTERP            = $(SHELL)
106 SCRIPT_SUBST_VARS = GHCPKGBIN PKGCONFOPT
107 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
108 INSTALL_SCRIPTS  += $(SCRIPT_PROG)
109 endif
110 PKGCONFOPT        = --global-conf $(PKGCONF)
111
112 ifeq "$(INSTALLING)" "1"
113 SCRIPT_PROG     =  $(INSTALLED_SCRIPT_PROG)
114 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
115 LINK            =  ghc-pkg
116 endif
117 else
118 SCRIPT_PROG     =  $(INPLACE_SCRIPT_PROG)
119 endif
120
121 # -----------------------------------------------------------------------------
122 # don't recurse on 'make install'
123 #
124 ifeq "$(INSTALLING)" "1"
125 all :: $(HS_PROG)
126         $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
127 clean distclean maintainer-clean ::
128         $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
129 endif
130
131 # ghc-pkg is needed to boot in ghc/rts and library dirs
132 # Do a recursive 'make all' after generating dependencies, because this
133 # will work with 'make -j'.
134 ifneq "$(BootingFromHc)" "YES"
135 boot :: depend
136         $(MAKE) all
137 endif
138
139 include $(TOP)/mk/target.mk