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)
60 CONFIGURE_STAMP_EXTRAS :=
62 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
63 CONFIGURE_OPTS += --enable-library-profiling
64 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
67 BOOTSTRAPPING_CABAL = bootstrapping.cabal
76 boot: $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup)
78 $(GENPRIMOP) --make-haskell-source < ../compiler/prelude/primops.txt > base/GHC/Prim.hs
79 $(GENPRIMOP) --make-haskell-wrappers < ../compiler/prelude/primops.txt > base/GHC/PrimopWrappers.hs
81 # We build the Setup program in a setup subdirectory to stop it trying
82 # to use bits of base and Cabal when we build those packages.
83 # This also makes it slightly easier to clean.
85 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
87 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
88 %/setup/Setup: stamp/$(BOOTSTRAPPING_CABAL)
91 $(CP) $*/Setup.*hs $*/setup
92 cd $*/setup && $(GHC) --make -i../../$(BOOTSTRAPPING_CABAL) Setup.*hs -o Setup
94 stamp/$(BOOTSTRAPPING_CABAL):
95 $(RM) -rf $(BOOTSTRAPPING_CABAL)
96 $(CP) -a Cabal $(BOOTSTRAPPING_CABAL)
97 $(FIND) $(BOOTSTRAPPING_CABAL) \( -name "*.o" -o -name "*.hi" \) -exec $(RM) -f {} \;
100 .PHONY: all build configure
104 ifneq "$(NO_HADDOCK_DOCS)" "YES"
108 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
110 configure: $(foreach SUBDIR,$(SUBDIRS), \
111 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
113 .PHONY: build.library.%
115 # We should depend on %/%.cabal here (and in other rules), but make
116 # makes that difficult.
118 $(foreach SUBDIR,$(SUBDIRS), \
119 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
120 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
121 -$(RM) -f stamp/configure.library.*.$*
122 cd $* && setup/Setup configure \
125 --with-compiler=../../compiler/ghc-inplace \
126 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \
128 --haddock-args="--use-contents=../index.html --use-index=../doc-index.html"
131 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
132 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
134 cd $* && setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts))
135 cd $* && setup/Setup register --inplace
139 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
141 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
142 sh gen_contents_index
144 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
145 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
147 cd $* && setup/Setup haddock
149 .PHONY: install.library.%
151 INSTALL_DIR=$(prefix)/share/ghc/doc/html/
153 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
154 $(INSTALL_DATA) index.html doc-index.html $(INSTALL_DIR)
155 $(INSTALL_SCRIPT) gen_contents_index $(INSTALL_DIR)
157 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
158 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(INSTALL_DIR)
159 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
161 # Ideally this would depend on a stamp/build.library.%, but if it does
162 # then we can't change the libraries and then just rerun make.
163 # Thus if you install without building then it will just break.
164 $(foreach SUBDIR,$(SUBDIRS),stamp/configure.library.install.$(SUBDIR)): \
165 stamp/configure.library.install.%: %/setup/Setup
166 -$(RM) -f stamp/configure.library.*.$*
167 cd $* && setup/Setup configure $(CONFIGURE_OPTS) \
169 --with-compiler=$(bindir)/ghc \
173 # We need to reconfigure as we now need to register with the normal ghc-pkg
174 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
175 install.library.%: stamp/configure.library.install.% %/setup/Setup
176 cd $* && setup/Setup install
178 .PHONY: clean clean.library.%
180 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
181 $(RM) -f stamp/$(BOOTSTRAPPING_CABAL)
182 $(RM) -rf $(BOOTSTRAPPING_CABAL)
183 $(RM) -f libraries.txt index.html doc-index.html
185 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
187 $(RM) -f stamp/configure.library.*.$*
188 -cd $* && setup/Setup clean