Don't break when asked to install-docs
[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 \
16           regex-base regex-posix regex-compat parsec Cabal
17
18 ifeq "$(GhcLibsWithUnix)" "YES"
19 SUBDIRS += unix
20 endif
21 ifeq "$(Windows)" "YES"
22 SUBDIRS += $(wildcard Win32)
23 endif
24
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)
41 endif
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)
51 endif
52 endif
53
54 # -----------------------------------------------------------------------------
55
56 empty=
57 space=$(empty) $(empty)
58
59 CONFIGURE_OPTS =
60 CONFIGURE_STAMP_EXTRAS :=
61
62 ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
63 CONFIGURE_OPTS += --enable-library-profiling
64 CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
65 endif
66
67 BOOTSTRAPPING_CABAL = bootstrapping.cabal
68
69 .PHONY: subdirs
70
71 subdirs:
72         @echo $(SUBDIRS)
73
74 .PHONY: boot
75
76 boot: $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup)
77         # XXX Hideous hacks:
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
80
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.
84
85 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
86
87 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
88 %/setup/Setup: stamp/$(BOOTSTRAPPING_CABAL)
89         -$(RM) -rf $*/setup
90         mkdir $*/setup
91         $(CP) $*/Setup.*hs $*/setup
92         cd $*/setup && $(GHC) --make -i../../$(BOOTSTRAPPING_CABAL) Setup.*hs -o Setup
93
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 {} \;
98         touch $@
99
100 .PHONY: all build configure
101
102 all: build
103
104 ifneq "$(NO_HADDOCK_DOCS)" "YES"
105 all: doc
106 endif
107
108 build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))
109
110 configure: $(foreach SUBDIR,$(SUBDIRS), \
111              stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))
112
113 .PHONY: build.library.%
114
115 # We should depend on %/%.cabal here (and in other rules), but make
116 # makes that difficult.
117
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 \
123                              $(CONFIGURE_OPTS) \
124                              --prefix=$(prefix) \
125                              --with-compiler=../../compiler/ghc-inplace \
126                              --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \
127                              --datasubdir=ghc \
128                                                  --haddock-args="--use-contents=../index.html --use-index=../doc-index.html"
129         touch $@
130
131 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
132 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
133                  %/setup/Setup
134         cd $* && setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts))
135         cd $* && setup/Setup register --inplace
136
137 .PHONY: doc
138
139 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
140
141 doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
142         sh gen_contents_index
143
144 $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
145 doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
146                %/setup/Setup
147         cd $* && setup/Setup haddock
148
149 .PHONY: install install-docs install.library.%
150
151 INSTALL_DIR=$(prefix)/share/ghc/doc/html/
152
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)
156         # Hacks:
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)
160
161 # Cabal doesn't let us ask to install docs only, so do nothing here
162 install-docs:
163         @:
164
165 # Ideally this would depend on a stamp/build.library.%, but if it does
166 # then we can't change the libraries and then just rerun make.
167 # Thus if you install without building then it will just break.
168 $(foreach SUBDIR,$(SUBDIRS),stamp/configure.library.install.$(SUBDIR)): \
169 stamp/configure.library.install.%: %/setup/Setup
170         -$(RM) -f stamp/configure.library.*.$*
171         cd $* && setup/Setup configure $(CONFIGURE_OPTS) \
172                                        --prefix=$(prefix) \
173                                        --with-compiler=$(bindir)/ghc \
174                                        --datasubdir=ghc
175         touch $@
176
177 # We need to reconfigure as we now need to register with the normal ghc-pkg
178 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
179 install.library.%: stamp/configure.library.install.% %/setup/Setup
180         cd $* && setup/Setup install
181
182 .PHONY: clean clean.library.%
183
184 clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
185         $(RM) -f stamp/$(BOOTSTRAPPING_CABAL)
186         $(RM) -rf $(BOOTSTRAPPING_CABAL)
187         $(RM) -f libraries.txt index.html doc-index.html
188
189 $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
190 clean.library.%:
191         $(RM) -f stamp/configure.library.*.$*
192         -cd $* && setup/Setup clean
193         $(RM) -rf $*/setup
194