8 # To rebuild a particular library <package>:
10 # make clean.library.<package>
11 # make build.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 build.library.foo
23 .PHONY: default_target
27 ifeq "$(IN_BIN_DIST)" "1"
28 include ../Makefile-vars
30 # Ideally we'd just include something to give us variables
31 # for paths and arguments to tools etc, and those set in mk/build.mk.
33 include $(TOP)/mk/boilerplate.mk
36 SUBDIRS = base old-locale old-time directory process filepath pretty \
37 template-haskell readline Cabal random haskell98
39 ifeq "$(GhcLibsWithUnix)" "YES"
42 ifeq "$(Windows)" "YES"
43 SUBDIRS += $(wildcard Win32)
46 # Set GhcBootLibs=YES from the command line to work with just the libraries
47 # needed to bootstrap GHC.
48 ifneq "$(GhcBootLibs)" "YES"
49 SUBDIRS += $(wildcard regex-base)
50 SUBDIRS += $(wildcard regex-posix)
51 SUBDIRS += $(wildcard regex-compat)
52 SUBDIRS += $(wildcard parsec)
53 SUBDIRS += $(wildcard haskell-src)
54 SUBDIRS += $(wildcard html)
55 SUBDIRS += $(wildcard network)
56 SUBDIRS += $(wildcard QuickCheck)
57 SUBDIRS += $(wildcard HUnit)
58 SUBDIRS += $(wildcard mtl)
59 SUBDIRS += $(wildcard fgl)
60 SUBDIRS += $(wildcard X11)
61 SUBDIRS += $(wildcard time)
62 ifeq "$(Windows)" "NO"
63 # HGL is not working on Win32, so omit it for now. Better not to ship it
64 # at all than to ship a broken version.
65 SUBDIRS += $(wildcard HGL)
67 SUBDIRS += $(wildcard OpenGL)
68 SUBDIRS += $(wildcard GLUT)
69 SUBDIRS += $(wildcard OpenAL)
70 SUBDIRS += $(wildcard ALUT)
71 SUBDIRS += $(wildcard stm)
72 SUBDIRS += $(wildcard xhtml)
73 SUBDIRS += $(wildcard cgi)
74 SUBDIRS += $(wildcard arrows)
75 ifeq "$(GhcLibsWithObjectIO)" "YES"
76 SUBDIRS += $(wildcard ObjectIO)
78 SUBDIRS += $(wildcard parallel)
81 # -----------------------------------------------------------------------------
84 space=$(empty) $(empty)
86 ifeq "$(Windows)" "YES"
93 CONFIGURE_STAMP_EXTRAS :=
95 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
96 CONFIGURE_OPTS += --enable-library-profiling
97 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
100 ifeq "$(SplitObjs)" "YES"
101 CONFIGURE_OPTS += --enable-split-objs
102 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
105 BOOTSTRAP_LIBS = Cabal filepath
106 BOOTSTRAP_STAMPS = $(addprefix stamp/bootstrapping.,$(BOOTSTRAP_LIBS))
107 BOOTSTRAP_INC_1_UP = $(addprefix -i../bootstrapping.,$(BOOTSTRAP_LIBS))
108 BOOTSTRAP_INC_2_UP = $(addprefix -i../../bootstrapping.,$(BOOTSTRAP_LIBS))
117 boot: $(BOOTSTRAP_STAMPS) ifBuildable/ifBuildable \
118 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup) \
119 installPackage/installPackage
121 # We build the Setup program in a setup subdirectory to stop it trying
122 # to use bits of base and Cabal when we build those packages.
123 # This also makes it slightly easier to clean.
125 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
127 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
128 %/setup/Setup: $(BOOTSTRAP_STAMPS)
131 $(CP) $*/Setup.*hs $*/setup
132 cd $*/setup && $(GHC) -Wall -cpp --make Setup.*hs -o Setup \
133 $(BOOTSTRAP_INC_2_UP)
135 installPackage/installPackage: installPackage.hs $(BOOTSTRAP_STAMPS)
136 -$(RM) -rf installPackage
138 $(CP) installPackage.hs installPackage/
139 cd installPackage && $(GHC) -Wall -cpp \
140 --make installPackage -o installPackage \
141 $(BOOTSTRAP_INC_1_UP)
143 ifBuildable/ifBuildable: ifBuildable.hs
144 -$(RM) -rf ifBuildable
146 $(CP) ifBuildable.hs ifBuildable/
147 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
149 $(BOOTSTRAP_STAMPS): stamp/bootstrapping.%:
150 $(RM) -rf bootstrapping.$*
151 $(CP) -R $* bootstrapping.$*
152 $(FIND) bootstrapping.$* \( -name "*.o" -o -name "*.hi" \) \
156 .PHONY: all build configure
160 ifneq "$(NO_HADDOCK_DOCS)" "YES"
164 .PHONY: rebuild.library.%
166 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
167 rebuild.library.%: clean.library.% build.library.%
169 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
170 build: installPackage/installPackage
172 configure: $(foreach SUBDIR,$(SUBDIRS), \
173 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
175 .PHONY: build.library.%
177 # We should depend on %/%.cabal here (and in other rules), but make
178 # makes that difficult.
180 $(foreach SUBDIR,$(SUBDIRS), \
181 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
182 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
183 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
184 ( cd $* && setup/Setup configure \
186 --prefix='$$topdir' \
187 --libsubdir='$$compiler/lib/$$pkgid' \
188 --with-compiler=../../compiler/ghc-inplace$(dot_bat) \
189 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \
190 --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \
193 --haddock-args="--use-contents=../index.html \
194 --use-index=../doc-index.html" \
195 $(addprefix --configure-option=,$(CONFIGURE_ARGS)) \
196 --configure-option=--with-cc=$(CC) ) \
197 && touch $@ || touch $*/unbuildable
198 # We don't touch $@ if configure failed as we would prefer to try
199 # configuring it next time round, rather than assuming it'll still fail.
200 # This is particularly important for corelibs, where failure means the
203 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
204 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
205 %/setup/Setup ifBuildable/ifBuildable
206 ifBuildable/ifBuildable $* setup/Setup build \
207 $(addprefix --ghc-option=,$(GhcLibHcOpts))
208 ifBuildable/ifBuildable $* setup/Setup register --inplace
210 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/CabalMakefile):\
211 %/CabalMakefile: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
212 %/setup/Setup ifBuildable/ifBuildable
213 $(RM) $*/CabalMakefile
214 ifBuildable/ifBuildable $* setup/Setup makefile -f CabalMakefile \
215 $(addprefix --ghc-option=,$(GhcLibHcOpts))
219 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
221 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
222 sh gen_contents_index
224 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
225 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
226 %/setup/Setup ifBuildable/ifBuildable
227 ifBuildable/ifBuildable $* setup/Setup haddock
229 .PHONY: install install-docs install.library.%
231 ROOT=$(prefix)/share/ghc/doc/html/
233 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
234 ifneq "$(NO_HADDOCK_DOCS)" "YES"
235 $(INSTALL_DIR) $(ROOT)
236 $(INSTALL_DATA) index.html doc-index.html $(ROOT)
237 $(INSTALL_SCRIPT) gen_contents_index $(ROOT)
239 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(ROOT)
240 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(ROOT)
241 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(ROOT)
244 # Cabal doesn't let us ask to install docs only, so do nothing here
248 # Ideally this would depend on a stamp/build.library.%, but if it does
249 # then we can't change the libraries and then just rerun make.
250 # Thus if you install without building then it will just break.
251 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
252 install.library.%: installPackage/installPackage ifBuildable/ifBuildable
253 ifBuildable/ifBuildable $* ../installPackage/installPackage $(prefix) $(bindir)/ghc-pkg
255 .PHONY: binary-dist binary-dist.library.%
257 BIN_DIST_LIBDIR=$(BIN_DIST_DIR)/libraries
259 binary-dist: $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR))
260 mkdir $(BIN_DIST_LIBDIR)/installPackage
261 cp installPackage/installPackage $(BIN_DIST_LIBDIR)/installPackage
262 cp Makefile $(BIN_DIST_LIBDIR)
263 cp gen_contents_index $(BIN_DIST_LIBDIR)
264 cp index.html $(BIN_DIST_LIBDIR)
265 cp doc-index.html $(BIN_DIST_LIBDIR)
266 cp -a stamp $(BIN_DIST_LIBDIR)
268 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
269 binary-dist.library.%:
270 $(MKDIRHIER) $(BIN_DIST_LIBDIR)/$*
271 ifBuildable/ifBuildable $* cp $*.cabal $(BIN_DIST_LIBDIR)/$*
272 ifBuildable/ifBuildable $* cp -a dist $(BIN_DIST_LIBDIR)/$*
273 ifBuildable/ifBuildable $* $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
274 \( -name "*_split" -o -name "autogen" \) | xargs rm -rf
275 ifBuildable/ifBuildable $* $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
276 \( \( -name "*.o" -o -name "*.p_o" \) -a ! -name "HS*" \) \
279 .PHONY: distclean clean clean.library.%
283 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
284 $(RM) -f stamp/bootstrapping.*
285 $(RM) -rf bootstrapping.*
286 $(RM) -rf ifBuildable
287 $(RM) -f libraries.txt index.html doc-index.html
289 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
291 $(RM) -f stamp/configure.library.*.$* $*/unbuildable
292 -cd $* && setup/Setup clean