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 += $(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
99 idocdir = $$topdir/doc/libraries/$$pkg
100 ihaddockdir = $$topdir/doc/libraries/$$pkg
101 ihtmldir = $$httptopdir/doc/libraries/$$pkg
102 html_installed_root = $(prefix)/doc/libraries
104 # On non-Windows we can just give absolute paths all the time, and
105 # thus obey the htmldir that we are given.
109 ilibexecdir = $(libexecdir)
110 idynlibdir = $(dynlibdir)
111 idatadir = $(datadir)
112 idocdir = $(docdir)/libraries/$$pkg
113 ihaddockdir = $(htmldir)/libraries/$$pkg
114 ihtmldir = $(htmldir)/libraries/$$pkg
115 html_installed_root = $(htmldir)/libraries
118 ifneq "$(DOING_BIN_DIST)" "YES"
121 CONFIGURE_STAMP_EXTRAS :=
123 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
124 CONFIGURE_OPTS += --enable-library-profiling
125 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
128 ifneq "$(findstring $(space)dyn$(space), $(space)$(GhcLibWays)$(space))" ""
129 CONFIGURE_OPTS += --enable-shared
130 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-shared
133 ifeq "$(SplitObjs)" "YES"
134 CONFIGURE_OPTS += --enable-split-objs
135 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
138 ifneq "$(HSCOLOUR)" ""
139 CONFIGURE_OPTS += --with-hscolour=$(HSCOLOUR)
142 BOOTSTRAP_LIBS = Cabal filepath
143 BOOTSTRAP_STAMPS = $(addprefix stamp/bootstrapping.,$(BOOTSTRAP_LIBS))
144 BOOTSTRAP_INC_1_UP = -DCABAL_VERSION=1,3 $(addprefix -i../bootstrapping.,$(BOOTSTRAP_LIBS))
145 BOOTSTRAP_INC_2_UP = -DCABAL_VERSION=1,3 $(addprefix -i../../bootstrapping.,$(BOOTSTRAP_LIBS))
146 DEPLOYMENT_OPTS = $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) \
147 $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
156 boot: $(BOOTSTRAP_STAMPS) ifBuildable/ifBuildable \
157 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup) \
158 installPackage/installPackage
160 # We build the Setup program in a setup subdirectory to stop it trying
161 # to use bits of base and Cabal when we build those packages.
162 # This also makes it slightly easier to clean.
164 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
166 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
167 %/setup/Setup: $(BOOTSTRAP_STAMPS)
170 $(CP) $*/Setup.*hs $*/setup
171 cd $*/setup && $(GHC) -Wall -cpp --make Setup.*hs -o Setup \
172 $(BOOTSTRAP_INC_2_UP)
174 installPackage/installPackage: installPackage.hs $(BOOTSTRAP_STAMPS)
175 -$(RM) -rf installPackage
177 $(CP) installPackage.hs installPackage/
179 cd installPackage && ../$(HC) -Wall -cpp \
180 --make installPackage -o installPackage \
181 $(BOOTSTRAP_INC_1_UP) $(DEPLOYMENT_OPTS)
183 cd installPackage && $(GHC) -Wall -cpp \
184 --make installPackage -o installPackage \
185 $(BOOTSTRAP_INC_1_UP)
187 # TODO: The conditional is yucky, but we need to be able to build with stage1
188 # for bindists and as installPackages/ has no Makefile, it seems hard
189 # to make this nicer.
191 ifBuildable/ifBuildable: ifBuildable.hs
192 -$(RM) -rf ifBuildable
194 $(CP) ifBuildable.hs ifBuildable/
196 cd ifBuildable && ../$(HC) -Wall --make ifBuildable -o ifBuildable \
199 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
202 $(BOOTSTRAP_STAMPS): stamp/bootstrapping.%:
203 $(RM) -rf bootstrapping.$*
204 $(CP) -R $* bootstrapping.$*
205 $(FIND) bootstrapping.$* \( -name "*.o" -o -name "*.hi" \) \
209 .PHONY: all build configure
213 ifeq "$(HADDOCK_DOCS)" "YES"
217 .PHONY: rebuild.library.%
218 .PHONY: remake.library.%
220 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
221 rebuild.library.%: clean.library.% build.library.%
223 $(foreach SUBDIR,$(SUBDIRS),remake.library.$(SUBDIR)):\
224 remake.library.%: clean.library.% make.library.%
226 # NB. we're depending on make chasing dependencies from left to right here.
227 # This bit goes wrong with 'make -j'.
228 build: $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR))
229 build: installPackage/installPackage
231 configure: $(foreach SUBDIR,$(SUBDIRS), \
232 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
234 .PHONY: build.library.%
235 .PHONY: make.library.%
237 # We should depend on %/%.cabal here (and in other rules), but make
238 # makes that difficult.
240 # We put non-existant paths in when configuring, as we require that
241 # builds don't depend on these paths when making bindists.
243 # We rely on all the CONFIGURE_ARGS being quoted with '...', and there
244 # being no 's inside the values.
245 FLAGGED_CONFIGURE_ARGS = $(subst $(space)',\
246 $(space)--configure-option=',\
247 $(space)$(CONFIGURE_ARGS))
249 $(foreach SUBDIR,$(SUBDIRS), \
250 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
251 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
252 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
253 ( cd $* && setup/Setup configure \
255 --prefix=/NONEXISTANT \
256 --bindir=/NONEXISTANT \
257 --libdir=/NONEXISTANT \
258 --libsubdir='$$pkgid' \
259 --libexecdir=/NONEXISTANT \
260 --datadir=/NONEXISTANT \
261 --docdir=/NONEXISTANT \
262 --haddockdir=/NONEXISTANT \
263 --htmldir=/NONEXISTANT \
264 --with-compiler=../../compiler/stage1/ghc-inplace \
265 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \
266 --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace \
268 --haddock-options="--use-contents=../index.html \
269 --use-index=../doc-index.html" \
270 $(FLAGGED_CONFIGURE_ARGS) \
271 --configure-option=--with-cc=$(CC) ) \
272 && touch $@ || touch $*/unbuildable
273 # We don't touch $@ if configure failed as we would prefer to try
274 # configuring it next time round, rather than assuming it'll still fail.
275 # This is particularly important for bootlibs, where failure means the
278 # Build the library using 'make'
279 # We re-run 'setup makefile' each time, just in case any preprocessing
280 # needs to be done. However, we're careful not to overwrite GNUmakefile
281 # if it hasn't changed, so that dependency-generation isn't forced
283 $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR)):\
284 make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
285 %/setup/Setup ifBuildable/ifBuildable installPackage/installPackage
286 if ifBuildable/ifBuildable $*; then \
288 cmp -s ../Makefile.local Makefile.local || cp ../Makefile.local .; \
289 mv GNUmakefile GNUmakefile.tmp; \
290 setup/Setup makefile -f GNUmakefile; \
291 cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
292 $(MAKE) $(MFLAGS) && \
293 ../installPackage/installPackage register --inplace; \
296 # Build the library using 'setup build' (not the default)
297 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
298 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
299 %/setup/Setup ifBuildable/ifBuildable
300 if ifBuildable/ifBuildable $*; then \
302 setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts)); \
309 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
310 sh gen_contents_index --inplace
312 # Making hyperlinked source only works if we have hscolour
313 ifneq "$(HSCOLOUR)" ""
314 CABAL_HADDOCK_FLAGS=--hyperlink-source
317 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
318 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
319 %/setup/Setup ifBuildable/ifBuildable
320 if ifBuildable/ifBuildable $*; then \
321 cd $* && setup/Setup haddock --html-location='../$$pkg' \
322 $(CABAL_HADDOCK_FLAGS); \
324 ifneq "$(HSCOLOUR)" ""
325 # We use */src rather than $*/src due to the $(INTEGER_LIBRARY)/integer
327 if ifBuildable/ifBuildable $*; then cp hscolour.css $*/dist/doc/html/*/src/; fi
330 .PHONY: distclean clean clean.library.%
334 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
335 $(RM) -f stamp/bootstrapping.*
336 $(RM) -rf bootstrapping.*
337 $(RM) -rf ifBuildable
338 $(RM) -rf installPackage
339 $(RM) -f libraries.txt index.html doc-index.html doc-index*.html
340 $(RM) -f haddock* *.gif
343 $(RM) $(foreach lib, $(SUBDIRS), $(lib)/.depend $(lib)/.depend.bak)
345 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
347 $(RM) -f stamp/configure.library.*.$* $*/unbuildable
348 -cd $* && setup/Setup clean
350 $(RM) $*/GNUmakefile $*/Makefile.local
353 # -----------------------------------------------------------------------------
355 .PHONY: install install-docs install.library.%
357 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
358 ifeq "$(HADDOCK_DOCS)" "YES"
359 $(INSTALL_DIR) $(DESTDIR)$(html_installed_root)
360 $(INSTALL_DATA) index.html doc-index*.html $(DESTDIR)$(html_installed_root)
361 $(INSTALL_SCRIPT) gen_contents_index $(DESTDIR)$(html_installed_root)
363 $(INSTALL_DATA) base/dist/doc/html/*/*.css $(DESTDIR)$(html_installed_root)
364 $(INSTALL_DATA) base/dist/doc/html/*/*.js $(DESTDIR)$(html_installed_root)
365 $(INSTALL_DATA) base/dist/doc/html/*/*.gif $(DESTDIR)$(html_installed_root)
368 # Cabal doesn't let us ask to install docs only, so do nothing here
372 # Ideally this would depend on a stamp/build.library.%, but if it does
373 # then we can't change the libraries and then just rerun make.
374 # Thus if you install without building then it will just break.
376 # prefix and (on Windows) htmldir use $topdir when configuring, so we
377 # need to tell installPackage the real path to use when installing.
379 # We also need to pass all the other directories in, as they can be
380 # overridden when installing a bindist.
382 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
383 install.library.%: installPackage/installPackage ifBuildable/ifBuildable
384 if ifBuildable/ifBuildable $*; then \
386 ../installPackage/installPackage install '$(GHC_PKG_PROG)' '$(DESTDIR)$(libdir)/package.conf' '$(DESTDIR)' '$(prefix)' '$(iprefix)' '$(ibindir)' '$(ilibdir)' '$(ilibexecdir)' '$(idynlibdir)' '$(idatadir)' '$(idocdir)' '$(ihtmldir)' '$(ihaddockdir)' ; \
389 .PHONY: binary-dist binary-dist.library.%
391 BIN_DIST_LIBDIR=$(BIN_DIST_DIR)/libraries
393 binary-dist: $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR))
394 mkdir $(BIN_DIST_LIBDIR)/installPackage
395 cp installPackage/installPackage $(BIN_DIST_LIBDIR)/installPackage
396 mkdir $(BIN_DIST_LIBDIR)/ifBuildable
397 cp ifBuildable/ifBuildable $(BIN_DIST_LIBDIR)/ifBuildable
398 cp Makefile $(BIN_DIST_LIBDIR)
399 ifeq "$(HADDOCK_DOCS)" "YES"
400 cp gen_contents_index $(BIN_DIST_LIBDIR)
401 cp index.html $(BIN_DIST_LIBDIR)
402 cp doc-index*.html $(BIN_DIST_LIBDIR)
404 cp -pR stamp $(BIN_DIST_LIBDIR)
406 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
407 binary-dist.library.%:
408 if ifBuildable/ifBuildable $*; then \
409 $(MKDIRHIER) $(BIN_DIST_LIBDIR)/$*; \
411 cp $*.cabal $(BIN_DIST_LIBDIR)/$* && \
412 cp LICENSE $(BIN_DIST_LIBDIR)/$* && \
413 cp -R dist $(BIN_DIST_LIBDIR)/$* && \
414 $(FIND) . -name "*.buildinfo" -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
415 $(FIND) . -name unbuildable -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
416 (cp -RL include $(BIN_DIST_LIBDIR)/$* || true) && \
417 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
418 \( -name "*_split" -o -name "autogen" \) | xargs rm -rf && \
419 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
420 \( \( -name "*.o" -o -name "*.p_o" \) -a ! -name "HS*" \) \
424 # Ignore some doc targets that we don't support
425 # The root recurses into us when these targets are made
426 .PHONY: html-no-chunks chm HxS fo dvi ps pdf
427 html-no-chunks chm HxS fo dvi ps pdf: