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 rebuild.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 = base array packedstring containers bytestring
42 SUBDIRS += 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 readline 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 += $(wildcard ndp)
80 # -----------------------------------------------------------------------------
83 space=$(empty) $(empty)
85 # -----------------------------------------------------------------------------
87 ifeq "$(RelocatableBuild)" "YES"
88 # On Windows we want to make moveable bindists, but we need to tell
89 # ghc-pkg where the haddock docs are. Therefore we completely ignore
90 # where the user tells us to put the haddock documentation and put it
91 # somewhere whose relative location we know. When installing we need
92 # to give Cabal a real path, though.
96 ilibexecdir = $$topdir
98 idocdir = $$topdir/doc/libraries/$$pkg
99 iinterfacedir = $$topdir/doc/libraries/$$pkg
100 ihtmldir = $$httptopdir/doc/libraries/$$pkg
101 html_installed_root = $(prefix)/doc/libraries
103 # On non-Windows we can just give absolute paths all the time, and
104 # thus obey the htmldir that we are given.
108 ilibexecdir = $(libexecdir)
109 idatadir = $(datadir)
110 idocdir = $(docdir)/libraries/$$pkg
111 iinterfacedir = $(htmldir)/libraries/$$pkg
112 ihtmldir = $(htmldir)/libraries/$$pkg
113 html_installed_root = $(htmldir)/libraries
116 ifneq "$(DOING_BIN_DIST)" "YES"
119 CONFIGURE_STAMP_EXTRAS :=
121 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
122 CONFIGURE_OPTS += --enable-library-profiling
123 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
126 ifneq "$(findstring $(space)dyn$(space), $(space)$(GhcLibWays)$(space))" ""
127 CONFIGURE_OPTS += --enable-shared
128 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-shared
131 ifeq "$(SplitObjs)" "YES"
132 CONFIGURE_OPTS += --enable-split-objs
133 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
136 ifneq "$(HSCOLOUR)" ""
137 CONFIGURE_OPTS += --with-hscolour=$(HSCOLOUR)
140 BOOTSTRAP_LIBS = Cabal filepath
141 BOOTSTRAP_STAMPS = $(addprefix stamp/bootstrapping.,$(BOOTSTRAP_LIBS))
142 BOOTSTRAP_INC_1_UP = -DCABAL_VERSION=1,3 $(addprefix -i../bootstrapping.,$(BOOTSTRAP_LIBS))
143 BOOTSTRAP_INC_2_UP = -DCABAL_VERSION=1,3 $(addprefix -i../../bootstrapping.,$(BOOTSTRAP_LIBS))
152 boot: $(BOOTSTRAP_STAMPS) ifBuildable/ifBuildable \
153 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup) \
154 installPackage/installPackage
156 # We build the Setup program in a setup subdirectory to stop it trying
157 # to use bits of base and Cabal when we build those packages.
158 # This also makes it slightly easier to clean.
160 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
162 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
163 %/setup/Setup: $(BOOTSTRAP_STAMPS)
166 $(CP) $*/Setup.*hs $*/setup
167 cd $*/setup && $(GHC) -Wall -cpp --make Setup.*hs -o Setup \
168 $(BOOTSTRAP_INC_2_UP)
170 installPackage/installPackage: installPackage.hs $(BOOTSTRAP_STAMPS)
171 -$(RM) -rf installPackage
173 $(CP) installPackage.hs installPackage/
174 cd installPackage && $(GHC) -Wall -cpp \
175 --make installPackage -o installPackage \
176 $(BOOTSTRAP_INC_1_UP)
178 ifBuildable/ifBuildable: ifBuildable.hs
179 -$(RM) -rf ifBuildable
181 $(CP) ifBuildable.hs ifBuildable/
182 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
184 $(BOOTSTRAP_STAMPS): stamp/bootstrapping.%:
185 $(RM) -rf bootstrapping.$*
186 $(CP) -R $* bootstrapping.$*
187 $(FIND) bootstrapping.$* \( -name "*.o" -o -name "*.hi" \) \
191 .PHONY: all build configure
195 ifeq "$(HADDOCK_DOCS)" "YES"
199 .PHONY: rebuild.library.%
201 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
202 rebuild.library.%: clean.library.% make.library.%
204 # NB. we're depending on make chasing dependencies from left to right here.
205 # This bit goes wrong with 'make -j'.
206 build: $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR))
207 build: installPackage/installPackage
209 configure: $(foreach SUBDIR,$(SUBDIRS), \
210 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
212 .PHONY: build.library.%
213 .PHONY: make.library.%
215 # We should depend on %/%.cabal here (and in other rules), but make
216 # makes that difficult.
218 # We put non-existant paths in when configuring, as we require that
219 # builds don't depend on these paths when making bindists.
221 # We rely on all the CONFIGURE_ARGS being quoted with '...', and there
222 # being no 's inside the values.
223 FLAGGED_CONFIGURE_ARGS = $(subst $(space)',\
224 $(space)--configure-option=',\
225 $(space)$(CONFIGURE_ARGS))
227 $(foreach SUBDIR,$(SUBDIRS), \
228 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
229 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
230 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
231 ( cd $* && setup/Setup configure \
233 --prefix=/NONEXISTANT \
234 --bindir=/NONEXISTANT \
235 --libdir=/NONEXISTANT \
236 --libsubdir='$$pkgid' \
237 --libexecdir=/NONEXISTANT \
238 --datadir=/NONEXISTANT \
239 --docdir=/NONEXISTANT \
240 --interfacedir=/NONEXISTANT \
241 --htmldir=/NONEXISTANT \
242 --with-compiler=../../compiler/stage1/ghc-inplace \
243 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \
244 --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace \
246 --haddock-options="--use-contents=../index.html \
247 --use-index=../doc-index.html" \
248 $(FLAGGED_CONFIGURE_ARGS) \
249 --configure-option=--with-cc=$(CC) ) \
250 && touch $@ || touch $*/unbuildable
251 # We don't touch $@ if configure failed as we would prefer to try
252 # configuring it next time round, rather than assuming it'll still fail.
253 # This is particularly important for bootlibs, where failure means the
256 # Build the library using 'make'
257 # We re-run 'setup makefile' each time, just in case any preprocessing
258 # needs to be done. However, we're careful not to overwrite GNUmakefile
259 # if it hasn't changed, so that dependency-generation isn't forced
261 $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR)):\
262 make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
263 %/setup/Setup ifBuildable/ifBuildable
264 if ifBuildable/ifBuildable $*; then \
266 cmp -s ../Makefile.local Makefile.local || cp ../Makefile.local .; \
267 mv GNUmakefile GNUmakefile.tmp; \
268 setup/Setup makefile -f GNUmakefile; \
269 cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
270 $(MAKE) $(MFLAGS) && \
271 ../installPackage/installPackage register --inplace; \
274 # Build the library using 'setup build' (not the default)
275 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
276 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
277 %/setup/Setup ifBuildable/ifBuildable
278 if ifBuildable/ifBuildable $*; then \
280 setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts)); \
287 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
288 sh gen_contents_index --inplace
290 # Making hyperlinked source only works if we have hscolour
291 ifneq "$(HSCOLOUR)" ""
292 CABAL_HADDOCK_FLAGS=--hyperlink-source
295 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
296 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
297 %/setup/Setup ifBuildable/ifBuildable
298 if ifBuildable/ifBuildable $*; then \
299 cd $* && setup/Setup haddock --html-location='../$$pkg' \
300 $(CABAL_HADDOCK_FLAGS); \
302 ifneq "$(HSCOLOUR)" ""
303 if ifBuildable/ifBuildable $*; then cp hscolour.css $*/dist/doc/html/$*/src/; fi
306 .PHONY: distclean clean clean.library.%
310 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
311 $(RM) -f stamp/bootstrapping.*
312 $(RM) -rf bootstrapping.*
313 $(RM) -rf ifBuildable
314 $(RM) -rf installPackage
315 $(RM) -f libraries.txt index.html doc-index.html doc-index*.html
316 $(RM) -f haddock* *.gif
319 $(RM) $(foreach lib, $(SUBDIRS), $(lib)/.depend $(lib)/.depend.bak)
321 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
323 $(RM) -f stamp/configure.library.*.$* $*/unbuildable
324 -cd $* && setup/Setup clean
326 $(RM) $*/GNUmakefile $*/Makefile.local
329 # -----------------------------------------------------------------------------
331 .PHONY: install install-docs install.library.%
333 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
334 ifeq "$(HADDOCK_DOCS)" "YES"
335 $(INSTALL_DIR) $(DESTDIR)$(html_installed_root)
336 $(INSTALL_DATA) index.html doc-index*.html $(DESTDIR)$(html_installed_root)
337 $(INSTALL_SCRIPT) gen_contents_index $(DESTDIR)$(html_installed_root)
339 $(INSTALL_DATA) base/dist/doc/html/*/*.css $(DESTDIR)$(html_installed_root)
340 $(INSTALL_DATA) base/dist/doc/html/*/*.js $(DESTDIR)$(html_installed_root)
341 $(INSTALL_DATA) base/dist/doc/html/*/*.gif $(DESTDIR)$(html_installed_root)
344 # Cabal doesn't let us ask to install docs only, so do nothing here
348 # Ideally this would depend on a stamp/build.library.%, but if it does
349 # then we can't change the libraries and then just rerun make.
350 # Thus if you install without building then it will just break.
352 # prefix and (on Windows) htmldir use $topdir when configuring, so we
353 # need to tell installPackage the real path to use when installing.
355 # We also need to pass all the other directories in, as they can be
356 # overridden when installing a bindist.
358 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
359 install.library.%: installPackage/installPackage ifBuildable/ifBuildable
360 if ifBuildable/ifBuildable $*; then \
362 ../installPackage/installPackage install '$(GHC_PKG_PROG)' '$(DESTDIR)$(libdir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(iinterfacedir)' ; \
365 .PHONY: binary-dist binary-dist.library.%
367 BIN_DIST_LIBDIR=$(BIN_DIST_DIR)/libraries
369 binary-dist: $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR))
370 mkdir $(BIN_DIST_LIBDIR)/installPackage
371 cp installPackage/installPackage $(BIN_DIST_LIBDIR)/installPackage
372 mkdir $(BIN_DIST_LIBDIR)/ifBuildable
373 cp ifBuildable/ifBuildable $(BIN_DIST_LIBDIR)/ifBuildable
374 cp Makefile $(BIN_DIST_LIBDIR)
375 ifeq "$(HADDOCK_DOCS)" "YES"
376 cp gen_contents_index $(BIN_DIST_LIBDIR)
377 cp index.html $(BIN_DIST_LIBDIR)
378 cp doc-index*.html $(BIN_DIST_LIBDIR)
380 cp -pR stamp $(BIN_DIST_LIBDIR)
382 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
383 binary-dist.library.%:
384 if ifBuildable/ifBuildable $*; then \
385 $(MKDIRHIER) $(BIN_DIST_LIBDIR)/$*; \
387 cp $*.cabal $(BIN_DIST_LIBDIR)/$* && \
388 cp LICENSE $(BIN_DIST_LIBDIR)/$* && \
389 cp -R dist $(BIN_DIST_LIBDIR)/$* && \
390 $(FIND) . -name "*.buildinfo" -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
391 $(FIND) . -name unbuildable -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
392 (cp -RL include $(BIN_DIST_LIBDIR)/$* || true) && \
393 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
394 \( -name "*_split" -o -name "autogen" \) | xargs rm -rf && \
395 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
396 \( \( -name "*.o" -o -name "*.p_o" \) -a ! -name "HS*" \) \
400 # Ignore some doc targets that we don't support
401 # The root recurses into us when these targets are made
402 .PHONY: html-no-chunks chm HxS fo dvi ps pdf
403 html-no-chunks chm HxS fo dvi ps pdf: