1 # -----------------------------------------------------------------------------
2 # $Id: package.mk,v 1.36 2004/02/07 14:08:57 panne Exp $
6 ifeq "$(STANDALONE_PACKAGE)" ""
7 ifeq "$(ProjectNameShort)" "ghc"
8 STANDALONE_PACKAGE = NO
10 STANDALONE_PACKAGE = YES
14 # -----------------------------------------------------------------------------
15 # Build the package configuration file and tell the compiler about it.
19 ifeq "$(STANDALONE_PACKAGE)" "NO"
20 PKGCONF_CPP_EXTRA_OPTS = -I$(GHC_INCLUDE_DIR)
22 PKGCONF_CPP_EXTRA_OPTS =
25 package.conf.inplace : package.conf.in
26 $(CPP) $(RAWCPP_FLAGS) -P $(PKGCONF_CPP_EXTRA_OPTS) -x c $(PACKAGE_CPP_OPTS) $< | \
27 sed -e 's/""//g' -e 's/\[ *,/[ /g' >$@
29 package.conf.installed : package.conf.in
30 $(CPP) $(RAWCPP_FLAGS) -P $(PKGCONF_CPP_EXTRA_OPTS) -DINSTALLING -x c $(PACKAGE_CPP_OPTS) $< | \
31 sed -e 's/""//g' -e 's/\[ *,/[ /g' >$@
33 # we could be more accurate here and add a dependency on
34 # ghc/driver/package.conf, but that doesn't work too well because of
35 # make's limited accuracy with modification times: when doing 'make
36 # boot' in multiple packages, make won't detect that the package
37 # configuration needs updating if it was updated already in the last
40 # The stamp file goes in $(GHC_DRIVER_DIR), so that if someone happens
41 # to 'make clean' in ghc without cleaning in libraries too, the packages
42 # will be correctly re-installed.
44 ifeq "$(STANDALONE_PACKAGE)" "NO"
46 STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
47 CLEAN_FILES += $(STAMP_PKG_CONF)
49 ifneq "$(BootingFromHc)" "YES"
50 boot all :: $(STAMP_PKG_CONF)
53 $(STAMP_PKG_CONF) : package.conf.inplace package.conf.installed
54 $(GHC_PKG_INPLACE) --update-package <package.conf.inplace
55 $(GHC_PKG_INPLACE) -f $(GHC_DRIVER_DIR)/package.conf --update-package <package.conf.installed
56 @touch $(STAMP_PKG_CONF)
58 CLEAN_FILES += package.conf.installed package.conf.inplace
60 else # $(STANDALONE_PACKAGE) == "YES"
62 PACKAGE_CPP_OPTS += -DPACKAGE=\"${PACKAGE}\"
63 PACKAGE_CPP_OPTS += -DPACKAGE_DEPS='$(patsubst %,"%"$(comma),$(PACKAGE_DEPS))'
64 PACKAGE_CPP_OPTS += -DLIBRARY=\"HS$(PACKAGE)\"
65 PACKAGE_CPP_OPTS += -DLIBDIR=\"$(libdir)\"
66 PACKAGE_CPP_OPTS += -DFPTOOLS_TOP_ABS=\"${FPTOOLS_TOP_ABS}\"
68 # Let the package configuration file refer to $(libdir) as
69 # ${pkglibdir}. Note we can't use ${libdir} because ghc-pkg already
70 # redefines it to point to GHC's libdir (bug or feature?).
72 install :: package.conf.installed
73 $(GHC_PKG) --force --update-package <package.conf.installed
75 # Invoke this rule by hand in order to use the package in-place
76 install-inplace-pkg : package.conf.inplace
77 $(GHC_PKG) --force --update-package <package.conf.inplace
79 endif # $(STANDALONE_PACKAGE)
83 # -----------------------------------------------------------------------------
84 # Building the static library libHS<pkg>.a
86 ifeq "$(STANDALONE_PACKAGE)" "NO"
90 SRC_HSC2HS_OPTS += -I.
92 ifeq "$(NON_HS_PACKAGE)" ""
93 SRC_HC_OPTS += -package-name $(PACKAGE)
94 SRC_HC_OPTS += $(GhcLibHcOpts)
95 SRC_HC_OPTS += $(patsubst %, -package %, $(PACKAGE_DEPS))
98 LIBRARY = libHS$(PACKAGE)$(_way).a
104 # POSSIBLE alternative version using --make:
107 # $(GHC_INPLACE) $(HC_OPTS) --make $(HS_SRCS)
111 # $(AR) $(AR_OPTS) $@ $(HS_OBJS)
115 # $(GHC_INPLACE) $(HC_OPTS) --make $<
117 # $(GHC_INPLACE) $(HC_OPTS) --make $<
119 # -----------------------------------------------------------------------------
120 # Installation; need to install .hi files as well as libraries
122 ifeq "$(DLLized)" "YES"
123 INSTALL_PROGS += $(DLL_NAME)
124 INSTALL_LIBS += $(patsubst %.a,%_imp.a, $(LIBRARY))
127 # The interface files are put inside the $(libdir), since they
128 # might (potentially) be platform specific..
130 ifeq "$(HIERARCHICAL_LIB)" "YES"
131 ifacedir = $(libdir)/imports
133 ifacedir = $(libdir)/hslibs-imports/$(PACKAGE)
136 # If the lib consists of a hierachy of modules, we must retain the directory
137 # structure when we install the interfaces.
138 ifeq "$(HIERARCHICAL_LIB)" "YES"
139 INSTALL_IFACES_WITH_DIRS += $(HS_IFACES)
140 ifneq "$(ALL_DIRS)" ""
142 @for i in $(ALL_DIRS); do \
143 $(INSTALL_DIR) $(ifacedir)/$$i; \
147 INSTALL_IFACES += $(HS_IFACES)
150 # -----------------------------------------------------------------------------
153 ifeq "$(STANDALONE_PACKAGE)" "NO"
154 MKDEPENDHS = $(GHC_INPLACE)
157 SRC_MKDEPENDC_OPTS += $(addprefix -I,$(ALL_DIRS))
159 ifeq "$(STANDALONE_PACKAGE)" "NO"
160 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
163 endif # $(PACKAGE) /= ""
165 # install library (could be implicitly specified or explicitly, like libHS*_cbits.a)
166 INSTALL_LIBS += $(LIBRARY)
168 #--------------------------------------------------------------
169 # Building dynamically-linkable libraries for GHCi
171 # Build $(GHCI_LIBRARY) whenever we build $(LIBRARY)
173 # Why? GHCi can only link .o files (at the moment), not .a files
174 # so we have to build libFoo.o as well as libFoo.a
176 # Furthermore, GHCi currently never loads
177 # profiling libraries (or other non-std ways)
179 ifneq "$(LIBRARY)" ""
182 ifeq "$(GhcWithInterpreter)" "YES"
184 GHCI_LIBRARY = $(patsubst lib%.a,%.o,$(LIBRARY))
186 INSTALL_LIBS += $(GHCI_LIBRARY)
187 CLEAN_FILES += $(GHCI_LIBRARY)
189 all :: $(GHCI_LIBRARY)
191 ifneq "$(DONT_WANT_STD_GHCI_LIB_RULE)" "YES"
192 # If you don't want to build GHCI_LIBRARY the 'standard' way,
193 # set DONT_WANT_STD_GHCI_LIB_RULE to YES. The Prelude and
194 # hslibs/Win32 uses this 'feature', which will go away soon
195 # when we can use a "fixed" ld.
197 $(GHCI_LIBRARY) : $(LIBOBJS)
198 $(LD) -r $(LD_X) -o $@ $(STUBOBJS) $(LIBOBJS)
200 endif # DONT_WANT_STD_GHCI_LIB_RULE
201 endif # GhcWithInterpreter
204 # -----------------------------------------------------------------------------
205 # Doc building with Haddock
207 ifneq "$(NO_HADDOCK_DOCS)" "YES"
209 HS_PPS = $(addsuffix .raw-hs, $(basename $(filter-out $(EXCLUDED_HADDOCK_SRCS), $(HS_SRCS))))
212 HTML_DOC = $(HTML_DIR)/haddock.css
216 CLEAN_FILES += $(HS_PPS) $(addsuffix .tmp, $(HS_SRCS))
220 @echo Haddock must be installed in order to build HTML library documentation.
221 @echo Please install Haddock and re-configure.
228 $(RM) -rf $(HTML_DIR)
230 $(HTML_DOC) : $(HS_PPS)
231 @$(INSTALL_DIR) $(HTML_DIR)
232 $(HADDOCK) $(HADDOCK_OPTS) -h -o $(HTML_DIR) $(HS_PPS) \
233 --package=$(PACKAGE) \
234 --dump-interface=$(PACKAGE).haddock \
235 --use-index=../doc-index.html --use-contents=../index.html \
236 $(foreach pkg, $(PACKAGE_DEPS), \
237 --read-interface=../$(pkg),../$(pkg)/$(pkg).haddock)
239 CLEAN_FILES += $(PACKAGE).haddock
242 $(HC) $(HC_OPTS) -D__HADDOCK__ -E -optP-P $< -o $@
245 $(HC) $(HC_OPTS) -D__HADDOCK__ -E -optP-P $< -o $@
247 install-docs :: $(HTML_DOC)
248 @$(INSTALL_DIR) $(datadir)/html/libraries/$(PACKAGE)
249 @for i in $(HTML_DIR)/*; do \
250 echo $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/libraries/$(PACKAGE); \
251 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/libraries/$(PACKAGE); \
253 $(INSTALL_DATA) $(INSTALL_OPTS) $(PACKAGE).haddock $(datadir)/html/libraries/$(PACKAGE)
256 endif # NO_HADDOCK_DOCS
258 # -----------------------------------------------------------------------------
260 endif # $(LIBRARY) /= ""