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 # [ -e foo/configure.ac ] && ( cd foo && autoreconf )
21 # make make.library.foo
23 .PHONY: default_target show
28 @echo '$(VALUE)="$($(VALUE))"'
30 # make doesn't give us an easy way to get the libraries built in
31 # dependency order the first time, but not rebuild base (for example)
32 # when we want to rebuild another library later.
33 # So for now we just don't do anything in parallel in here.
36 # Ideally we'd just include something to give us variables
37 # for paths and arguments to tools etc, and those set in mk/build.mk.
39 include $(TOP)/mk/boilerplate.mk
41 SUBDIRS = ghc-prim $(INTEGER_LIBRARY) base array packedstring
42 SUBDIRS += containers bytestring old-locale old-time filepath directory
43 ifeq "$(GhcLibsWithUnix)" "YES"
46 ifeq "$(Windows)" "YES"
47 SUBDIRS += $(wildcard Win32)
49 SUBDIRS += process pretty hpc template-haskell editline Cabal random haskell98
51 # Set GhcBootLibs=YES from the command line to work with just the libraries
52 # needed to bootstrap GHC.
53 ifneq "$(GhcBootLibs)" "YES"
54 SUBDIRS += $(wildcard regex-base)
55 SUBDIRS += $(wildcard regex-posix)
56 SUBDIRS += $(wildcard regex-compat)
57 SUBDIRS += $(wildcard parsec)
58 SUBDIRS += $(wildcard haskell-src)
59 SUBDIRS += $(wildcard html)
60 SUBDIRS += $(wildcard network)
61 SUBDIRS += $(wildcard QuickCheck)
62 SUBDIRS += $(wildcard HUnit)
63 SUBDIRS += $(wildcard mtl)
64 SUBDIRS += $(wildcard fgl)
65 SUBDIRS += $(wildcard time)
66 SUBDIRS += $(wildcard OpenGL)
67 SUBDIRS += $(wildcard GLUT)
68 SUBDIRS += $(wildcard OpenAL)
69 SUBDIRS += $(wildcard ALUT)
70 SUBDIRS += $(wildcard stm)
71 SUBDIRS += $(wildcard xhtml)
72 SUBDIRS += $(wildcard cgi)
73 ifeq "$(GhcLibsWithObjectIO)" "YES"
74 SUBDIRS += $(wildcard ObjectIO)
76 SUBDIRS += $(wildcard parallel)
77 SUBDIRS_BUILD += $(wildcard ndp)
78 SUBDIRS_BUILD += $(wildcard dph/dph-base)
79 SUBDIRS_BUILD += $(wildcard dph/dph-prim-interface)
80 SUBDIRS_BUILD += $(wildcard dph/dph-prim-seq)
81 SUBDIRS_BUILD += $(wildcard dph/dph-prim-par)
82 SUBDIRS_BUILD += $(wildcard dph/dph)
85 SUBDIRS += $(SUBDIRS_BUILD)
87 # -----------------------------------------------------------------------------
90 space=$(empty) $(empty)
92 # -----------------------------------------------------------------------------
94 ifeq "$(ghc_ge_609)" "YES"
95 GhcLibHcOpts += -fno-warn-deprecated-flags
98 ifeq "$(RelocatableBuild)" "YES"
99 # On Windows we want to make moveable bindists, but we need to tell
100 # ghc-pkg where the haddock docs are. Therefore we completely ignore
101 # where the user tells us to put the haddock documentation and put it
102 # somewhere whose relative location we know. When installing we need
103 # to give Cabal a real path, though.
107 ilibexecdir = $$topdir
108 idynlibdir = $$topdir
110 idocdir = $$topdir/doc/libraries/$$pkg
111 ihaddockdir = $$topdir/doc/libraries/$$pkg
112 ihtmldir = $$httptopdir/doc/libraries/$$pkg
113 html_installed_root = $(prefix)/doc/libraries
115 # On non-Windows we can just give absolute paths all the time, and
116 # thus obey the htmldir that we are given.
120 ilibexecdir = $(libexecdir)
121 idynlibdir = $(dynlibdir)
122 idatadir = $(datadir)
123 idocdir = $(docdir)/libraries/$$pkg
124 ihaddockdir = $(htmldir)/libraries/$$pkg
125 ihtmldir = $(htmldir)/libraries/$$pkg
126 html_installed_root = $(htmldir)/libraries
129 ifneq "$(DOING_BIN_DIST)" "YES"
132 CONFIGURE_STAMP_EXTRAS :=
134 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
135 CONFIGURE_OPTS += --enable-library-profiling
136 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
139 ifneq "$(findstring $(space)dyn$(space), $(space)$(GhcLibWays)$(space))" ""
140 CONFIGURE_OPTS += --enable-shared
141 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-shared
144 ifeq "$(SplitObjs)" "YES"
145 CONFIGURE_OPTS += --enable-split-objs
146 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
149 ifneq "$(HSCOLOUR)" ""
150 CONFIGURE_OPTS += --with-hscolour=$(HSCOLOUR)
153 DEPLOYMENT_OPTS = $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) \
154 $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
161 HERE_ABS=$(FPTOOLS_TOP_ABS)/libraries
163 IFBUILDABLE=ifBuildable/ifBuildable $(HERE_ABS)/boot-packages
164 CABAL=$(HERE_ABS)/cabal-bin $(GHC) $(BOOTSTRAPPING_CONF)
165 BOOTSTRAPPING_CONF=$(HERE_ABS)/bootstrapping.conf
167 CABAL_GHC_FLAGS = -Wall
168 ifeq "$(ghc_ge_605)" "NO"
169 CABAL_GHC_FLAGS += -cpp
172 BOOTSTRAPPING_FLAGS = $(CABAL_GHC_FLAGS) -DCABAL_VERSION=1,3 -odir $(HERE_ABS)/bootstrapping -hidir $(HERE_ABS)/bootstrapping -i$(HERE_ABS)/Cabal -i$(HERE_ABS)/filepath
176 boot: ifBuildable/ifBuildable cabal-bin $(BOOTSTRAPPING_CONF)
178 cabal-bin: cabal-bin.hs
179 $(GHC) $(BOOTSTRAPPING_FLAGS) --make cabal-bin -o cabal-bin
181 $(BOOTSTRAPPING_CONF): cabal-bin
183 -cd filepath && $(CABAL) clean --distpref=dist-bootstrapping
184 cd filepath && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --package-db=$@.tmp
185 cd filepath && $(CABAL) build --distpref=dist-bootstrapping
186 cd filepath && $(CABAL) install --distpref=dist-bootstrapping --inplace
187 -cd Cabal && $(CABAL) clean --distpref=dist-bootstrapping
188 cd Cabal && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --package-db=$@.tmp
189 cd Cabal && $(CABAL) build --distpref=dist-bootstrapping
190 cd Cabal && $(CABAL) install --distpref=dist-bootstrapping --inplace
193 installPackage/installPackage: installPackage.hs
194 -$(RM) -rf installPackage
196 $(CP) installPackage.hs installPackage/
197 cd installPackage && $(FPTOOLS_TOP_ABS)/compiler/stage1/ghc-inplace \
198 --make installPackage -o installPackage \
201 ifBuildable/ifBuildable: ifBuildable.hs
202 -$(RM) -rf ifBuildable
204 $(CP) ifBuildable.hs ifBuildable/
206 cd ifBuildable && ../$(HC) -Wall --make ifBuildable -o ifBuildable \
209 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
212 .PHONY: all build configure
216 ifeq "$(HADDOCK_DOCS)" "YES"
220 .PHONY: rebuild.library.%
221 .PHONY: remake.library.%
223 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
224 rebuild.library.%: clean.library.% build.library.%
226 $(foreach SUBDIR,$(SUBDIRS),remake.library.$(SUBDIR)):\
227 remake.library.%: clean.library.% make.library.%
229 # NB. we're depending on make chasing dependencies from left to right here.
230 # This bit goes wrong with 'make -j'.
231 build: $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR)) \
232 installPackage/installPackage
234 configure: $(foreach SUBDIR,$(SUBDIRS), \
235 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
237 .PHONY: build.library.%
238 .PHONY: make.library.%
240 # We should depend on %/%.cabal here (and in other rules), but make
241 # makes that difficult.
243 # We put non-existant paths in when configuring, as we require that
244 # builds don't depend on these paths when making bindists.
246 # We rely on all the CONFIGURE_ARGS being quoted with '...', and there
247 # being no 's inside the values.
248 FLAGGED_CONFIGURE_ARGS = $(subst $(space)',\
249 $(space)--configure-option=',\
250 $(space)$(CONFIGURE_ARGS))
252 ifeq "$(Windows)" "YES"
253 NONEXISTENT=c:/NONEXISTENT
255 NONEXISTENT=/NONEXISTENT
258 ALL_CONFIGURE_FLAGS = \
260 --prefix=$(NONEXISTENT) \
261 --bindir=$(NONEXISTENT) \
262 --libdir=$(NONEXISTENT) \
263 --libsubdir='$$pkgid' \
264 --libexecdir=$(NONEXISTENT) \
265 --datadir=$(NONEXISTENT) \
266 --docdir=$(NONEXISTENT) \
267 --haddockdir=$(NONEXISTENT) \
268 --htmldir=$(NONEXISTENT) \
269 --with-compiler=$(FPTOOLS_TOP_ABS)/compiler/stage1/ghc-inplace \
270 --with-hc-pkg=$(FPTOOLS_TOP_ABS)/utils/ghc-pkg/ghc-pkg-inplace \
271 --with-hsc2hs=$(FPTOOLS_TOP_ABS)/utils/hsc2hs/hsc2hs-inplace \
273 --haddock-options="--use-contents=../index.html \
274 --use-index=../doc-index.html" \
275 $(FLAGGED_CONFIGURE_ARGS) \
276 --configure-option=--with-cc=$(CC)
278 $(foreach SUBDIR,$(SUBDIRS), \
279 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
280 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: cabal-bin
281 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
282 $(MKDIRHIER) `dirname $@`
283 ( cd $* && $(CABAL) configure $(ALL_CONFIGURE_FLAGS) ) \
284 && touch $@ || touch $*/unbuildable
285 # We don't touch $@ if configure failed as we would prefer to try
286 # configuring it next time round, rather than assuming it'll still fail.
287 # This is particularly important for bootlibs, where failure means the
290 # Build the library using 'make'
291 # We re-run 'setup makefile' each time, just in case any preprocessing
292 # needs to be done. However, we're careful not to overwrite GNUmakefile
293 # if it hasn't changed, so that dependency-generation isn't forced
295 # Packages in $(SUBDIRS_BUILD) need to use the build.* rules instead of
296 # make.*, so filter them out and use an alternate rule below instead.
297 $(foreach SUBDIR,$(filter-out $(SUBDIRS_BUILD),$(SUBDIRS)),make.library.$(SUBDIR)):\
298 make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
299 cabal-bin ifBuildable/ifBuildable
300 if $(IFBUILDABLE) $*; then \
302 cmp -s $(MAKEFILE_LOCAL) Makefile.local || cp $(MAKEFILE_LOCAL) .; \
303 mv GNUmakefile GNUmakefile.tmp; \
304 $(CABAL) makefile -f GNUmakefile; \
305 cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
306 $(MAKE) $(MFLAGS) && \
307 $(CABAL) register --inplace; \
310 MAKEFILE_LOCAL = $(FPTOOLS_TOP_ABS)/libraries/Makefile.local
312 # Alternate rule, as described above
313 $(foreach SUBDIR,$(SUBDIRS_BUILD),make.library.$(SUBDIR)):\
314 make.library.%: build.library.%
316 # Build the library using 'setup build' (not the default)
317 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
318 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
319 cabal-bin ifBuildable/ifBuildable
320 if $(IFBUILDABLE) $*; then \
322 $(CABAL) build $(addprefix --ghc-option=,$(GhcLibHcOpts)); \
323 $(CABAL) register --inplace; \
330 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
331 sh gen_contents_index --inplace
333 # Making hyperlinked source only works if we have hscolour
334 ifneq "$(HSCOLOUR)" ""
335 CABAL_HADDOCK_FLAGS=--hyperlink-source
338 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
339 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
340 cabal-bin ifBuildable/ifBuildable
341 if $(IFBUILDABLE) $*; then \
342 cd $* && $(CABAL) haddock --html-location='../$$pkg' \
343 $(CABAL_HADDOCK_FLAGS); \
345 ifneq "$(HSCOLOUR)" ""
346 # We use */src rather than $*/src due to the $(INTEGER_LIBRARY)/integer
348 if $(IFBUILDABLE) $*; then cp hscolour.css $*/dist/doc/html/*/src/; fi
351 .PHONY: distclean clean clean.library.%
355 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
356 $(RM) -rf bootstrapping/*
357 $(RM) -f bootstrapping.conf bootstrapping.conf.old
358 $(RM) -f bootstrapping.conf.tmp bootstrapping.conf.tmp.old
360 $(RM) -rf ifBuildable
361 $(RM) -rf installPackage
362 $(RM) -f libraries.txt index.html doc-index.html doc-index*.html
363 $(RM) -f haddock* *.gif
366 $(RM) $(foreach lib, $(SUBDIRS), $(lib)/.depend $(lib)/.depend.bak)
368 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
370 $(RM) -f stamp/configure.library.*.$* $*/unbuildable
371 -cd $* && $(CABAL) clean
372 -cd $* && $(CABAL) clean --distpref=dist-bootstrapping
373 $(RM) -f $*/Setup $*/Setup.exe $*/Setup.hi $*/Setup.o
374 $(RM) $*/GNUmakefile $*/Makefile.local
377 # -----------------------------------------------------------------------------
379 .PHONY: install install-docs install.library.%
381 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
382 ifeq "$(HADDOCK_DOCS)" "YES"
383 $(INSTALL_DIR) $(DESTDIR)$(html_installed_root)
384 $(INSTALL_DATA) index.html doc-index*.html $(DESTDIR)$(html_installed_root)
385 $(INSTALL_SCRIPT) gen_contents_index $(DESTDIR)$(html_installed_root)
387 $(INSTALL_DATA) base/dist/doc/html/*/*.css $(DESTDIR)$(html_installed_root)
388 $(INSTALL_DATA) base/dist/doc/html/*/*.js $(DESTDIR)$(html_installed_root)
389 $(INSTALL_DATA) base/dist/doc/html/*/*.gif $(DESTDIR)$(html_installed_root)
392 # Cabal doesn't let us ask to install docs only, so do nothing here
396 # Ideally this would depend on a stamp/build.library.%, but if it does
397 # then we can't change the libraries and then just rerun make.
398 # Thus if you install without building then it will just break.
400 # prefix and (on Windows) htmldir use $topdir when configuring, so we
401 # need to tell installPackage the real path to use when installing.
403 # We also need to pass all the other directories in, as they can be
404 # overridden when installing a bindist.
406 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
407 install.library.%: installPackage/installPackage ifBuildable/ifBuildable
408 if $(IFBUILDABLE) $*; then \
410 $(FPTOOLS_TOP_ABS)/libraries/installPackage/installPackage install '$(GHC_PKG_PROG)' '$(DESTDIR)$(libdir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idynlibdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(ihaddockdir)' ; \
413 .PHONY: binary-dist binary-dist.library.%
415 BIN_DIST_LIBDIR=$(BIN_DIST_DIR)/libraries
417 binary-dist: $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)) \
418 installPackage/installPackage
419 mkdir $(BIN_DIST_LIBDIR)/installPackage
420 cp installPackage/installPackage $(BIN_DIST_LIBDIR)/installPackage
421 mkdir $(BIN_DIST_LIBDIR)/ifBuildable
422 cp ifBuildable/ifBuildable $(BIN_DIST_LIBDIR)/ifBuildable
423 cp Makefile $(BIN_DIST_LIBDIR)
424 ifeq "$(HADDOCK_DOCS)" "YES"
425 cp gen_contents_index $(BIN_DIST_LIBDIR)
426 cp index.html $(BIN_DIST_LIBDIR)
427 cp doc-index*.html $(BIN_DIST_LIBDIR)
429 cp -pR stamp $(BIN_DIST_LIBDIR)
431 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
432 binary-dist.library.%:
433 if $(IFBUILDABLE) $*; then \
434 $(MKDIRHIER) $(BIN_DIST_LIBDIR)/$*; \
436 cp $*.cabal $(BIN_DIST_LIBDIR)/$* && \
437 cp LICENSE $(BIN_DIST_LIBDIR)/$* && \
438 cp -R dist $(BIN_DIST_LIBDIR)/$* && \
439 $(FIND) . -name "*.buildinfo" -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
440 $(FIND) . -name unbuildable -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
441 (cp -RL include $(BIN_DIST_LIBDIR)/$* || true) && \
442 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
443 \( -name "*_split" -o -name "autogen" \) | xargs rm -rf && \
444 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
445 \( \( -name "*.o" -o -name "*.p_o" \) -a ! -name "HS*" \) \
449 # Ignore some doc targets that we don't support
450 # The root recurses into us when these targets are made
451 .PHONY: html-no-chunks chm HxS fo dvi ps pdf
452 html-no-chunks chm HxS fo dvi ps pdf: