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
46 DO_STAGE_1_LIBS := YES
49 DO_STAGE_2_LIBS := YES
51 ifneq "$(filter install clean maintainer-clean distclean binary-dist,$(MAKECMDGOALS))" ""
52 DO_STAGE_1_LIBS := YES
53 DO_STAGE_2_LIBS := YES
56 # Any libraries listed here should also be in ../packages
60 ifeq "$(DO_STAGE_1_LIBS)" "YES"
61 SUBDIRS += ghc-prim $(INTEGER_LIBRARY) base syb base3-compat array packedstring
62 SUBDIRS += containers bytestring old-locale old-time filepath
63 ifeq "$(GhcLibsWithUnix)" "YES"
66 ifeq "$(Windows)" "YES"
67 SUBDIRS += $(wildcard Win32)
69 SUBDIRS += directory process pretty hpc template-haskell editline Cabal random haskell98
71 # Set GhcBootLibs=YES from the command line to work with just the libraries
72 # needed to bootstrap GHC.
73 ifneq "$(GhcBootLibs)" "YES"
74 SUBDIRS += $(wildcard regex-base)
75 SUBDIRS += $(wildcard regex-posix)
76 SUBDIRS += $(wildcard regex-compat)
77 SUBDIRS += $(wildcard parsec)
78 SUBDIRS += $(wildcard haskell-src)
79 SUBDIRS += $(wildcard html)
80 SUBDIRS += $(wildcard network)
81 SUBDIRS += $(wildcard QuickCheck)
82 SUBDIRS += $(wildcard HUnit)
83 SUBDIRS += $(wildcard mtl)
84 SUBDIRS += $(wildcard time)
85 SUBDIRS += $(wildcard stm)
86 SUBDIRS += $(wildcard xhtml)
87 SUBDIRS += $(wildcard parallel)
91 ifeq "$(DO_STAGE_2_LIBS)" "YES"
92 ifneq "$(GhcBootLibs)" "YES"
93 ifneq "$(wildcard dph)" ""
94 SUBDIRS += dph/dph-base
95 SUBDIRS += dph/dph-prim-interface
96 SUBDIRS += dph/dph-prim-seq
97 SUBDIRS += dph/dph-prim-par
98 SUBDIRS += dph/dph-seq
99 SUBDIRS += dph/dph-par
104 # -----------------------------------------------------------------------------
107 space=$(empty) $(empty)
109 # -----------------------------------------------------------------------------
111 ifeq "$(ghc_ge_609)" "YES"
112 GhcLibHcOpts += -fno-warn-deprecated-flags
115 IFBUILDABLE=ifBuildable/ifBuildable $(FPTOOLS_TOP_ABS)/packages
117 ifneq "$(DOING_BIN_DIST)" "YES"
120 CONFIGURE_STAMP_EXTRAS :=
122 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
123 CONFIGURE_OPTS += --enable-library-profiling
124 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
127 ifeq "$(BuildSharedLibs)" "YES"
128 CONFIGURE_OPTS += --enable-shared
129 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-shared
132 ifeq "$(SplitObjs)" "YES"
133 CONFIGURE_OPTS += --enable-split-objs
134 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
142 HERE_ABS=$(FPTOOLS_TOP_ABS)/libraries
144 CABAL_GHC_FLAGS = -Wall
146 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
150 boot: ifBuildable/ifBuildable cabal-bin bootstrapping.conf
152 cabal-bin: cabal-bin.hs
154 $(GHC) $(BOOTSTRAPPING_FLAGS) --make cabal-bin -o cabal-bin
156 bootstrapping.conf: cabal-bin
158 -cd extensible-exceptions && $(CABAL) clean --distpref=dist-bootstrapping
159 cd extensible-exceptions && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
160 cd extensible-exceptions && $(CABAL) build --distpref=dist-bootstrapping
161 cd extensible-exceptions && $(CABAL) install --distpref=dist-bootstrapping --inplace
162 -cd filepath && $(CABAL) clean --distpref=dist-bootstrapping
163 cd filepath && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
164 cd filepath && $(CABAL) build --distpref=dist-bootstrapping
165 cd filepath && $(CABAL) install --distpref=dist-bootstrapping --inplace
166 -cd Cabal && $(CABAL) clean --distpref=dist-bootstrapping
167 cd Cabal && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
168 cd Cabal && $(CABAL) build --distpref=dist-bootstrapping
169 cd Cabal && $(CABAL) install --distpref=dist-bootstrapping --inplace
170 -cd hpc && $(CABAL) clean --distpref=dist-bootstrapping
171 cd hpc && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
172 cd hpc && $(CABAL) build --distpref=dist-bootstrapping
173 cd hpc && $(CABAL) install --distpref=dist-bootstrapping --inplace
176 ifBuildable/ifBuildable: ifBuildable.hs
177 -$(RM) -rf ifBuildable
179 $(CP) ifBuildable.hs ifBuildable/
181 cd ifBuildable && ../$(HC) -Wall --make ifBuildable -o ifBuildable
183 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
186 .PHONY: all build configure
190 .PHONY: rebuild.library.%
191 .PHONY: remake.library.%
193 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
194 rebuild.library.%: clean.library.% build.library.%
196 $(foreach SUBDIR,$(SUBDIRS),remake.library.$(SUBDIR)):\
197 remake.library.%: clean.library.% make.library.%
199 # The meta package dph is a special case
202 @echo "*** Package dph needs to be made in stage=2"
205 # NB. we're depending on make chasing dependencies from left to right here.
206 # This bit goes wrong with 'make -j'.
207 remake.library.dph: remake.library.dph/dph-base \
208 remake.library.dph/dph-prim-interface \
209 remake.library.dph/dph-prim-seq \
210 remake.library.dph/dph-prim-par \
211 remake.library.dph/dph-seq \
212 remake.library.dph/dph-par
215 # NB. we're depending on make chasing dependencies from left to right here.
216 # This bit goes wrong with 'make -j'.
217 build: $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR))
219 configure: $(foreach SUBDIR,$(SUBDIRS), \
220 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
222 .PHONY: build.library.%
223 .PHONY: make.library.%
225 # We should depend on %/%.cabal here (and in other rules), but make
226 # makes that difficult.
228 ALL_CONFIGURE_FLAGS = \
229 $(INSTALL_DIRS_CONFIGURE_FLAGS) \
230 $(USE_STAGE$(stage)_CONFIGURE_FLAGS) \
231 $(COMMON_CONFIGURE_FLAGS) \
232 --haddock-options="--use-contents=../index.html \
233 --use-index=../doc-index.html" \
236 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).dph/dph-par: \
239 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).dph/dph-seq: \
245 $(foreach SUBDIR,$(SUBDIRS), \
246 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
247 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: cabal-bin
248 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
249 $(MKDIRHIER) `dirname $@`
250 ( cd $* && $(CABAL) configure $(ALL_CONFIGURE_FLAGS) ) \
251 && touch $@ || touch $*/unbuildable
252 # We don't touch $@ if configure failed as we would prefer to try
253 # configuring it next time round, rather than assuming it'll still fail.
254 # This is particularly important for bootlibs, where failure means the
257 # Build the library using 'make'
258 # We re-run 'setup makefile' each time, just in case any preprocessing
259 # needs to be done. However, we're careful not to overwrite GNUmakefile
260 # if it hasn't changed, so that dependency-generation isn't forced
262 $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR)):\
263 make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
264 cabal-bin ifBuildable/ifBuildable
265 if $(IFBUILDABLE) $*; then \
267 cmp -s $(MAKEFILE_LOCAL) Makefile.local || cp $(MAKEFILE_LOCAL) .; \
268 mv GNUmakefile GNUmakefile.tmp; \
269 $(CABAL) makefile -f GNUmakefile; \
270 cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
271 $(MAKE) $(MFLAGS) && \
272 $(CABAL) register --inplace; \
275 # Special case for meta package dph: we can only remake it as we don't have
276 # any dependency info between the sub-packages
278 @echo "*** Please use the target 'remake.library.dph' instead"
280 MAKEFILE_LOCAL = $(FPTOOLS_TOP_ABS)/libraries/Makefile.local
282 # Build the library using 'setup build' (not the default)
283 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
284 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
285 cabal-bin ifBuildable/ifBuildable
286 if $(IFBUILDABLE) $*; then \
288 $(CABAL) build $(BUILD_FLAGS); \
289 $(CABAL) register --inplace; \
296 # No docs for compat libraries for now.
297 DOC_SUBDIRS = $(filter-out %-compat, $(SUBDIRS))
299 doc: $(foreach SUBDIR,$(DOC_SUBDIRS),doc.library.$(SUBDIR))
300 sh gen_contents_index --inplace
302 # Making hyperlinked source only works if we have hscolour
303 ifeq "$(HSCOLOUR_SRCS)" "YES"
304 CABAL_HADDOCK_FLAGS += --hyperlink-source
306 CABAL_HADDOCK_FLAGS += --with-haddock=$(FPTOOLS_TOP_ABS)/utils/haddock/install-inplace/bin/haddock
308 $(foreach SUBDIR,$(DOC_SUBDIRS),doc.library.$(SUBDIR)):\
309 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
310 cabal-bin ifBuildable/ifBuildable
311 if $(IFBUILDABLE) $*; then \
312 cd $* && $(CABAL) haddock --html-location='../$$pkg' \
313 $(CABAL_HADDOCK_FLAGS); \
315 ifneq "$(HSCOLOUR)" ""
316 # We use */src rather than $*/src due to the $(INTEGER_LIBRARY)/integer
318 # XXX We also need to check that the directory exists, as e.g. dph disables
319 # haddock, so the directory doesn't get made. We should remove this once
320 # we can always haddock everything.
321 if $(IFBUILDABLE) $* && [ -d $*/dist/doc/html/*/src/ ]; then cp hscolour.css $*/dist/doc/html/*/src/; fi
324 .PHONY: maintainer-clean distclean clean clean.library.%
326 maintainer-clean: clean
329 ifeq "$(wildcard dph)" ""
330 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
332 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)) clean.library.dph
334 -cd extensible-exceptions && $(CABAL) clean --distpref=dist-bootstrapping
335 -cd filepath && $(CABAL) clean --distpref=dist-bootstrapping
336 -cd Cabal && $(CABAL) clean --distpref=dist-bootstrapping
337 -cd hpc && $(CABAL) clean --distpref=dist-bootstrapping
338 $(RM) -rf bootstrapping
339 $(RM) -f bootstrapping.conf bootstrapping.conf.old
340 $(RM) -f bootstrapping.conf.tmp bootstrapping.conf.tmp.old
341 $(RM) -f cabal-bin cabal-bin.exe
342 $(RM) -rf ifBuildable
343 $(RM) -f libraries.txt index.html doc-index.html doc-index*.html
344 $(RM) -f haddock* *.gif
347 maintainer-clean distclean:
348 $(RM) $(foreach lib, $(SUBDIRS), $(lib)/.depend $(lib)/.depend.bak)
350 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
352 $(RM) -f stamp/configure.library.*.$* $*/unbuildable
353 -cd $* && $(CABAL) clean
354 $(RM) -f $*/Setup $*/Setup.exe $*/Setup.hi $*/Setup.o
355 $(RM) $*/GNUmakefile $*/Makefile.local
358 # Extra target to clean all the sub-packages of dph
361 @echo "*** Package dph needs to be made in stage=2"
364 clean.library.dph: clean.library.dph/dph-prim-par \
365 clean.library.dph/dph-prim-seq \
366 clean.library.dph/dph-prim-interface \
367 clean.library.dph/dph-base
371 # -----------------------------------------------------------------------------
373 .PHONY: install install-docs install.library.%
375 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
376 ifeq "$(HADDOCK_DOCS)" "YES"
377 $(INSTALL_DIR) $(DESTDIR)$(html_installed_root)
378 $(INSTALL_DATA) index.html doc-index*.html $(DESTDIR)$(html_installed_root)
379 $(INSTALL_SCRIPT) gen_contents_index $(DESTDIR)$(html_installed_root)
380 $(INSTALL_DATA) prologue.txt $(DESTDIR)$(html_installed_root)
382 $(INSTALL_DATA) base/dist/doc/html/*/*.css $(DESTDIR)$(html_installed_root)
383 $(INSTALL_DATA) base/dist/doc/html/*/*.js $(DESTDIR)$(html_installed_root)
384 $(INSTALL_DATA) base/dist/doc/html/*/*.gif $(DESTDIR)$(html_installed_root)
387 # Cabal doesn't let us ask to install docs only, so do nothing here
391 # Ideally this would depend on a stamp/build.library.%, but if it does
392 # then we can't change the libraries and then just rerun make.
393 # Thus if you install without building then it will just break.
395 # prefix and (on Windows) htmldir use $topdir when configuring, so we
396 # need to tell installPackage the real path to use when installing.
398 # We also need to pass all the other directories in, as they can be
399 # overridden when installing a bindist.
401 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
402 install.library.%: ifBuildable/ifBuildable
403 if $(IFBUILDABLE) $*; then \
405 $(INSTALL_PACKAGE) install '$(GHC_PKG_INSTALL_PROG)' '$(DESTDIR)$(datadir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idynlibdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(ihaddockdir)' ; \
408 .PHONY: binary-dist binary-dist.library.%
410 BIN_DIST_LIBDIR=$(BIN_DIST_DIR)/libraries
412 binary-dist: $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR))
413 ifeq "$(WHERE_AM_I)" ""
414 echo "I don't know where I am" >&2
417 echo $(WHERE_AM_I)/Makefile >> $(BIN_DIST_LIST)
418 # XXX This needs to be changed: This ifBuildable is built with the
419 # bootstrapping compiler, so isn't OS X friendly. It should be made into
420 # a Cabal package if we keep it. However, once we drop extralibs we can
421 # probably remove it anyway.
422 echo $(WHERE_AM_I)/ifBuildable/ifBuildable >> $(BIN_DIST_LIST)
423 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
424 ifeq "$(HADDOCK_DOCS)" "YES"
425 for FILE in gen_contents_index prologue.txt index.html doc-index*.html; do echo $(WHERE_AM_I)/$$FILE >> $(BIN_DIST_LIST); done
428 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
429 binary-dist.library.%:
430 if $(IFBUILDABLE) $*; then \
431 $(MAKE) -C $* -f Makefile.local binary-dist BINDIST_EXTRAS="$*.cabal LICENSE $*.buildinfo unbuildable" WHERE_AM_I=$(WHERE_AM_I)/$*; \
434 # Ignore some doc targets that we don't support
435 # The root recurses into us when these targets are made
436 .PHONY: html-no-chunks chm HxS fo dvi ps pdf
437 html-no-chunks chm HxS fo dvi ps pdf: