8 # To rebuild a particular library <package>:
10 # make clean.library.<package>
11 # make make.library.<package>
13 # or the following is equivalent:
15 # make remake.library.<package>
17 # To add a new library to the tree, do
19 # darcs get http://darcs.haskell.org/packages/foo
20 # [ -f foo/configure.ac ] && ( cd foo && autoreconf )
21 # make make.library.foo
23 .PHONY: default_target
27 # make doesn't give us an easy way to get the libraries built in
28 # dependency order the first time, but not rebuild base (for example)
29 # when we want to rebuild another library later.
30 # So for now we just don't do anything in parallel in here.
33 # Ideally we'd just include something to give us variables
34 # for paths and arguments to tools etc, and those set in mk/build.mk.
36 include $(TOP)/mk/boilerplate.mk
37 include $(TOP)/mk/cabal-flags.mk
43 # Any libraries listed here should also be in ../packages
48 SUBDIRS += ghc-prim $(INTEGER_LIBRARY) base syb base3-compat array packedstring
49 SUBDIRS += containers bytestring old-locale old-time filepath
50 ifeq "$(GhcLibsWithUnix)" "YES"
53 ifeq "$(Windows)" "YES"
54 SUBDIRS += $(wildcard Win32)
56 SUBDIRS += directory process pretty hpc template-haskell editline Cabal random haskell98
58 # Set GhcBootLibs=YES from the command line to work with just the libraries
59 # needed to bootstrap GHC.
60 ifneq "$(GhcBootLibs)" "YES"
61 SUBDIRS += $(wildcard regex-base)
62 SUBDIRS += $(wildcard regex-posix)
63 SUBDIRS += $(wildcard regex-compat)
64 SUBDIRS += $(wildcard parsec)
65 SUBDIRS += $(wildcard haskell-src)
66 SUBDIRS += $(wildcard html)
67 SUBDIRS += $(wildcard network)
68 SUBDIRS += $(wildcard QuickCheck)
69 SUBDIRS += $(wildcard HUnit)
70 SUBDIRS += $(wildcard mtl)
71 SUBDIRS += $(wildcard time)
72 SUBDIRS += $(wildcard stm)
73 SUBDIRS += $(wildcard xhtml)
74 SUBDIRS += $(wildcard parallel)
79 ifneq "$(GhcBootLibs)" "YES"
80 ifneq "$(wildcard dph)" ""
81 SUBDIRS += dph/dph-base
82 SUBDIRS += dph/dph-prim-interface
83 SUBDIRS += dph/dph-prim-seq
84 SUBDIRS += dph/dph-prim-par
85 SUBDIRS += dph/dph-seq
86 SUBDIRS += dph/dph-par
91 # -----------------------------------------------------------------------------
94 space=$(empty) $(empty)
96 # -----------------------------------------------------------------------------
98 ifeq "$(ghc_ge_609)" "YES"
99 GhcLibHcOpts += -fno-warn-deprecated-flags
102 IFBUILDABLE=ifBuildable/ifBuildable $(FPTOOLS_TOP_ABS)/packages
104 ifneq "$(DOING_BIN_DIST)" "YES"
107 CONFIGURE_STAMP_EXTRAS :=
109 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
110 CONFIGURE_OPTS += --enable-library-profiling
111 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
114 ifeq "$(BuildSharedLibs)" "YES"
115 CONFIGURE_OPTS += --enable-shared
116 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-shared
119 ifeq "$(SplitObjs)" "YES"
120 CONFIGURE_OPTS += --enable-split-objs
121 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
124 ifeq "$(HSCOLOUR_SRCS)" "YES"
125 CONFIGURE_OPTS += --with-hscolour="$(HSCOLOUR)"
133 HERE_ABS=$(FPTOOLS_TOP_ABS)/libraries
135 CABAL_GHC_FLAGS = -Wall
137 BOOTSTRAPPING_FLAGS = $(CABAL_GHC_FLAGS) -DCABAL_VERSION=$(CABAL_VERSION) -odir $(HERE_ABS)/bootstrapping -hidir $(HERE_ABS)/bootstrapping -i$(HERE_ABS)/Cabal -i$(HERE_ABS)/filepath -i$(HERE_ABS)/hpc
141 boot: ifBuildable/ifBuildable cabal-bin bootstrapping.conf
143 cabal-bin: cabal-bin.hs
145 $(GHC) $(BOOTSTRAPPING_FLAGS) --make cabal-bin -o cabal-bin
147 bootstrapping.conf: cabal-bin
149 -cd extensible-exceptions && $(CABAL) clean --distpref=dist-bootstrapping
150 cd extensible-exceptions && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
151 cd extensible-exceptions && $(CABAL) build --distpref=dist-bootstrapping
152 cd extensible-exceptions && $(CABAL) install --distpref=dist-bootstrapping --inplace
153 -cd filepath && $(CABAL) clean --distpref=dist-bootstrapping
154 cd filepath && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
155 cd filepath && $(CABAL) build --distpref=dist-bootstrapping
156 cd filepath && $(CABAL) install --distpref=dist-bootstrapping --inplace
157 -cd Cabal && $(CABAL) clean --distpref=dist-bootstrapping
158 cd Cabal && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
159 cd Cabal && $(CABAL) build --distpref=dist-bootstrapping
160 cd Cabal && $(CABAL) install --distpref=dist-bootstrapping --inplace
161 -cd hpc && $(CABAL) clean --distpref=dist-bootstrapping
162 cd hpc && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
163 cd hpc && $(CABAL) build --distpref=dist-bootstrapping
164 cd hpc && $(CABAL) install --distpref=dist-bootstrapping --inplace
167 ifBuildable/ifBuildable: ifBuildable.hs
168 -$(RM) -rf ifBuildable
170 $(CP) ifBuildable.hs ifBuildable/
172 cd ifBuildable && ../$(HC) -Wall --make ifBuildable -o ifBuildable
174 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
177 .PHONY: all build configure
181 .PHONY: rebuild.library.%
182 .PHONY: remake.library.%
184 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
185 rebuild.library.%: clean.library.% build.library.%
187 $(foreach SUBDIR,$(SUBDIRS),remake.library.$(SUBDIR)):\
188 remake.library.%: clean.library.% make.library.%
190 # NB. we're depending on make chasing dependencies from left to right here.
191 # This bit goes wrong with 'make -j'.
192 build: $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR))
194 configure: $(foreach SUBDIR,$(SUBDIRS), \
195 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
197 .PHONY: build.library.%
198 .PHONY: make.library.%
200 # We should depend on %/%.cabal here (and in other rules), but make
201 # makes that difficult.
203 ALL_CONFIGURE_FLAGS = \
204 $(INSTALL_DIRS_CONFIGURE_FLAGS) \
205 $(USE_STAGE$(stage)_CONFIGURE_FLAGS) \
206 $(COMMON_CONFIGURE_FLAGS) \
207 --haddock-options="--use-contents=../index.html \
208 --use-index=../doc-index.html" \
211 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).dph/dph-par: \
214 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).dph/dph-seq: \
220 $(foreach SUBDIR,$(SUBDIRS), \
221 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
222 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: cabal-bin
223 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
224 $(MKDIRHIER) `dirname $@`
225 ( cd $* && $(CABAL) configure $(ALL_CONFIGURE_FLAGS) ) \
226 && touch $@ || touch $*/unbuildable
227 # We don't touch $@ if configure failed as we would prefer to try
228 # configuring it next time round, rather than assuming it'll still fail.
229 # This is particularly important for bootlibs, where failure means the
232 # Build the library using 'make'
233 # We re-run 'setup makefile' each time, just in case any preprocessing
234 # needs to be done. However, we're careful not to overwrite GNUmakefile
235 # if it hasn't changed, so that dependency-generation isn't forced
237 $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR)):\
238 make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
239 cabal-bin ifBuildable/ifBuildable
240 if $(IFBUILDABLE) $*; then \
242 cmp -s $(MAKEFILE_LOCAL) Makefile.local || cp $(MAKEFILE_LOCAL) .; \
243 mv GNUmakefile GNUmakefile.tmp; \
244 $(CABAL) makefile -f GNUmakefile; \
245 cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
246 $(MAKE) $(MFLAGS) && \
247 $(CABAL) register --inplace; \
250 MAKEFILE_LOCAL = $(FPTOOLS_TOP_ABS)/libraries/Makefile.local
252 # Build the library using 'setup build' (not the default)
253 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
254 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
255 cabal-bin ifBuildable/ifBuildable
256 if $(IFBUILDABLE) $*; then \
258 $(CABAL) build $(BUILD_FLAGS); \
259 $(CABAL) register --inplace; \
266 # No docs for compat libraries for now.
267 DOC_SUBDIRS = $(filter-out %-compat, $(SUBDIRS))
269 doc: $(foreach SUBDIR,$(DOC_SUBDIRS),doc.library.$(SUBDIR))
270 sh gen_contents_index --inplace
272 # Making hyperlinked source only works if we have hscolour
273 ifeq "$(HSCOLOUR_SRCS)" "YES"
274 CABAL_HADDOCK_FLAGS += --hyperlink-source
276 CABAL_HADDOCK_FLAGS += --with-haddock=$(FPTOOLS_TOP_ABS)/utils/haddock/install-inplace/bin/haddock
278 $(foreach SUBDIR,$(DOC_SUBDIRS),doc.library.$(SUBDIR)):\
279 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
280 cabal-bin ifBuildable/ifBuildable
281 if $(IFBUILDABLE) $*; then \
282 cd $* && $(CABAL) haddock --html-location='../$$pkg' \
283 $(CABAL_HADDOCK_FLAGS); \
285 ifneq "$(HSCOLOUR)" ""
286 # We use */src rather than $*/src due to the $(INTEGER_LIBRARY)/integer
288 # XXX We also need to check that the directory exists, as e.g. dph disables
289 # haddock, so the directory doesn't get made. We should remove this once
290 # we can always haddock everything.
291 if $(IFBUILDABLE) $* && [ -d $*/dist/doc/html/*/src/ ]; then cp hscolour.css $*/dist/doc/html/*/src/; fi
294 .PHONY: maintainer-clean distclean clean clean.library.%
296 maintainer-clean: clean
299 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
300 -cd extensible-exceptions && $(CABAL) clean --distpref=dist-bootstrapping
301 -cd filepath && $(CABAL) clean --distpref=dist-bootstrapping
302 -cd Cabal && $(CABAL) clean --distpref=dist-bootstrapping
303 -cd hpc && $(CABAL) clean --distpref=dist-bootstrapping
304 $(RM) -rf bootstrapping
305 $(RM) -f bootstrapping.conf bootstrapping.conf.old
306 $(RM) -f bootstrapping.conf.tmp bootstrapping.conf.tmp.old
307 $(RM) -f cabal-bin cabal-bin.exe
308 $(RM) -rf ifBuildable
309 $(RM) -f libraries.txt index.html doc-index.html doc-index*.html
310 $(RM) -f haddock* *.gif
312 ifneq "$(wildcard dph)" ""
316 maintainer-clean distclean:
317 $(RM) $(foreach lib, $(SUBDIRS), $(lib)/.depend $(lib)/.depend.bak)
319 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
321 $(RM) -f stamp/configure.library.*.$* $*/unbuildable
322 -cd $* && $(CABAL) clean
323 $(RM) -f $*/Setup $*/Setup.exe $*/Setup.hi $*/Setup.o
324 $(RM) $*/GNUmakefile $*/Makefile.local
327 # -----------------------------------------------------------------------------
329 .PHONY: install install-docs install.library.%
331 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
332 ifeq "$(HADDOCK_DOCS)" "YES"
333 $(INSTALL_DIR) $(DESTDIR)$(html_installed_root)
334 $(INSTALL_DATA) index.html doc-index*.html $(DESTDIR)$(html_installed_root)
335 $(INSTALL_SCRIPT) gen_contents_index $(DESTDIR)$(html_installed_root)
336 $(INSTALL_DATA) prologue.txt $(DESTDIR)$(html_installed_root)
338 $(INSTALL_DATA) base/dist/doc/html/*/*.css $(DESTDIR)$(html_installed_root)
339 $(INSTALL_DATA) base/dist/doc/html/*/*.js $(DESTDIR)$(html_installed_root)
340 $(INSTALL_DATA) base/dist/doc/html/*/*.gif $(DESTDIR)$(html_installed_root)
343 # Cabal doesn't let us ask to install docs only, so do nothing here
347 # Ideally this would depend on a stamp/build.library.%, but if it does
348 # then we can't change the libraries and then just rerun make.
349 # Thus if you install without building then it will just break.
351 # prefix and (on Windows) htmldir use $topdir when configuring, so we
352 # need to tell installPackage the real path to use when installing.
354 # We also need to pass all the other directories in, as they can be
355 # overridden when installing a bindist.
357 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
358 install.library.%: ifBuildable/ifBuildable
359 if $(IFBUILDABLE) $*; then \
361 $(INSTALL_PACKAGE) install '$(GHC_PKG_INSTALL_PROG)' '$(DESTDIR)$(datadir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idynlibdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(ihaddockdir)' ; \
364 .PHONY: binary-dist binary-dist.library.%
366 BIN_DIST_LIBDIR=$(BIN_DIST_DIR)/libraries
368 binary-dist: $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR))
369 ifeq "$(WHERE_AM_I)" ""
370 echo "I don't know where I am" >&2
373 echo $(WHERE_AM_I)/Makefile >> $(BIN_DIST_LIST)
374 # XXX This needs to be changed: This ifBuildable is built with the
375 # bootstrapping compiler, so isn't OS X friendly. It should be made into
376 # a Cabal package if we keep it. However, once we drop extralibs we can
377 # probably remove it anyway.
378 echo $(WHERE_AM_I)/ifBuildable/ifBuildable >> $(BIN_DIST_LIST)
379 for FILE in dph/dph-prim-interface/interface/*.h dph/dph/LICENSE; do if [ -f $$FILE ]; then echo $(WHERE_AM_I)/$$FILE >> $(BIN_DIST_LIST); fi; done
380 ifeq "$(HADDOCK_DOCS)" "YES"
381 for FILE in gen_contents_index prologue.txt index.html doc-index*.html; do echo $(WHERE_AM_I)/$$FILE >> $(BIN_DIST_LIST); done
384 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
385 binary-dist.library.%:
386 if $(IFBUILDABLE) $*; then \
387 $(MAKE) -C $* -f Makefile.local binary-dist BINDIST_EXTRAS="$*.cabal LICENSE $*.buildinfo unbuildable" WHERE_AM_I=$(WHERE_AM_I)/$*; \
390 # Ignore some doc targets that we don't support
391 # The root recurses into us when these targets are made
392 .PHONY: html-no-chunks chm HxS fo dvi ps pdf
393 html-no-chunks chm HxS fo dvi ps pdf: