7 include $(TOP)/mk/boilerplate.mk
9 SUBDIRS = base filepath haskell98 template-haskell readline \
10 regex-base regex-posix regex-compat parsec Cabal
12 ifeq "$(GhcLibsWithUnix)" "YES"
15 ifeq "$(Windows)" "YES"
16 SUBDIRS += $(wildcard Win32)
19 # Set GhcBootLibs=YES from the command line to work with just the libraries
20 # needed to bootstrap GHC.
21 ifneq "$(GhcBootLibs)" "YES"
22 SUBDIRS += $(wildcard haskell-src)
23 SUBDIRS += $(wildcard html)
24 SUBDIRS += $(wildcard network)
25 SUBDIRS += $(wildcard QuickCheck)
26 SUBDIRS += $(wildcard HUnit)
27 SUBDIRS += $(wildcard mtl)
28 SUBDIRS += $(wildcard fgl)
29 SUBDIRS += $(wildcard X11)
30 SUBDIRS += $(wildcard time)
31 ifeq "$(Windows)" "NO"
32 # HGL is not working on Win32, so omit it for now. Better not to ship it
33 # at all than to ship a broken version.
34 SUBDIRS += $(wildcard HGL)
36 SUBDIRS += $(wildcard OpenGL)
37 SUBDIRS += $(wildcard GLUT)
38 SUBDIRS += $(wildcard OpenAL)
39 SUBDIRS += $(wildcard ALUT)
40 SUBDIRS += $(wildcard stm)
41 SUBDIRS += $(wildcard xhtml)
42 SUBDIRS += $(wildcard cgi)
43 ifeq "$(GhcLibsWithObjectIO)" "YES"
44 SUBDIRS += $(wildcard ObjectIO)
48 # -----------------------------------------------------------------------------
51 space=$(empty) $(empty)
54 CONFIGURE_STAMP_EXTRAS :=
56 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
57 CONFIGURE_OPTS += --enable-library-profiling
58 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
61 BOOTSTRAPPING_CABAL = bootstrapping.cabal
65 boot: $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup)
67 $(GENPRIMOP) --make-haskell-source < ../compiler/prelude/primops.txt > base/GHC/Prim.hs
68 $(GENPRIMOP) --make-haskell-wrappers < ../compiler/prelude/primops.txt > base/GHC/PrimopWrappers.hs
70 # We build the Setup program in a setup subdirectory to stop it trying
71 # to use bits of base and Cabal when we build those packages.
72 # This also makes it slightly easier to clean.
74 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
76 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
77 %/setup/Setup: stamp/$(BOOTSTRAPPING_CABAL)
80 $(CP) $*/Setup.*hs $*/setup
81 cd $*/setup && $(GHC) --make -i../../$(BOOTSTRAPPING_CABAL) Setup.*hs -o Setup
83 stamp/$(BOOTSTRAPPING_CABAL):
84 $(RM) -rf $(BOOTSTRAPPING_CABAL)
85 $(CP) -a Cabal $(BOOTSTRAPPING_CABAL)
86 $(FIND) $(BOOTSTRAPPING_CABAL) \( -name "*.o" -o -name "*.hi" \) -exec $(RM) -f {} \;
89 .PHONY: all build configure
93 ifneq "$(NO_HADDOCK_DOCS)" "YES"
97 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
99 configure: $(foreach SUBDIR,$(SUBDIRS), \
100 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
102 .PHONY: build.library.%
104 # We should depend on %/%.cabal here (and in other rules), but make
105 # makes that difficult.
107 $(foreach SUBDIR,$(SUBDIRS), \
108 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
109 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
110 -$(RM) -f stamp/configure.library.*.$*
111 cd $* && setup/Setup configure \
114 --with-compiler=../../compiler/ghc-inplace \
115 --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \
117 --haddock-args="--use-contents=../index.html --use-index=../doc-index.html"
120 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
121 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
123 cd $* && setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts))
124 cd $* && setup/Setup register --inplace
128 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
130 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
131 sh gen_contents_index
133 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
134 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
136 cd $* && setup/Setup haddock
138 .PHONY: install.library.%
140 INSTALL_DIR=$(prefix)/share/ghc/doc/html/
142 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
143 $(INSTALL_DATA) index.html doc-index.html $(INSTALL_DIR)
144 $(INSTALL_SCRIPT) gen_contents_index $(INSTALL_DIR)
146 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
147 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.js $(INSTALL_DIR)
148 $(INSTALL_DATA) $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
150 # Ideally this would depend on a stamp/build.library.%, but if it does
151 # then we can't change the libraries and then just rerun make.
152 # Thus if you install without building then it will just break.
153 $(foreach SUBDIR,$(SUBDIRS),stamp/configure.library.install.$(SUBDIR)): \
154 stamp/configure.library.install.%: %/setup/Setup
155 -$(RM) -f stamp/configure.library.*.$*
156 cd $* && setup/Setup configure $(CONFIGURE_OPTS) \
158 --with-compiler=$(bindir)/ghc \
162 # We need to reconfigure as we now need to register with the normal ghc-pkg
163 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
164 install.library.%: stamp/configure.library.install.% %/setup/Setup
165 cd $* && setup/Setup install
167 .PHONY: clean clean.library.%
169 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
170 $(RM) -f stamp/$(BOOTSTRAPPING_CABAL)
171 $(RM) -rf $(BOOTSTRAPPING_CABAL)
172 $(RM) -f libraries.txt index.html doc-index.html
174 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
176 $(RM) -f stamp/configure.library.*.$*
177 -cd $* && setup/Setup clean