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-seq)
80 SUBDIRS_BUILD += $(wildcard dph/dph-prim-par)
81 SUBDIRS_BUILD += $(wildcard dph/dph)
84 SUBDIRS += $(SUBDIRS_BUILD)
86 # -----------------------------------------------------------------------------
89 space=$(empty) $(empty)
91 # -----------------------------------------------------------------------------
93 ifeq "$(RelocatableBuild)" "YES"
94 # On Windows we want to make moveable bindists, but we need to tell
95 # ghc-pkg where the haddock docs are. Therefore we completely ignore
96 # where the user tells us to put the haddock documentation and put it
97 # somewhere whose relative location we know. When installing we need
98 # to give Cabal a real path, though.
102 ilibexecdir = $$topdir
103 idynlibdir = $$topdir
105 idocdir = $$topdir/doc/libraries/$$pkg
106 ihaddockdir = $$topdir/doc/libraries/$$pkg
107 ihtmldir = $$httptopdir/doc/libraries/$$pkg
108 html_installed_root = $(prefix)/doc/libraries
110 # On non-Windows we can just give absolute paths all the time, and
111 # thus obey the htmldir that we are given.
115 ilibexecdir = $(libexecdir)
116 idynlibdir = $(dynlibdir)
117 idatadir = $(datadir)
118 idocdir = $(docdir)/libraries/$$pkg
119 ihaddockdir = $(htmldir)/libraries/$$pkg
120 ihtmldir = $(htmldir)/libraries/$$pkg
121 html_installed_root = $(htmldir)/libraries
124 ifneq "$(DOING_BIN_DIST)" "YES"
127 CONFIGURE_STAMP_EXTRAS :=
129 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
130 CONFIGURE_OPTS += --enable-library-profiling
131 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
134 ifneq "$(findstring $(space)dyn$(space), $(space)$(GhcLibWays)$(space))" ""
135 CONFIGURE_OPTS += --enable-shared
136 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-shared
139 ifeq "$(SplitObjs)" "YES"
140 CONFIGURE_OPTS += --enable-split-objs
141 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
144 ifneq "$(HSCOLOUR)" ""
145 CONFIGURE_OPTS += --with-hscolour=$(HSCOLOUR)
148 BOOTSTRAP_LIBS = Cabal filepath
149 BOOTSTRAP_STAMPS = $(addprefix stamp/bootstrapping.,$(BOOTSTRAP_LIBS))
150 BOOTSTRAP_INC = -DCABAL_VERSION=1,3 $(addprefix -i$(FPTOOLS_TOP_ABS)/libraries/bootstrapping.,$(BOOTSTRAP_LIBS))
151 DEPLOYMENT_OPTS = $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) \
152 $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
161 boot: $(BOOTSTRAP_STAMPS) ifBuildable/ifBuildable \
162 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup) \
163 installPackage/installPackage
165 # We build the Setup program in a setup subdirectory to stop it trying
166 # to use bits of base and Cabal when we build those packages.
167 # This also makes it slightly easier to clean.
169 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
171 CABAL_GHC_FLAGS = -Wall
173 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
174 %/setup/Setup: $(BOOTSTRAP_STAMPS)
177 $(CP) $*/Setup.*hs $*/setup
178 cd $*/setup && $(GHC) $(CABAL_GHC_FLAGS) --make Setup.*hs -o Setup \
181 installPackage/installPackage: installPackage.hs $(BOOTSTRAP_STAMPS)
182 -$(RM) -rf installPackage
184 $(CP) installPackage.hs installPackage/
186 cd installPackage && ../$(HC) $(CABAL_GHC_FLAGS) \
187 --make installPackage -o installPackage \
188 $(BOOTSTRAP_INC) $(DEPLOYMENT_OPTS)
190 cd installPackage && $(GHC) $(CABAL_GHC_FLAGS) \
191 --make installPackage -o installPackage \
194 # TODO: The conditional is yucky, but we need to be able to build with stage1
195 # for bindists and as installPackages/ has no Makefile, it seems hard
196 # to make this nicer.
198 ifBuildable/ifBuildable: ifBuildable.hs
199 -$(RM) -rf ifBuildable
201 $(CP) ifBuildable.hs ifBuildable/
203 cd ifBuildable && ../$(HC) -Wall --make ifBuildable -o ifBuildable \
206 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
209 IFBUILDABLE=ifBuildable/ifBuildable $(FPTOOLS_TOP_ABS)/libraries/boot-packages
211 $(BOOTSTRAP_STAMPS): stamp/bootstrapping.%:
212 $(RM) -rf bootstrapping.$*
213 $(CP) -R $* bootstrapping.$*
214 $(FIND) bootstrapping.$* \( -name "*.o" -o -name "*.hi" \) \
218 .PHONY: all build configure
222 ifeq "$(HADDOCK_DOCS)" "YES"
226 .PHONY: rebuild.library.%
227 .PHONY: remake.library.%
229 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
230 rebuild.library.%: clean.library.% build.library.%
232 $(foreach SUBDIR,$(SUBDIRS),remake.library.$(SUBDIR)):\
233 remake.library.%: clean.library.% make.library.%
235 # NB. we're depending on make chasing dependencies from left to right here.
236 # This bit goes wrong with 'make -j'.
237 build: $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR))
238 build: installPackage/installPackage
240 configure: $(foreach SUBDIR,$(SUBDIRS), \
241 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
243 .PHONY: build.library.%
244 .PHONY: make.library.%
246 # We should depend on %/%.cabal here (and in other rules), but make
247 # makes that difficult.
249 # We put non-existant paths in when configuring, as we require that
250 # builds don't depend on these paths when making bindists.
252 # We rely on all the CONFIGURE_ARGS being quoted with '...', and there
253 # being no 's inside the values.
254 FLAGGED_CONFIGURE_ARGS = $(subst $(space)',\
255 $(space)--configure-option=',\
256 $(space)$(CONFIGURE_ARGS))
258 ifeq "$(Windows)" "YES"
259 NONEXISTENT=c:/NONEXISTENT
261 NONEXISTENT=/NONEXISTENT
264 ALL_CONFIGURE_FLAGS = \
266 --prefix=$(NONEXISTENT) \
267 --bindir=$(NONEXISTENT) \
268 --libdir=$(NONEXISTENT) \
269 --libsubdir='$$pkgid' \
270 --libexecdir=$(NONEXISTENT) \
271 --datadir=$(NONEXISTENT) \
272 --docdir=$(NONEXISTENT) \
273 --haddockdir=$(NONEXISTENT) \
274 --htmldir=$(NONEXISTENT) \
275 --with-compiler=$(FPTOOLS_TOP_ABS)/compiler/stage1/ghc-inplace \
276 --with-hc-pkg=$(FPTOOLS_TOP_ABS)/utils/ghc-pkg/ghc-pkg-inplace \
277 --with-hsc2hs=$(FPTOOLS_TOP_ABS)/utils/hsc2hs/hsc2hs-inplace \
279 --haddock-options="--use-contents=../index.html \
280 --use-index=../doc-index.html" \
281 $(FLAGGED_CONFIGURE_ARGS) \
282 --configure-option=--with-cc=$(CC)
284 $(foreach SUBDIR,$(SUBDIRS), \
285 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
286 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
287 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
288 $(MKDIRHIER) `dirname $@`
289 ( cd $* && setup/Setup configure $(ALL_CONFIGURE_FLAGS) ) \
290 && touch $@ || touch $*/unbuildable
291 # We don't touch $@ if configure failed as we would prefer to try
292 # configuring it next time round, rather than assuming it'll still fail.
293 # This is particularly important for bootlibs, where failure means the
296 # Build the library using 'make'
297 # We re-run 'setup makefile' each time, just in case any preprocessing
298 # needs to be done. However, we're careful not to overwrite GNUmakefile
299 # if it hasn't changed, so that dependency-generation isn't forced
301 # Packages in $(SUBDIRS_BUILD) need to use the build.* rules instead of
302 # make.*, so filter them out and use an alternate rule below instead.
303 $(foreach SUBDIR,$(filter-out $(SUBDIRS_BUILD),$(SUBDIRS)),make.library.$(SUBDIR)):\
304 make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
305 %/setup/Setup ifBuildable/ifBuildable installPackage/installPackage
306 if $(IFBUILDABLE) $*; then \
308 cmp -s $(MAKEFILE_LOCAL) Makefile.local || cp $(MAKEFILE_LOCAL) .; \
309 mv GNUmakefile GNUmakefile.tmp; \
310 setup/Setup makefile -f GNUmakefile; \
311 cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
312 $(MAKE) $(MFLAGS) && \
313 setup/Setup register --inplace; \
316 MAKEFILE_LOCAL = $(FPTOOLS_TOP_ABS)/libraries/Makefile.local
318 # Alternate rule, as described above
319 $(foreach SUBDIR,$(SUBDIRS_BUILD),make.library.$(SUBDIR)):\
320 make.library.%: build.library.%
322 # Build the library using 'setup build' (not the default)
323 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
324 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
325 %/setup/Setup ifBuildable/ifBuildable
326 if $(IFBUILDABLE) $*; then \
328 setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts)); \
329 setup/Setup register --inplace; \
336 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
337 sh gen_contents_index --inplace
339 # Making hyperlinked source only works if we have hscolour
340 ifneq "$(HSCOLOUR)" ""
341 CABAL_HADDOCK_FLAGS=--hyperlink-source
344 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
345 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
346 %/setup/Setup ifBuildable/ifBuildable
347 if $(IFBUILDABLE) $*; then \
348 cd $* && setup/Setup haddock --html-location='../$$pkg' \
349 $(CABAL_HADDOCK_FLAGS); \
351 ifneq "$(HSCOLOUR)" ""
352 # We use */src rather than $*/src due to the $(INTEGER_LIBRARY)/integer
354 if $(IFBUILDABLE) $*; then cp hscolour.css $*/dist/doc/html/*/src/; fi
357 .PHONY: distclean clean clean.library.%
361 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
362 $(RM) -f stamp/bootstrapping.*
363 $(RM) -rf bootstrapping.*
364 $(RM) -rf ifBuildable
365 $(RM) -rf installPackage
366 $(RM) -f libraries.txt index.html doc-index.html doc-index*.html
367 $(RM) -f haddock* *.gif
370 $(RM) $(foreach lib, $(SUBDIRS), $(lib)/.depend $(lib)/.depend.bak)
372 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
374 $(RM) -f stamp/configure.library.*.$* $*/unbuildable
375 -cd $* && setup/Setup clean
377 $(RM) $*/GNUmakefile $*/Makefile.local
380 # -----------------------------------------------------------------------------
382 .PHONY: install install-docs install.library.%
384 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
385 ifeq "$(HADDOCK_DOCS)" "YES"
386 $(INSTALL_DIR) $(DESTDIR)$(html_installed_root)
387 $(INSTALL_DATA) index.html doc-index*.html $(DESTDIR)$(html_installed_root)
388 $(INSTALL_SCRIPT) gen_contents_index $(DESTDIR)$(html_installed_root)
390 $(INSTALL_DATA) base/dist/doc/html/*/*.css $(DESTDIR)$(html_installed_root)
391 $(INSTALL_DATA) base/dist/doc/html/*/*.js $(DESTDIR)$(html_installed_root)
392 $(INSTALL_DATA) base/dist/doc/html/*/*.gif $(DESTDIR)$(html_installed_root)
395 # Cabal doesn't let us ask to install docs only, so do nothing here
399 # Ideally this would depend on a stamp/build.library.%, but if it does
400 # then we can't change the libraries and then just rerun make.
401 # Thus if you install without building then it will just break.
403 # prefix and (on Windows) htmldir use $topdir when configuring, so we
404 # need to tell installPackage the real path to use when installing.
406 # We also need to pass all the other directories in, as they can be
407 # overridden when installing a bindist.
409 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
410 install.library.%: installPackage/installPackage ifBuildable/ifBuildable
411 if $(IFBUILDABLE) $*; then \
413 $(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)' ; \
416 .PHONY: binary-dist binary-dist.library.%
418 BIN_DIST_LIBDIR=$(BIN_DIST_DIR)/libraries
420 binary-dist: $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR))
421 mkdir $(BIN_DIST_LIBDIR)/installPackage
422 cp installPackage/installPackage $(BIN_DIST_LIBDIR)/installPackage
423 mkdir $(BIN_DIST_LIBDIR)/ifBuildable
424 cp ifBuildable/ifBuildable $(BIN_DIST_LIBDIR)/ifBuildable
425 cp Makefile $(BIN_DIST_LIBDIR)
426 ifeq "$(HADDOCK_DOCS)" "YES"
427 cp gen_contents_index $(BIN_DIST_LIBDIR)
428 cp index.html $(BIN_DIST_LIBDIR)
429 cp doc-index*.html $(BIN_DIST_LIBDIR)
431 cp -pR stamp $(BIN_DIST_LIBDIR)
433 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
434 binary-dist.library.%:
435 if $(IFBUILDABLE) $*; then \
436 $(MKDIRHIER) $(BIN_DIST_LIBDIR)/$*; \
438 cp $*.cabal $(BIN_DIST_LIBDIR)/$* && \
439 cp LICENSE $(BIN_DIST_LIBDIR)/$* && \
440 cp -R dist $(BIN_DIST_LIBDIR)/$* && \
441 $(FIND) . -name "*.buildinfo" -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
442 $(FIND) . -name unbuildable -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
443 (cp -RL include $(BIN_DIST_LIBDIR)/$* || true) && \
444 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
445 \( -name "*_split" -o -name "autogen" \) | xargs rm -rf && \
446 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
447 \( \( -name "*.o" -o -name "*.p_o" \) -a ! -name "HS*" \) \
451 # Ignore some doc targets that we don't support
452 # The root recurses into us when these targets are made
453 .PHONY: html-no-chunks chm HxS fo dvi ps pdf
454 html-no-chunks chm HxS fo dvi ps pdf: