6 ifeq "$(IN_BIN_DIST)" "1"
7 include ../Makefile-vars
9 # Ideally we'd just include something to give us variables
10 # for paths and arguments to tools etc, and those set in mk/build.mk.
12 include $(TOP)/mk/boilerplate.mk
15 SUBDIRS = base filepath haskell98 template-haskell readline Cabal
17 ifeq "$(GhcLibsWithUnix)" "YES"
20 ifeq "$(Windows)" "YES"
21 SUBDIRS += $(wildcard Win32)
24 # Set GhcBootLibs=YES from the command line to work with just the libraries
25 # needed to bootstrap GHC.
26 ifneq "$(GhcBootLibs)" "YES"
27 SUBDIRS += $(wildcard regex-base)
28 SUBDIRS += $(wildcard regex-posix)
29 SUBDIRS += $(wildcard regex-compat)
30 SUBDIRS += $(wildcard parsec)
31 SUBDIRS += $(wildcard haskell-src)
32 SUBDIRS += $(wildcard html)
33 SUBDIRS += $(wildcard network)
34 SUBDIRS += $(wildcard QuickCheck)
35 SUBDIRS += $(wildcard HUnit)
36 SUBDIRS += $(wildcard mtl)
37 SUBDIRS += $(wildcard fgl)
38 SUBDIRS += $(wildcard X11)
39 SUBDIRS += $(wildcard time)
40 ifeq "$(Windows)" "NO"
41 # HGL is not working on Win32, so omit it for now. Better not to ship it
42 # at all than to ship a broken version.
43 SUBDIRS += $(wildcard HGL)
45 SUBDIRS += $(wildcard OpenGL)
46 SUBDIRS += $(wildcard GLUT)
47 SUBDIRS += $(wildcard OpenAL)
48 SUBDIRS += $(wildcard ALUT)
49 SUBDIRS += $(wildcard stm)
50 SUBDIRS += $(wildcard xhtml)
51 SUBDIRS += $(wildcard cgi)
52 ifeq "$(GhcLibsWithObjectIO)" "YES"
53 SUBDIRS += $(wildcard ObjectIO)
57 # -----------------------------------------------------------------------------
60 space=$(empty) $(empty)
62 ifeq "$(Windows)" "YES"
69 CONFIGURE_STAMP_EXTRAS :=
71 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
72 CONFIGURE_OPTS += --enable-library-profiling
73 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
76 ifeq "$(SplitObjs)" "YES"
77 CONFIGURE_OPTS += --enable-split-objs
78 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-splitting
81 BOOTSTRAPPING_CABAL = bootstrapping.cabal
90 boot: ifBuildable/ifBuildable \
91 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup)
93 $(GENPRIMOP) --make-haskell-source < ../compiler/prelude/primops.txt > base/GHC/Prim.hs
94 $(GENPRIMOP) --make-haskell-wrappers < ../compiler/prelude/primops.txt > base/GHC/PrimopWrappers.hs
96 # We build the Setup program in a setup subdirectory to stop it trying
97 # to use bits of base and Cabal when we build those packages.
98 # This also makes it slightly easier to clean.
100 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
102 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
103 %/setup/Setup: stamp/$(BOOTSTRAPPING_CABAL)
106 $(CP) $*/Setup.*hs $*/setup
107 cd $*/setup && $(GHC) -Wall --make -i../../$(BOOTSTRAPPING_CABAL) Setup.*hs -o Setup
109 ifBuildable/ifBuildable: ifBuildable.hs stamp/$(BOOTSTRAPPING_CABAL)
110 -$(RM) -rf ifBuildable
112 $(CP) ifBuildable.hs ifBuildable/
113 cd ifBuildable && $(GHC) -Wall --make -i../$(BOOTSTRAPPING_CABAL) \
114 ifBuildable -o ifBuildable
116 stamp/$(BOOTSTRAPPING_CABAL):
117 $(RM) -rf $(BOOTSTRAPPING_CABAL)
118 $(CP) -R Cabal $(BOOTSTRAPPING_CABAL)
119 $(FIND) $(BOOTSTRAPPING_CABAL) \( -name "*.o" -o -name "*.hi" \) -exec $(RM) -f {} \;
122 .PHONY: all build configure
126 ifneq "$(NO_HADDOCK_DOCS)" "YES"
130 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
132 configure: $(foreach SUBDIR,$(SUBDIRS), \
133 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
135 .PHONY: build.library.%
137 # We should depend on %/%.cabal here (and in other rules), but make
138 # makes that difficult.
140 $(foreach SUBDIR,$(SUBDIRS), \
141 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
142 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
143 -$(RM) -f stamp/configure.library.*.$*
144 cd $* && setup/Setup configure \
147 --with-compiler=../../compiler/ghc-inplace$(dot_bat) \
148 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \
149 --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \
152 --haddock-args="--use-contents=../index.html --use-index=../doc-index.html" \
153 $(addprefix --configure-option=,$(CONFIGURE_ARGS)) \
154 --configure-option=--with-cc=$(CC)
157 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
158 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
160 cd $* && ../ifBuildable/ifBuildable setup/Setup build \
161 $(addprefix --ghc-option=,$(GhcLibHcOpts))
162 cd $* && ../ifBuildable/ifBuildable setup/Setup register --inplace
166 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
168 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
169 sh gen_contents_index
171 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
172 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
174 cd $* && ../ifBuildable/ifBuildable setup/Setup haddock
176 .PHONY: install install-docs install.library.%
178 INSTALL_DIR=$(prefix)/share/ghc/doc/html/
180 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
181 ifneq "$(NO_HADDOCK_DOCS)" "YES"
182 $(INSTALL_DATA) index.html doc-index.html $(INSTALL_DIR)
183 $(INSTALL_SCRIPT) gen_contents_index $(INSTALL_DIR)
185 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
186 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(INSTALL_DIR)
187 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
190 # Cabal doesn't let us ask to install docs only, so do nothing here
194 # Ideally this would depend on a stamp/build.library.%, but if it does
195 # then we can't change the libraries and then just rerun make.
196 # Thus if you install without building then it will just break.
197 $(foreach SUBDIR,$(SUBDIRS),stamp/configure.library.install.$(SUBDIR)): \
198 stamp/configure.library.install.%: %/setup/Setup
199 -$(RM) -f stamp/configure.library.*.$*
200 cd $* && ../ifBuildable/ifBuildable setup/Setup configure \
203 --with-compiler=$(bindir)/ghc \
207 # We need to reconfigure as we now need to register with the normal ghc-pkg
208 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
209 install.library.%: stamp/configure.library.install.% %/setup/Setup
210 cd $* && ../ifBuildable/ifBuildable setup/Setup install
212 .PHONY: distclean clean clean.library.%
216 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
217 $(RM) -f stamp/$(BOOTSTRAPPING_CABAL)
218 $(RM) -rf $(BOOTSTRAPPING_CABAL)
219 $(RM) -rf ifBuildable
220 $(RM) -f libraries.txt index.html doc-index.html
222 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
224 $(RM) -f stamp/configure.library.*.$*
225 -cd $* && setup/Setup clean