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 \
16 regex-base regex-posix regex-compat parsec Cabal
18 ifeq "$(GhcLibsWithUnix)" "YES"
21 ifeq "$(Windows)" "YES"
22 SUBDIRS += $(wildcard Win32)
25 # Set GhcBootLibs=YES from the command line to work with just the libraries
26 # needed to bootstrap GHC.
27 ifneq "$(GhcBootLibs)" "YES"
28 SUBDIRS += $(wildcard haskell-src)
29 SUBDIRS += $(wildcard html)
30 SUBDIRS += $(wildcard network)
31 SUBDIRS += $(wildcard QuickCheck)
32 SUBDIRS += $(wildcard HUnit)
33 SUBDIRS += $(wildcard mtl)
34 SUBDIRS += $(wildcard fgl)
35 SUBDIRS += $(wildcard X11)
36 SUBDIRS += $(wildcard time)
37 ifeq "$(Windows)" "NO"
38 # HGL is not working on Win32, so omit it for now. Better not to ship it
39 # at all than to ship a broken version.
40 SUBDIRS += $(wildcard HGL)
42 SUBDIRS += $(wildcard OpenGL)
43 SUBDIRS += $(wildcard GLUT)
44 SUBDIRS += $(wildcard OpenAL)
45 SUBDIRS += $(wildcard ALUT)
46 SUBDIRS += $(wildcard stm)
47 SUBDIRS += $(wildcard xhtml)
48 SUBDIRS += $(wildcard cgi)
49 ifeq "$(GhcLibsWithObjectIO)" "YES"
50 SUBDIRS += $(wildcard ObjectIO)
54 # -----------------------------------------------------------------------------
57 space=$(empty) $(empty)
59 ifeq "$(Windows)" "YES"
66 CONFIGURE_STAMP_EXTRAS :=
68 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
69 CONFIGURE_OPTS += --enable-library-profiling
70 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
73 BOOTSTRAPPING_CABAL = bootstrapping.cabal
82 boot: $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup)
84 $(GENPRIMOP) --make-haskell-source < ../compiler/prelude/primops.txt > base/GHC/Prim.hs
85 $(GENPRIMOP) --make-haskell-wrappers < ../compiler/prelude/primops.txt > base/GHC/PrimopWrappers.hs
87 # We build the Setup program in a setup subdirectory to stop it trying
88 # to use bits of base and Cabal when we build those packages.
89 # This also makes it slightly easier to clean.
91 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
93 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
94 %/setup/Setup: stamp/$(BOOTSTRAPPING_CABAL)
97 $(CP) $*/Setup.*hs $*/setup
98 cd $*/setup && $(GHC) --make -i../../$(BOOTSTRAPPING_CABAL) Setup.*hs -o Setup
100 stamp/$(BOOTSTRAPPING_CABAL):
101 $(RM) -rf $(BOOTSTRAPPING_CABAL)
102 $(CP) -a Cabal $(BOOTSTRAPPING_CABAL)
103 $(FIND) $(BOOTSTRAPPING_CABAL) \( -name "*.o" -o -name "*.hi" \) -exec $(RM) -f {} \;
106 .PHONY: all build configure
110 ifneq "$(NO_HADDOCK_DOCS)" "YES"
114 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
116 configure: $(foreach SUBDIR,$(SUBDIRS), \
117 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
119 .PHONY: build.library.%
121 # We should depend on %/%.cabal here (and in other rules), but make
122 # makes that difficult.
124 $(foreach SUBDIR,$(SUBDIRS), \
125 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
126 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
127 -$(RM) -f stamp/configure.library.*.$*
128 cd $* && setup/Setup configure \
131 --with-compiler=../../compiler/ghc-inplace$(dot_bat) \
132 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \
133 --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \
136 --haddock-args="--use-contents=../index.html --use-index=../doc-index.html" \
137 --configure-option=--with-cc=$(CC)
140 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
141 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
143 cd $* && setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts))
144 cd $* && setup/Setup register --inplace
148 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
150 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
151 sh gen_contents_index
153 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
154 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
156 cd $* && setup/Setup haddock
158 .PHONY: install install-docs install.library.%
160 INSTALL_DIR=$(prefix)/share/ghc/doc/html/
162 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
163 $(INSTALL_DATA) index.html doc-index.html $(INSTALL_DIR)
164 $(INSTALL_SCRIPT) gen_contents_index $(INSTALL_DIR)
166 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
167 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(INSTALL_DIR)
168 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
170 # Cabal doesn't let us ask to install docs only, so do nothing here
174 # Ideally this would depend on a stamp/build.library.%, but if it does
175 # then we can't change the libraries and then just rerun make.
176 # Thus if you install without building then it will just break.
177 $(foreach SUBDIR,$(SUBDIRS),stamp/configure.library.install.$(SUBDIR)): \
178 stamp/configure.library.install.%: %/setup/Setup
179 -$(RM) -f stamp/configure.library.*.$*
180 cd $* && setup/Setup configure $(CONFIGURE_OPTS) \
182 --with-compiler=$(bindir)/ghc \
186 # We need to reconfigure as we now need to register with the normal ghc-pkg
187 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
188 install.library.%: stamp/configure.library.install.% %/setup/Setup
189 cd $* && setup/Setup install
191 .PHONY: clean clean.library.%
193 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
194 $(RM) -f stamp/$(BOOTSTRAPPING_CABAL)
195 $(RM) -rf $(BOOTSTRAPPING_CABAL)
196 $(RM) -f libraries.txt index.html doc-index.html
198 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
200 $(RM) -f stamp/configure.library.*.$*
201 -cd $* && setup/Setup clean