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
40 include $(TOP)/mk/cabal-flags.mk
42 SUBDIRS = ghc-prim $(INTEGER_LIBRARY) base array packedstring
43 SUBDIRS += containers bytestring old-locale old-time filepath directory
44 ifeq "$(GhcLibsWithUnix)" "YES"
47 ifeq "$(Windows)" "YES"
48 SUBDIRS += $(wildcard Win32)
50 SUBDIRS += process pretty hpc template-haskell editline Cabal random haskell98
52 # Set GhcBootLibs=YES from the command line to work with just the libraries
53 # needed to bootstrap GHC.
54 ifneq "$(GhcBootLibs)" "YES"
55 SUBDIRS += $(wildcard regex-base)
56 SUBDIRS += $(wildcard regex-posix)
57 SUBDIRS += $(wildcard regex-compat)
58 SUBDIRS += $(wildcard parsec)
59 SUBDIRS += $(wildcard haskell-src)
60 SUBDIRS += $(wildcard html)
61 SUBDIRS += $(wildcard network)
62 SUBDIRS += $(wildcard QuickCheck)
63 SUBDIRS += $(wildcard HUnit)
64 SUBDIRS += $(wildcard mtl)
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 SUBDIRS += $(wildcard parallel)
74 SUBDIRS_BUILD += $(wildcard ndp)
75 SUBDIRS_BUILD += $(wildcard dph/dph-base)
76 SUBDIRS_BUILD += $(wildcard dph/dph-prim-interface)
77 SUBDIRS_BUILD += $(wildcard dph/dph-prim-seq)
78 SUBDIRS_BUILD += $(wildcard dph/dph-prim-par)
79 SUBDIRS_BUILD += $(wildcard dph/dph)
82 SUBDIRS += $(SUBDIRS_BUILD)
84 # -----------------------------------------------------------------------------
87 space=$(empty) $(empty)
89 # -----------------------------------------------------------------------------
91 ifeq "$(ghc_ge_609)" "YES"
92 GhcLibHcOpts += -fno-warn-deprecated-flags
95 ifeq "$(RelocatableBuild)" "YES"
96 # On Windows we want to make moveable bindists, but we need to tell
97 # ghc-pkg where the haddock docs are. Therefore we completely ignore
98 # where the user tells us to put the haddock documentation and put it
99 # somewhere whose relative location we know. When installing we need
100 # to give Cabal a real path, though.
104 ilibexecdir = $$topdir
105 idynlibdir = $$topdir
107 idocdir = $$topdir/doc/libraries/$$pkg
108 ihaddockdir = $$topdir/doc/libraries/$$pkg
109 ihtmldir = $$httptopdir/doc/libraries/$$pkg
110 html_installed_root = $(prefix)/doc/libraries
112 # On non-Windows we can just give absolute paths all the time, and
113 # thus obey the htmldir that we are given.
117 ilibexecdir = $(libexecdir)
118 idynlibdir = $(dynlibdir)
119 idatadir = $(datadir)
120 idocdir = $(docdir)/libraries/$$pkg
121 ihaddockdir = $(htmldir)/libraries/$$pkg
122 ihtmldir = $(htmldir)/libraries/$$pkg
123 html_installed_root = $(htmldir)/libraries
126 ifneq "$(DOING_BIN_DIST)" "YES"
129 CONFIGURE_STAMP_EXTRAS :=
131 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
132 CONFIGURE_OPTS += --enable-library-profiling
133 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
136 ifneq "$(findstring $(space)dyn$(space), $(space)$(GhcLibWays)$(space))" ""
137 CONFIGURE_OPTS += --enable-shared
138 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-shared
141 ifeq "$(SplitObjs)" "YES"
142 CONFIGURE_OPTS += --enable-split-objs
143 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
146 DEPLOYMENT_OPTS = $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) \
147 $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS))
154 HERE_ABS=$(FPTOOLS_TOP_ABS)/libraries
156 IFBUILDABLE=ifBuildable/ifBuildable $(HERE_ABS)/boot-packages
157 CABAL=$(HERE_ABS)/cabal-bin $(GHC) $(HERE_ABS)/bootstrapping.conf
159 CABAL_GHC_FLAGS = -Wall
160 ifeq "$(ghc_ge_605)" "NO"
161 CABAL_GHC_FLAGS += -cpp
164 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 -i$(HERE_ABS)/hpc
168 boot: ifBuildable/ifBuildable cabal-bin bootstrapping.conf
170 cabal-bin: cabal-bin.hs
171 $(GHC) $(BOOTSTRAPPING_FLAGS) --make cabal-bin -o cabal-bin
173 bootstrapping.conf: cabal-bin
175 -cd filepath && $(CABAL) clean --distpref=dist-bootstrapping
176 cd filepath && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
177 cd filepath && $(CABAL) build --distpref=dist-bootstrapping
178 cd filepath && $(CABAL) install --distpref=dist-bootstrapping --inplace
179 -cd Cabal && $(CABAL) clean --distpref=dist-bootstrapping
180 cd Cabal && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
181 cd Cabal && $(CABAL) build --distpref=dist-bootstrapping
182 cd Cabal && $(CABAL) install --distpref=dist-bootstrapping --inplace
183 -cd hpc && $(CABAL) clean --distpref=dist-bootstrapping
184 cd hpc && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --with-hc-pkg=$(GHC_PKG) --package-db=$(HERE_ABS)/$@.tmp
185 cd hpc && $(CABAL) build --distpref=dist-bootstrapping
186 cd hpc && $(CABAL) install --distpref=dist-bootstrapping --inplace
189 installPackage/installPackage: installPackage.hs
190 -$(RM) -rf installPackage
192 $(CP) installPackage.hs installPackage/
193 cd installPackage && $(FPTOOLS_TOP_ABS)/compiler/stage1/ghc-inplace \
194 --make installPackage -o installPackage \
197 ifBuildable/ifBuildable: ifBuildable.hs
198 -$(RM) -rf ifBuildable
200 $(CP) ifBuildable.hs ifBuildable/
202 cd ifBuildable && ../$(HC) -Wall --make ifBuildable -o ifBuildable \
205 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
208 .PHONY: all build configure
212 ifeq "$(HADDOCK_DOCS)" "YES"
216 .PHONY: rebuild.library.%
217 .PHONY: remake.library.%
219 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
220 rebuild.library.%: clean.library.% build.library.%
222 $(foreach SUBDIR,$(SUBDIRS),remake.library.$(SUBDIR)):\
223 remake.library.%: clean.library.% make.library.%
225 # NB. we're depending on make chasing dependencies from left to right here.
226 # This bit goes wrong with 'make -j'.
227 build: $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR)) \
228 installPackage/installPackage
230 configure: $(foreach SUBDIR,$(SUBDIRS), \
231 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
233 .PHONY: build.library.%
234 .PHONY: make.library.%
236 # We should depend on %/%.cabal here (and in other rules), but make
237 # makes that difficult.
239 ifeq "$(Windows)" "YES"
240 NONEXISTENT=c:/NONEXISTENT
242 NONEXISTENT=/NONEXISTENT
245 ALL_CONFIGURE_FLAGS = \
246 $(INSTALL_CONFIGURE_FLAGS) \
247 --haddock-options="--use-contents=../index.html \
248 --use-index=../doc-index.html" \
251 $(foreach SUBDIR,$(SUBDIRS), \
252 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
253 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: cabal-bin \
255 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
256 $(MKDIRHIER) `dirname $@`
257 ( cd $* && $(CABAL) configure $(ALL_CONFIGURE_FLAGS) ) \
258 && touch $@ || touch $*/unbuildable
259 # We don't touch $@ if configure failed as we would prefer to try
260 # configuring it next time round, rather than assuming it'll still fail.
261 # This is particularly important for bootlibs, where failure means the
264 # Build the library using 'make'
265 # We re-run 'setup makefile' each time, just in case any preprocessing
266 # needs to be done. However, we're careful not to overwrite GNUmakefile
267 # if it hasn't changed, so that dependency-generation isn't forced
269 # Packages in $(SUBDIRS_BUILD) need to use the build.* rules instead of
270 # make.*, so filter them out and use an alternate rule below instead.
271 $(foreach SUBDIR,$(filter-out $(SUBDIRS_BUILD),$(SUBDIRS)),make.library.$(SUBDIR)):\
272 make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
273 cabal-bin ifBuildable/ifBuildable bootstrapping.conf
274 if $(IFBUILDABLE) $*; then \
276 cmp -s $(MAKEFILE_LOCAL) Makefile.local || cp $(MAKEFILE_LOCAL) .; \
277 mv GNUmakefile GNUmakefile.tmp; \
278 $(CABAL) makefile -f GNUmakefile; \
279 cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
280 $(MAKE) $(MFLAGS) && \
281 $(CABAL) register --inplace; \
284 MAKEFILE_LOCAL = $(FPTOOLS_TOP_ABS)/libraries/Makefile.local
286 # Alternate rule, as described above
287 $(foreach SUBDIR,$(SUBDIRS_BUILD),make.library.$(SUBDIR)):\
288 make.library.%: build.library.%
290 # Build the library using 'setup build' (not the default)
291 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
292 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
293 cabal-bin ifBuildable/ifBuildable bootstrapping.conf
294 if $(IFBUILDABLE) $*; then \
296 $(CABAL) build $(BUILD_FLAGS); \
297 $(CABAL) register --inplace; \
304 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
305 sh gen_contents_index --inplace
307 # Making hyperlinked source only works if we have hscolour
308 ifneq "$(HSCOLOUR)" ""
309 CABAL_HADDOCK_FLAGS=--hyperlink-source
312 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
313 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
314 cabal-bin ifBuildable/ifBuildable bootstrapping.conf
315 if $(IFBUILDABLE) $*; then \
316 cd $* && $(CABAL) haddock --html-location='../$$pkg' \
317 $(CABAL_HADDOCK_FLAGS); \
319 ifneq "$(HSCOLOUR)" ""
320 # We use */src rather than $*/src due to the $(INTEGER_LIBRARY)/integer
322 if $(IFBUILDABLE) $*; then cp hscolour.css $*/dist/doc/html/*/src/; fi
325 .PHONY: distclean clean clean.library.%
329 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
330 -cd filepath && $(CABAL) clean --distpref=dist-bootstrapping
331 -cd Cabal && $(CABAL) clean --distpref=dist-bootstrapping
332 -cd hpc && $(CABAL) clean --distpref=dist-bootstrapping
333 $(RM) -rf bootstrapping/*
334 $(RM) -f bootstrapping.conf bootstrapping.conf.old
335 $(RM) -f bootstrapping.conf.tmp bootstrapping.conf.tmp.old
336 $(RM) -f cabal-bin cabal-bin.exe
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 $* && $(CABAL) clean
349 $(RM) -f $*/Setup $*/Setup.exe $*/Setup.hi $*/Setup.o
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) $*; then \
386 $(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)' ; \
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 installPackage/installPackage
395 mkdir $(BIN_DIST_LIBDIR)/installPackage
396 cp installPackage/installPackage $(BIN_DIST_LIBDIR)/installPackage
397 mkdir $(BIN_DIST_LIBDIR)/ifBuildable
398 cp ifBuildable/ifBuildable $(BIN_DIST_LIBDIR)/ifBuildable
399 cp Makefile $(BIN_DIST_LIBDIR)
400 ifeq "$(HADDOCK_DOCS)" "YES"
401 cp gen_contents_index $(BIN_DIST_LIBDIR)
402 cp index.html $(BIN_DIST_LIBDIR)
403 cp doc-index*.html $(BIN_DIST_LIBDIR)
405 cp -pR stamp $(BIN_DIST_LIBDIR)
407 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
408 binary-dist.library.%:
409 if $(IFBUILDABLE) $*; then \
410 $(MKDIRHIER) $(BIN_DIST_LIBDIR)/$*; \
412 cp $*.cabal $(BIN_DIST_LIBDIR)/$* && \
413 cp LICENSE $(BIN_DIST_LIBDIR)/$* && \
414 cp -R dist $(BIN_DIST_LIBDIR)/$* && \
415 $(FIND) . -name "*.buildinfo" -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
416 $(FIND) . -name unbuildable -exec cp {} $(BIN_DIST_LIBDIR)/$* \; && \
417 (cp -RL include $(BIN_DIST_LIBDIR)/$* || true) && \
418 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
419 \( -name "*_split" -o -name "autogen" \) | xargs rm -rf && \
420 $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
421 \( \( -name "*.o" -o -name "*.p_o" \) -a ! -name "HS*" \) \
425 # Ignore some doc targets that we don't support
426 # The root recurses into us when these targets are made
427 .PHONY: html-no-chunks chm HxS fo dvi ps pdf
428 html-no-chunks chm HxS fo dvi ps pdf: