1 # -----------------------------------------------------------------------------
2 # $Id: package.mk,v 1.38 2004/03/27 09:57:58 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
106 # POSSIBLE alternative version using --make:
109 # $(GHC_INPLACE) $(HC_OPTS) --make $(HS_SRCS)
113 # $(AR) $(AR_OPTS) $@ $(HS_OBJS)
117 # $(GHC_INPLACE) $(HC_OPTS) --make $<
119 # $(GHC_INPLACE) $(HC_OPTS) --make $<
121 # -----------------------------------------------------------------------------
122 # Installation; need to install .hi files as well as libraries
124 ifeq "$(DLLized)" "YES"
125 INSTALL_PROGS += $(DLL_NAME)
126 INSTALL_LIBS += $(patsubst %.a,%_imp.a, $(LIBRARY))
129 # The interface files are put inside the $(libdir), since they
130 # might (potentially) be platform specific..
132 ifeq "$(HIERARCHICAL_LIB)" "YES"
133 ifacedir = $(libdir)/imports
135 ifacedir = $(libdir)/hslibs-imports/$(PACKAGE)
138 # If the lib consists of a hierachy of modules, we must retain the directory
139 # structure when we install the interfaces.
140 ifeq "$(HIERARCHICAL_LIB)" "YES"
141 INSTALL_IFACES_WITH_DIRS += $(HS_IFACES)
142 ifneq "$(ALL_DIRS)" ""
144 @for i in $(ALL_DIRS); do \
145 $(INSTALL_DIR) $(ifacedir)/$$i; \
149 INSTALL_IFACES += $(HS_IFACES)
152 # -----------------------------------------------------------------------------
155 ifeq "$(STANDALONE_PACKAGE)" "NO"
156 MKDEPENDHS = $(GHC_INPLACE)
159 SRC_MKDEPENDC_OPTS += $(addprefix -I,$(ALL_DIRS))
161 ifeq "$(STANDALONE_PACKAGE)" "NO"
162 SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
165 endif # $(PACKAGE) /= ""
167 # install library (could be implicitly specified or explicitly, like libHS*_cbits.a)
168 INSTALL_LIBS += $(LIBRARY)
170 #--------------------------------------------------------------
171 # Building dynamically-linkable libraries for GHCi
173 # Build $(GHCI_LIBRARY) whenever we build $(LIBRARY)
175 # Why? GHCi can only link .o files (at the moment), not .a files
176 # so we have to build libFoo.o as well as libFoo.a
178 # Furthermore, GHCi currently never loads
179 # profiling libraries (or other non-std ways)
181 ifneq "$(LIBRARY)" ""
184 ifeq "$(GhcWithInterpreter)" "YES"
186 GHCI_LIBRARY = $(patsubst lib%.a,%.o,$(LIBRARY))
188 INSTALL_LIBS += $(GHCI_LIBRARY)
189 CLEAN_FILES += $(GHCI_LIBRARY)
191 all :: $(GHCI_LIBRARY)
193 ifneq "$(DONT_WANT_STD_GHCI_LIB_RULE)" "YES"
194 # If you don't want to build GHCI_LIBRARY the 'standard' way,
195 # set DONT_WANT_STD_GHCI_LIB_RULE to YES. The Prelude and
196 # hslibs/Win32 uses this 'feature', which will go away soon
197 # when we can use a "fixed" ld.
199 $(GHCI_LIBRARY) : $(LIBOBJS)
200 $(LD) -r $(LD_X) -o $@ $(STUBOBJS) $(LIBOBJS)
202 endif # DONT_WANT_STD_GHCI_LIB_RULE
203 endif # GhcWithInterpreter
206 # -----------------------------------------------------------------------------
207 # Doc building with Haddock
209 ifneq "$(NO_HADDOCK_DOCS)" "YES"
211 HS_PPS = $(addsuffix .raw-hs, $(basename $(filter-out $(EXCLUDED_HADDOCK_SRCS), $(HS_SRCS))))
214 HTML_DOC = $(HTML_DIR)/haddock.css $(HTML_DIR)/haddock.js
218 CLEAN_FILES += $(HS_PPS) $(addsuffix .tmp, $(HS_SRCS))
222 @echo Haddock must be installed in order to build HTML library documentation.
223 @echo Please install Haddock and re-configure.
230 $(RM) -rf $(HTML_DIR)
232 $(HTML_DOC) : $(HS_PPS)
233 @$(INSTALL_DIR) $(HTML_DIR)
234 $(HADDOCK) $(HADDOCK_OPTS) -h -o $(HTML_DIR) $(HS_PPS) \
235 --package=$(PACKAGE) \
236 --dump-interface=$(PACKAGE).haddock \
237 --use-index=../doc-index.html --use-contents=../index.html \
238 $(foreach pkg, $(PACKAGE_DEPS), \
239 --read-interface=../$(pkg),../$(pkg)/$(pkg).haddock)
241 CLEAN_FILES += $(PACKAGE).haddock
244 $(HC) $(HC_OPTS) -D__HADDOCK__ -E -optP-P $< -o $@
247 $(HC) $(HC_OPTS) -D__HADDOCK__ -E -optP-P $< -o $@
249 install-docs :: $(HTML_DOC)
250 @$(INSTALL_DIR) $(datadir)/html/libraries/$(PACKAGE)
251 @for i in $(HTML_DIR)/*; do \
252 echo $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/libraries/$(PACKAGE); \
253 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/libraries/$(PACKAGE); \
255 $(INSTALL_DATA) $(INSTALL_OPTS) $(PACKAGE).haddock $(datadir)/html/libraries/$(PACKAGE)
258 endif # NO_HADDOCK_DOCS
260 # -----------------------------------------------------------------------------
262 endif # $(LIBRARY) /= ""