6 ifeq "$(IN_BIN_DIST)" "1"
7 include ../Makefile-vars
10 include $(TOP)/mk/boilerplate.mk
13 SUBDIRS = base filepath haskell98 template-haskell readline \
14 regex-base regex-posix regex-compat parsec Cabal
16 ifeq "$(GhcLibsWithUnix)" "YES"
19 ifeq "$(Windows)" "YES"
20 SUBDIRS += $(wildcard Win32)
23 # Set GhcBootLibs=YES from the command line to work with just the libraries
24 # needed to bootstrap GHC.
25 ifneq "$(GhcBootLibs)" "YES"
26 SUBDIRS += $(wildcard haskell-src)
27 SUBDIRS += $(wildcard html)
28 SUBDIRS += $(wildcard network)
29 SUBDIRS += $(wildcard QuickCheck)
30 SUBDIRS += $(wildcard HUnit)
31 SUBDIRS += $(wildcard mtl)
32 SUBDIRS += $(wildcard fgl)
33 SUBDIRS += $(wildcard X11)
34 SUBDIRS += $(wildcard time)
35 ifeq "$(Windows)" "NO"
36 # HGL is not working on Win32, so omit it for now. Better not to ship it
37 # at all than to ship a broken version.
38 SUBDIRS += $(wildcard HGL)
40 SUBDIRS += $(wildcard OpenGL)
41 SUBDIRS += $(wildcard GLUT)
42 SUBDIRS += $(wildcard OpenAL)
43 SUBDIRS += $(wildcard ALUT)
44 SUBDIRS += $(wildcard stm)
45 SUBDIRS += $(wildcard xhtml)
46 SUBDIRS += $(wildcard cgi)
47 ifeq "$(GhcLibsWithObjectIO)" "YES"
48 SUBDIRS += $(wildcard ObjectIO)
52 # -----------------------------------------------------------------------------
55 space=$(empty) $(empty)
58 CONFIGURE_STAMP_EXTRAS :=
60 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
61 CONFIGURE_OPTS += --enable-library-profiling
62 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
65 BOOTSTRAPPING_CABAL = bootstrapping.cabal
74 boot: $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup)
76 $(GENPRIMOP) --make-haskell-source < ../compiler/prelude/primops.txt > base/GHC/Prim.hs
77 $(GENPRIMOP) --make-haskell-wrappers < ../compiler/prelude/primops.txt > base/GHC/PrimopWrappers.hs
79 # We build the Setup program in a setup subdirectory to stop it trying
80 # to use bits of base and Cabal when we build those packages.
81 # This also makes it slightly easier to clean.
83 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
85 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
86 %/setup/Setup: stamp/$(BOOTSTRAPPING_CABAL)
89 $(CP) $*/Setup.*hs $*/setup
90 cd $*/setup && $(GHC) --make -i../../$(BOOTSTRAPPING_CABAL) Setup.*hs -o Setup
92 stamp/$(BOOTSTRAPPING_CABAL):
93 $(RM) -rf $(BOOTSTRAPPING_CABAL)
94 $(CP) -a Cabal $(BOOTSTRAPPING_CABAL)
95 $(FIND) $(BOOTSTRAPPING_CABAL) \( -name "*.o" -o -name "*.hi" \) -exec $(RM) -f {} \;
98 .PHONY: all build configure
102 ifneq "$(NO_HADDOCK_DOCS)" "YES"
106 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
108 configure: $(foreach SUBDIR,$(SUBDIRS), \
109 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
111 .PHONY: build.library.%
113 # We should depend on %/%.cabal here (and in other rules), but make
114 # makes that difficult.
116 $(foreach SUBDIR,$(SUBDIRS), \
117 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
118 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
119 -$(RM) -f stamp/configure.library.*.$*
120 cd $* && setup/Setup configure \
123 --with-compiler=../../compiler/ghc-inplace \
124 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \
126 --haddock-args="--use-contents=../index.html --use-index=../doc-index.html"
129 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
130 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
132 cd $* && setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts))
133 cd $* && setup/Setup register --inplace
137 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
139 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
140 sh gen_contents_index
142 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
143 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
145 cd $* && setup/Setup haddock
147 .PHONY: install.library.%
149 INSTALL_DIR=$(prefix)/share/ghc/doc/html/
151 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
152 $(INSTALL_DATA) index.html doc-index.html $(INSTALL_DIR)
153 $(INSTALL_SCRIPT) gen_contents_index $(INSTALL_DIR)
155 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
156 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(INSTALL_DIR)
157 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
159 # Ideally this would depend on a stamp/build.library.%, but if it does
160 # then we can't change the libraries and then just rerun make.
161 # Thus if you install without building then it will just break.
162 $(foreach SUBDIR,$(SUBDIRS),stamp/configure.library.install.$(SUBDIR)): \
163 stamp/configure.library.install.%: %/setup/Setup
164 -$(RM) -f stamp/configure.library.*.$*
165 cd $* && setup/Setup configure $(CONFIGURE_OPTS) \
167 --with-compiler=$(bindir)/ghc \
171 # We need to reconfigure as we now need to register with the normal ghc-pkg
172 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
173 install.library.%: stamp/configure.library.install.% %/setup/Setup
174 cd $* && setup/Setup install
176 .PHONY: clean clean.library.%
178 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
179 $(RM) -f stamp/$(BOOTSTRAPPING_CABAL)
180 $(RM) -rf $(BOOTSTRAPPING_CABAL)
181 $(RM) -f libraries.txt index.html doc-index.html
183 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
185 $(RM) -f stamp/configure.library.*.$*
186 -cd $* && setup/Setup clean