8 # To rebuild a particular library <package>:
10 # make clean.library.<package>
11 # make build.library.<package>
13 .PHONY: default_target
17 ifeq "$(IN_BIN_DIST)" "1"
18 include ../Makefile-vars
20 # Ideally we'd just include something to give us variables
21 # for paths and arguments to tools etc, and those set in mk/build.mk.
23 include $(TOP)/mk/boilerplate.mk
26 SUBDIRS = base old-time directory filepath pretty template-haskell \
27 readline Cabal random haskell98
29 ifeq "$(GhcLibsWithUnix)" "YES"
32 ifeq "$(Windows)" "YES"
33 SUBDIRS += $(wildcard Win32)
36 # Set GhcBootLibs=YES from the command line to work with just the libraries
37 # needed to bootstrap GHC.
38 ifneq "$(GhcBootLibs)" "YES"
39 SUBDIRS += $(wildcard regex-base)
40 SUBDIRS += $(wildcard regex-posix)
41 SUBDIRS += $(wildcard regex-compat)
42 SUBDIRS += $(wildcard parsec)
43 SUBDIRS += $(wildcard haskell-src)
44 SUBDIRS += $(wildcard html)
45 SUBDIRS += $(wildcard network)
46 SUBDIRS += $(wildcard QuickCheck)
47 SUBDIRS += $(wildcard HUnit)
48 SUBDIRS += $(wildcard mtl)
49 SUBDIRS += $(wildcard fgl)
50 SUBDIRS += $(wildcard X11)
51 SUBDIRS += $(wildcard time)
52 ifeq "$(Windows)" "NO"
53 # HGL is not working on Win32, so omit it for now. Better not to ship it
54 # at all than to ship a broken version.
55 SUBDIRS += $(wildcard HGL)
57 SUBDIRS += $(wildcard OpenGL)
58 SUBDIRS += $(wildcard GLUT)
59 SUBDIRS += $(wildcard OpenAL)
60 SUBDIRS += $(wildcard ALUT)
61 SUBDIRS += $(wildcard stm)
62 SUBDIRS += $(wildcard xhtml)
63 SUBDIRS += $(wildcard cgi)
64 SUBDIRS += $(wildcard arrows)
65 ifeq "$(GhcLibsWithObjectIO)" "YES"
66 SUBDIRS += $(wildcard ObjectIO)
68 SUBDIRS += $(wildcard parallel)
71 # -----------------------------------------------------------------------------
74 space=$(empty) $(empty)
76 ifeq "$(Windows)" "YES"
83 CONFIGURE_STAMP_EXTRAS :=
85 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
86 CONFIGURE_OPTS += --enable-library-profiling
87 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
90 ifeq "$(SplitObjs)" "YES"
91 CONFIGURE_OPTS += --enable-split-objs
92 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
95 BOOTSTRAPPING_STAMPS = $(addprefix stamp/bootstrapping.,Cabal filepath pretty)
104 boot: $(BOOTSTRAPPING_STAMPS) ifBuildable/ifBuildable \
105 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup) \
106 installPackage/installPackage
108 # We build the Setup program in a setup subdirectory to stop it trying
109 # to use bits of base and Cabal when we build those packages.
110 # This also makes it slightly easier to clean.
112 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
114 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
115 %/setup/Setup: $(BOOTSTRAPPING_STAMPS)
118 $(CP) $*/Setup.*hs $*/setup
119 cd $*/setup && $(GHC) -i../../bootstrapping.Cabal \
120 -i../../bootstrapping.filepath \
121 -i../../bootstrapping.pretty \
122 -Wall -cpp --make Setup.*hs -o Setup
124 installPackage/installPackage: installPackage.hs $(BOOTSTRAPPING_STAMPS)
125 -$(RM) -rf installPackage
127 $(CP) installPackage.hs installPackage/
128 cd installPackage && $(GHC) -Wall -cpp \
129 --make installPackage -o installPackage \
130 -i../bootstrapping.Cabal \
131 -i../bootstrapping.filepath \
132 -i../bootstrapping.pretty
134 ifBuildable/ifBuildable: ifBuildable.hs
135 -$(RM) -rf ifBuildable
137 $(CP) ifBuildable.hs ifBuildable/
138 cd ifBuildable && $(GHC) -Wall --make ifBuildable -o ifBuildable
140 $(BOOTSTRAPPING_STAMPS): stamp/bootstrapping.%:
141 $(RM) -rf bootstrapping.$*
142 $(CP) -R $* bootstrapping.$*
143 $(FIND) bootstrapping.$* \( -name "*.o" -o -name "*.hi" \) \
147 .PHONY: all build configure
151 ifneq "$(NO_HADDOCK_DOCS)" "YES"
155 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
156 build: installPackage/installPackage
158 configure: $(foreach SUBDIR,$(SUBDIRS), \
159 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
161 .PHONY: build.library.%
163 # We should depend on %/%.cabal here (and in other rules), but make
164 # makes that difficult.
166 $(foreach SUBDIR,$(SUBDIRS), \
167 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
168 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
169 -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
170 ( cd $* && setup/Setup configure \
173 --with-compiler=../../compiler/ghc-inplace$(dot_bat) \
174 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \
175 --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \
178 --haddock-args="--use-contents=../index.html \
179 --use-index=../doc-index.html" \
180 $(addprefix --configure-option=,$(CONFIGURE_ARGS)) \
181 --configure-option=--with-cc=$(CC) ) \
182 && touch $@ || touch $*/unbuildable
183 # We don't touch $@ if configure failed as we would prefer to try
184 # configuring it next time round, rather than assuming it'll still fail.
185 # This is particularly important for corelibs, where failure means the
188 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
189 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
190 %/setup/Setup ifBuildable/ifBuildable
191 ifBuildable/ifBuildable $* setup/Setup build \
192 $(addprefix --ghc-option=,$(GhcLibHcOpts))
193 ifBuildable/ifBuildable $* setup/Setup register --inplace
197 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
199 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
200 sh gen_contents_index
202 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
203 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
204 %/setup/Setup ifBuildable/ifBuildable
205 ifBuildable/ifBuildable $* setup/Setup haddock
207 .PHONY: install install-docs install.library.%
209 INSTALL_DIR=$(prefix)/share/ghc/doc/html/
211 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
212 ifneq "$(NO_HADDOCK_DOCS)" "YES"
213 $(INSTALL_DATA) index.html doc-index.html $(INSTALL_DIR)
214 $(INSTALL_SCRIPT) gen_contents_index $(INSTALL_DIR)
216 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
217 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(INSTALL_DIR)
218 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
221 # Cabal doesn't let us ask to install docs only, so do nothing here
225 # Ideally this would depend on a stamp/build.library.%, but if it does
226 # then we can't change the libraries and then just rerun make.
227 # Thus if you install without building then it will just break.
228 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
229 install.library.%: installPackage/installPackage ifBuildable/ifBuildable
230 ifBuildable/ifBuildable $* ../installPackage/installPackage
232 .PHONY: binary-dist binary-dist.library.%
234 BIN_DIST_LIBDIR=$(BIN_DIST_DIR)/libraries
236 binary-dist: $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR))
237 mkdir $(BIN_DIST_LIBDIR)/installPackage
238 cp installPackage/installPackage $(BIN_DIST_LIBDIR)/installPackage
239 cp Makefile $(BIN_DIST_LIBDIR)
240 cp gen_contents_index $(BIN_DIST_LIBDIR)
241 cp index.html $(BIN_DIST_LIBDIR)
242 cp doc-index.html $(BIN_DIST_LIBDIR)
243 cp -a stamp $(BIN_DIST_LIBDIR)
245 $(foreach SUBDIR,$(SUBDIRS),binary-dist.library.$(SUBDIR)): \
246 binary-dist.library.%:
247 $(MKDIRHIER) $(BIN_DIST_LIBDIR)/$*
248 ifBuildable/ifBuildable $* cp $*.cabal $(BIN_DIST_LIBDIR)/$*
249 ifBuildable/ifBuildable $* cp -a dist $(BIN_DIST_LIBDIR)/$*
250 ifBuildable/ifBuildable $* $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
251 \( -name "*_split" -o -name "autogen" \) | xargs rm -rf
252 ifBuildable/ifBuildable $* $(FIND) $(BIN_DIST_LIBDIR)/$*/dist \
253 \( \( -name "*.o" -o -name "*.p_o" \) -a ! -name "HS*" \) \
256 .PHONY: distclean clean clean.library.%
260 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
261 $(RM) -f stamp/bootstrapping.*
262 $(RM) -rf bootstrapping.*
263 $(RM) -rf ifBuildable
264 $(RM) -f libraries.txt index.html doc-index.html
266 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
268 $(RM) -f stamp/configure.library.*.$* $*/unbuildable
269 -cd $* && setup/Setup clean