parsec, regex-base, regex-compat, regex-posix are no longer core-packages
[ghc-hetmet.git] / libraries / Makefile
1
2 .PHONY: default_target
3
4 default_target: build
5
6 ifeq "$(IN_BIN_DIST)" "1"
7 include ../Makefile-vars
8 else
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.
11 TOP=.
12 include $(TOP)/mk/boilerplate.mk
13 endif
14
15 SUBDIRS = base filepath haskell98 template-haskell readline Cabal
16
17 ifeq "$(GhcLibsWithUnix)" "YES"
18 SUBDIRS += unix
19 endif
20 ifeq "$(Windows)" "YES"
21 SUBDIRS += $(wildcard Win32)
22 endif
23
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)
44 endif
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)
54 endif
55 endif
56
57 # -----------------------------------------------------------------------------
58
59 empty=
60 space=$(empty) $(empty)
61
62 ifeq "$(Windows)" "YES"
63 dot_bat=.bat
64 else
65 dot_bat=
66 endif
67
68 CONFIGURE_OPTS =
69 CONFIGURE_STAMP_EXTRAS :=
70
71 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
72 CONFIGURE_OPTS += --enable-library-profiling
73 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
74 endif
75
76 BOOTSTRAPPING_CABAL = bootstrapping.cabal
77
78 .PHONY: subdirs
79
80 subdirs:
81         @echo $(SUBDIRS)
82
83 .PHONY: boot
84
85 boot: $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup)
86         # XXX Hideous hacks:
87         $(GENPRIMOP) --make-haskell-source < ../compiler/prelude/primops.txt > base/GHC/Prim.hs
88         $(GENPRIMOP) --make-haskell-wrappers < ../compiler/prelude/primops.txt > base/GHC/PrimopWrappers.hs
89
90 # We build the Setup program in a setup subdirectory to stop it trying
91 # to use bits of base and Cabal when we build those packages.
92 # This also makes it slightly easier to clean.
93
94 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
95
96 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
97 %/setup/Setup: stamp/$(BOOTSTRAPPING_CABAL)
98         -$(RM) -rf $*/setup
99         mkdir $*/setup
100         $(CP) $*/Setup.*hs $*/setup
101         cd $*/setup && $(GHC) --make -i../../$(BOOTSTRAPPING_CABAL) Setup.*hs -o Setup
102
103 stamp/$(BOOTSTRAPPING_CABAL):
104         $(RM) -rf $(BOOTSTRAPPING_CABAL)
105         $(CP) -R Cabal $(BOOTSTRAPPING_CABAL)
106         $(FIND) $(BOOTSTRAPPING_CABAL) \( -name "*.o" -o -name "*.hi" \) -exec $(RM) -f {} \;
107         touch $@
108
109 .PHONY: all build configure
110
111 all: build
112
113 ifneq "$(NO_HADDOCK_DOCS)" "YES"
114 all: doc
115 endif
116
117 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
118
119 configure: $(foreach SUBDIR,$(SUBDIRS), \
120              stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
121
122 .PHONY: build.library.%
123
124 # We should depend on %/%.cabal here (and in other rules), but make
125 # makes that difficult.
126
127 $(foreach SUBDIR,$(SUBDIRS), \
128                   stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
129 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
130         -$(RM) -f stamp/configure.library.*.$*
131         cd $* && setup/Setup configure \
132                              $(CONFIGURE_OPTS) \
133                              --prefix=$(prefix) \
134                              --with-compiler=../../compiler/ghc-inplace$(dot_bat) \
135                              --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \
136                              --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \
137                              --with-ld=$(LD) \
138                              --datasubdir=ghc \
139                              --haddock-args="--use-contents=../index.html --use-index=../doc-index.html" \
140                              --configure-option=--with-cc=$(CC)
141         touch $@
142
143 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
144 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
145                  %/setup/Setup
146         cd $* && setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts))
147         cd $* && setup/Setup register --inplace
148
149 .PHONY: doc
150
151 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
152
153 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
154         sh gen_contents_index
155
156 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
157 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
158                %/setup/Setup
159         cd $* && setup/Setup haddock
160
161 .PHONY: install install-docs install.library.%
162
163 INSTALL_DIR=$(prefix)/share/ghc/doc/html/
164
165 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
166         $(INSTALL_DATA)   index.html doc-index.html                       $(INSTALL_DIR)
167         $(INSTALL_SCRIPT) gen_contents_index                                      $(INSTALL_DIR)
168         # Hacks:
169         $(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
170         $(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.js  $(INSTALL_DIR)
171         $(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
172
173 # Cabal doesn't let us ask to install docs only, so do nothing here
174 install-docs:
175         @:
176
177 # Ideally this would depend on a stamp/build.library.%, but if it does
178 # then we can't change the libraries and then just rerun make.
179 # Thus if you install without building then it will just break.
180 $(foreach SUBDIR,$(SUBDIRS),stamp/configure.library.install.$(SUBDIR)): \
181 stamp/configure.library.install.%: %/setup/Setup
182         -$(RM) -f stamp/configure.library.*.$*
183         cd $* && setup/Setup configure $(CONFIGURE_OPTS) \
184                                        --prefix=$(prefix) \
185                                        --with-compiler=$(bindir)/ghc \
186                                        --datasubdir=ghc
187         touch $@
188
189 # We need to reconfigure as we now need to register with the normal ghc-pkg
190 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
191 install.library.%: stamp/configure.library.install.% %/setup/Setup
192         cd $* && setup/Setup install
193
194 .PHONY: clean clean.library.%
195
196 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
197         $(RM) -f stamp/$(BOOTSTRAPPING_CABAL)
198         $(RM) -rf $(BOOTSTRAPPING_CABAL)
199         $(RM) -f libraries.txt index.html doc-index.html
200
201 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
202 clean.library.%:
203         $(RM) -f stamp/configure.library.*.$*
204         -cd $* && setup/Setup clean
205         $(RM) -rf $*/setup
206