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 # Ideally we'd just include something to give us variables
28 # for paths and arguments to tools etc, and those set in mk/build.mk.
30 include $(TOP)/mk/boilerplate.mk
32 SUBDIRS = base old-locale old-time directory process filepath pretty \
33 template-haskell readline Cabal random haskell98
35 ifeq "$(GhcLibsWithUnix)" "YES"
38 ifeq "$(Windows)" "YES"
39 SUBDIRS += $(wildcard Win32)
42 # Set GhcBootLibs=YES from the command line to work with just the libraries
43 # needed to bootstrap GHC.
44 ifneq "$(GhcBootLibs)" "YES"
45 SUBDIRS += $(wildcard regex-base)
46 SUBDIRS += $(wildcard regex-posix)
47 SUBDIRS += $(wildcard regex-compat)
48 SUBDIRS += $(wildcard parsec)
49 SUBDIRS += $(wildcard haskell-src)
50 SUBDIRS += $(wildcard html)
51 SUBDIRS += $(wildcard network)
52 SUBDIRS += $(wildcard QuickCheck)
53 SUBDIRS += $(wildcard HUnit)
54 SUBDIRS += $(wildcard mtl)
55 SUBDIRS += $(wildcard fgl)
56 SUBDIRS += $(wildcard X11)
57 SUBDIRS += $(wildcard time)
58 ifeq "$(Windows)" "NO"
59 # HGL is not working on Win32, so omit it for now. Better not to ship it
60 # at all than to ship a broken version.
61 SUBDIRS += $(wildcard HGL)
63 SUBDIRS += $(wildcard OpenGL)
64 SUBDIRS += $(wildcard GLUT)
65 SUBDIRS += $(wildcard OpenAL)
66 SUBDIRS += $(wildcard ALUT)
67 SUBDIRS += $(wildcard stm)
68 SUBDIRS += $(wildcard xhtml)
69 SUBDIRS += $(wildcard cgi)
70 SUBDIRS += $(wildcard arrows)
71 ifeq "$(GhcLibsWithObjectIO)" "YES"
72 SUBDIRS += $(wildcard ObjectIO)
74 SUBDIRS += $(wildcard parallel)
77 # -----------------------------------------------------------------------------
80 space=$(empty) $(empty)
82 # -----------------------------------------------------------------------------
84 ifneq "$(DOING_BIN_DIST)" "YES"
87 CONFIGURE_STAMP_EXTRAS :=
89 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
90 CONFIGURE_OPTS += --enable-library-profiling
91 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
94 ifeq "$(SplitObjs)" "YES"
95 CONFIGURE_OPTS += --enable-split-objs
96 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
99 BOOTSTRAP_LIBS = Cabal filepath
100 BOOTSTRAP_STAMPS = $(addprefix stamp/bootstrapping.,$(BOOTSTRAP_LIBS))
101 BOOTSTRAP_INC_1_UP = $(addprefix -i../bootstrapping.,$(BOOTSTRAP_LIBS))
102 BOOTSTRAP_INC_2_UP = $(addprefix -i../../bootstrapping.,$(BOOTSTRAP_LIBS))
111 boot: $(BOOTSTRAP_STAMPS) ifBuildable/ifBuildable \
112 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup) \
113 installPackage/installPackage
115 # We build the Setup program in a setup subdirectory to stop it trying
116 # to use bits of base and Cabal when we build those packages.
117 # This also makes it slightly easier to clean.
119 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
121 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
122 %/setup/Setup: $(BOOTSTRAP_STAMPS)
125 $(CP) $*/Setup.*hs $*/setup
126 cd $*/setup && $(GHC) -Wall -cpp --make Setup.*hs -o Setup \
127 $(BOOTSTRAP_INC_2_UP)
129 installPackage/installPackage: installPackage.hs $(BOOTSTRAP_STAMPS)
130 -$(RM) -rf installPackage
132 $(CP) installPackage.hs installPackage/
133 cd installPackage && $(GHC) -Wall -cpp \
134 --make installPackage -o installPackage \
135 $(BOOTSTRAP_INC_1_UP)
137 ifBuildable/ifBuildable: ifBuildable.hs
138 -$(RM) -rf ifBuildable
140 $(CP) ifBuildable.hs ifBuildable/
141 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
143 $(BOOTSTRAP_STAMPS): stamp/bootstrapping.%:
144 $(RM) -rf bootstrapping.$*
145 $(CP) -R $* bootstrapping.$*
146 $(FIND) bootstrapping.$* \( -name "*.o" -o -name "*.hi" \) \
150 .PHONY: all build configure
154 ifneq "$(NO_HADDOCK_DOCS)" "YES"
158 .PHONY: rebuild.library.%
160 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
161 rebuild.library.%: clean.library.% build.library.%
163 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
164 build: installPackage/installPackage
166 configure: $(foreach SUBDIR,$(SUBDIRS), \
167 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
169 .PHONY: build.library.%
171 # We should depend on %/%.cabal here (and in other rules), but make
172 # makes that difficult.
174 # We explicitly set datadir to "$prefix/share" as, while that is the
175 # default on Linux, on Windows it defaults to
176 # "C:\\Program Files\\Common Files"
178 # We also set libsubdir differently on Windows and non-Windows, as on
179 # non-Windows the path we deduce is highre up than the path passed to
180 # the executable with the shell script on non-Windows. This should
181 # probably be tidied up so that we can always pass the same libsubdir.
182 ifeq "$(Windows)" "YES"
185 libsubdir = $$compiler/lib/$$pkgid
188 $(foreach SUBDIR,$(SUBDIRS), \
189 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
190 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
191 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
192 ( cd $* && setup/Setup configure \
194 --prefix='$$topdir' \
195 --datadir='$$prefix/share' \
196 --libsubdir='$(libsubdir)' \
197 --with-compiler=../../compiler/ghc-inplace$(dot_bat) \
198 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \
199 --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \
202 --haddock-args="--use-contents=../index.html \
203 --use-index=../doc-index.html" \
204 $(addprefix --configure-option=,$(CONFIGURE_ARGS)) \
205 --configure-option=--with-cc=$(CC) ) \
206 && touch $@ || touch $*/unbuildable
207 # We don't touch $@ if configure failed as we would prefer to try
208 # configuring it next time round, rather than assuming it'll still fail.
209 # This is particularly important for corelibs, where failure means the
212 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
213 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
214 %/setup/Setup ifBuildable/ifBuildable
215 ifBuildable/ifBuildable $* setup/Setup build \
216 $(addprefix --ghc-option=,$(GhcLibHcOpts))
217 ifBuildable/ifBuildable $* setup/Setup register --inplace
219 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/CabalMakefile):\
220 %/CabalMakefile: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
221 %/setup/Setup ifBuildable/ifBuildable
222 $(RM) $*/CabalMakefile
223 ifBuildable/ifBuildable $* setup/Setup makefile -f CabalMakefile \
224 $(addprefix --ghc-option=,$(GhcLibHcOpts))
228 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
230 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
231 sh gen_contents_index
233 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
234 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
235 %/setup/Setup ifBuildable/ifBuildable
236 ifBuildable/ifBuildable $* setup/Setup haddock
238 .PHONY: distclean clean clean.library.%
242 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
243 $(RM) -f stamp/bootstrapping.*
244 $(RM) -rf bootstrapping.*
245 $(RM) -rf ifBuildable
246 $(RM) -f libraries.txt index.html doc-index.html
248 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
250 $(RM) -f stamp/configure.library.*.$* $*/unbuildable
251 -cd $* && setup/Setup clean
255 # -----------------------------------------------------------------------------
257 .PHONY: install install-docs install.library.%
259 ROOT=$(prefix)/share/ghc/doc/html/
261 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
262 ifneq "$(NO_HADDOCK_DOCS)" "YES"
263 $(INSTALL_DIR) $(ROOT)
264 $(INSTALL_DATA) index.html doc-index.html $(ROOT)
265 $(INSTALL_SCRIPT) gen_contents_index $(ROOT)
267 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(ROOT)
268 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(ROOT)
269 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(ROOT)
272 # Cabal doesn't let us ask to install docs only, so do nothing here
276 # Ideally this would depend on a stamp/build.library.%, but if it does
277 # then we can't change the libraries and then just rerun make.
278 # Thus if you install without building then it will just break.
279 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
280 install.library.%: installPackage/installPackage ifBuildable/ifBuildable
281 ifBuildable/ifBuildable $* ../installPackage/installPackage $(prefix) $(bindir)/ghc-pkg
283 .PHONY: binary-dist binary-dist.library.%
285 BIN_DIST_LIBDIR=$(BIN_DIST_DIR)/libraries
287 binary-dist: $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR))
288 mkdir $(BIN_DIST_LIBDIR)/installPackage
289 cp installPackage/installPackage $(BIN_DIST_LIBDIR)/installPackage
290 mkdir $(BIN_DIST_LIBDIR)/ifBuildable
291 cp ifBuildable/ifBuildable $(BIN_DIST_LIBDIR)/ifBuildable
292 cp Makefile $(BIN_DIST_LIBDIR)
293 cp gen_contents_index $(BIN_DIST_LIBDIR)
294 cp index.html $(BIN_DIST_LIBDIR)
295 cp doc-index.html $(BIN_DIST_LIBDIR)
296 cp -a stamp $(BIN_DIST_LIBDIR)
298 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
299 binary-dist.library.%:
300 $(MKDIRHIER) $(BIN_DIST_LIBDIR)/$*
301 ifBuildable/ifBuildable $* cp $*.cabal $(BIN_DIST_LIBDIR)/$*
302 ifBuildable/ifBuildable $* cp -a dist $(BIN_DIST_LIBDIR)/$*
304 ifBuildable/ifBuildable $* cp -aL include $(BIN_DIST_LIBDIR)/$* || :
305 ifBuildable/ifBuildable $* $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
306 \( -name "*_split" -o -name "autogen" \) | xargs rm -rf
307 ifBuildable/ifBuildable $* $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
308 \( \( -name "*.o" -o -name "*.p_o" \) -a ! -name "HS*" \) \