Makefile 6.94 KB
Newer Older
1

Ian Lynagh's avatar
Ian Lynagh committed
2
.PHONY: default_target
3

Ian Lynagh's avatar
Ian Lynagh committed
4
default_target: build
5

6
7
8
ifeq "$(IN_BIN_DIST)" "1"
include ../Makefile-vars
else
Ian Lynagh's avatar
Ian Lynagh committed
9
10
# Ideally we'd just include something to give us variables
# for paths and arguments to tools etc, and those set in mk/build.mk.
Ian Lynagh's avatar
Ian Lynagh committed
11
12
TOP=.
include $(TOP)/mk/boilerplate.mk
13
endif
Simon Marlow's avatar
Simon Marlow committed
14

15
SUBDIRS = base filepath haskell98 template-haskell readline Cabal
16
17
18
19

ifeq "$(GhcLibsWithUnix)" "YES"
SUBDIRS += unix
endif
20
21
22
ifeq "$(Windows)" "YES"
SUBDIRS += $(wildcard Win32)
endif
23
24
25
26

# Set GhcBootLibs=YES from the command line to work with just the libraries
# needed to bootstrap GHC.
ifneq "$(GhcBootLibs)" "YES"
27
28
29
30
SUBDIRS += $(wildcard regex-base)
SUBDIRS += $(wildcard regex-posix)
SUBDIRS += $(wildcard regex-compat)
SUBDIRS += $(wildcard parsec)
31
SUBDIRS += $(wildcard haskell-src)
32
SUBDIRS += $(wildcard html)
33
34
35
36
37
38
SUBDIRS += $(wildcard network)
SUBDIRS += $(wildcard QuickCheck)
SUBDIRS += $(wildcard HUnit)
SUBDIRS += $(wildcard mtl)
SUBDIRS += $(wildcard fgl)
SUBDIRS += $(wildcard X11)
39
SUBDIRS += $(wildcard time)
Simon Marlow's avatar
Simon Marlow committed
40
41
42
ifeq "$(Windows)" "NO"
# HGL is not working on Win32, so omit it for now.  Better not to ship it
# at all than to ship a broken version.
43
SUBDIRS += $(wildcard HGL)
Simon Marlow's avatar
Simon Marlow committed
44
endif
45
46
47
48
49
SUBDIRS += $(wildcard OpenGL)
SUBDIRS += $(wildcard GLUT)
SUBDIRS += $(wildcard OpenAL)
SUBDIRS += $(wildcard ALUT)
SUBDIRS += $(wildcard stm)
50
51
SUBDIRS += $(wildcard xhtml)
SUBDIRS += $(wildcard cgi)
52
53
54
55
56
57
58
ifeq "$(GhcLibsWithObjectIO)" "YES"
SUBDIRS += $(wildcard ObjectIO)
endif
endif

# -----------------------------------------------------------------------------

Ian Lynagh's avatar
Ian Lynagh committed
59
60
empty=
space=$(empty) $(empty)
61

62
63
64
65
66
67
ifeq "$(Windows)" "YES"
dot_bat=.bat
else
dot_bat=
endif

Ian Lynagh's avatar
Ian Lynagh committed
68
69
CONFIGURE_OPTS =
CONFIGURE_STAMP_EXTRAS :=
70

Ian Lynagh's avatar
Ian Lynagh committed
71
72
73
74
75
76
77
ifneq "$(findstring $(space)p$(space), $(space)$(GhcLibWays)$(space))" ""
CONFIGURE_OPTS += --enable-library-profiling
CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
endif

BOOTSTRAPPING_CABAL = bootstrapping.cabal

78
79
80
81
82
.PHONY: subdirs

subdirs:
	@echo $(SUBDIRS)

Ian Lynagh's avatar
Ian Lynagh committed
83
84
.PHONY: boot

Ian Lynagh's avatar
Ian Lynagh committed
85
86
boot: ifBuildable/ifBuildable \
	  $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup)
Ian Lynagh's avatar
Ian Lynagh committed
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
	# XXX Hideous hacks:
	$(GENPRIMOP) --make-haskell-source < ../compiler/prelude/primops.txt > base/GHC/Prim.hs
	$(GENPRIMOP) --make-haskell-wrappers < ../compiler/prelude/primops.txt > base/GHC/PrimopWrappers.hs

# We build the Setup program in a setup subdirectory to stop it trying
# to use bits of base and Cabal when we build those packages.
# This also makes it slightly easier to clean.

# We ought to be depending on %/Setup.*hs, but make makes that difficult.

$(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
%/setup/Setup: stamp/$(BOOTSTRAPPING_CABAL)
	-$(RM) -rf $*/setup
	mkdir $*/setup
	$(CP) $*/Setup.*hs $*/setup
102
	cd $*/setup && $(GHC) -Wall --make -i../../$(BOOTSTRAPPING_CABAL) Setup.*hs -o Setup
Ian Lynagh's avatar
Ian Lynagh committed
103

Ian Lynagh's avatar
Ian Lynagh committed
104
105
106
107
108
109
110
ifBuildable/ifBuildable: ifBuildable.hs stamp/$(BOOTSTRAPPING_CABAL)
	-$(RM) -rf ifBuildable
	mkdir ifBuildable
	$(CP) ifBuildable.hs ifBuildable/
	cd ifBuildable && $(GHC) -Wall --make -i../$(BOOTSTRAPPING_CABAL) \
	                         ifBuildable -o ifBuildable

Ian Lynagh's avatar
Ian Lynagh committed
111
112
stamp/$(BOOTSTRAPPING_CABAL):
	$(RM) -rf $(BOOTSTRAPPING_CABAL)
113
	$(CP) -R Cabal $(BOOTSTRAPPING_CABAL)
Ian Lynagh's avatar
Ian Lynagh committed
114
115
116
117
118
119
	$(FIND) $(BOOTSTRAPPING_CABAL) \( -name "*.o" -o -name "*.hi" \) -exec $(RM) -f {} \;
	touch $@

.PHONY: all build configure

all: build
120
121

ifneq "$(NO_HADDOCK_DOCS)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
all: doc
endif

build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR))

configure: $(foreach SUBDIR,$(SUBDIRS), \
             stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR))

.PHONY: build.library.%

# We should depend on %/%.cabal here (and in other rules), but make
# makes that difficult.

$(foreach SUBDIR,$(SUBDIRS), \
		  stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
	-$(RM) -f stamp/configure.library.*.$*
	cd $* && setup/Setup configure \
	                     $(CONFIGURE_OPTS) \
	                     --prefix=$(prefix) \
142
143
144
145
	                     --with-compiler=../../compiler/ghc-inplace$(dot_bat) \
	                     --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \
	                     --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \
	                     --with-ld=$(LD) \
Ian Lynagh's avatar
Ian Lynagh committed
146
	                     --datasubdir=ghc \
147
148
	                     --haddock-args="--use-contents=../index.html --use-index=../doc-index.html" \
	                     --configure-option=--with-cc=$(CC)
Ian Lynagh's avatar
Ian Lynagh committed
149
150
151
152
153
	touch $@

$(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
                 %/setup/Setup
Ian Lynagh's avatar
Ian Lynagh committed
154
155
156
	cd $* && ../ifBuildable/ifBuildable setup/Setup build \
	                                $(addprefix --ghc-option=,$(GhcLibHcOpts))
	cd $* && ../ifBuildable/ifBuildable setup/Setup register --inplace
Ian Lynagh's avatar
Ian Lynagh committed
157
158
159
160
161
162
163
164
165
166
167
168
169

.PHONY: doc

DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))

doc: $(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR))
	sh gen_contents_index

$(foreach SUBDIR,$(SUBDIRS),doc.library.$(SUBDIR)):\
doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
               %/setup/Setup
	cd $* && setup/Setup haddock

170
.PHONY: install install-docs install.library.%
Ian Lynagh's avatar
Ian Lynagh committed
171
172
173
174

INSTALL_DIR=$(prefix)/share/ghc/doc/html/

install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
175
ifneq "$(NO_HADDOCK_DOCS)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
176
177
178
179
180
181
	$(INSTALL_DATA)   index.html doc-index.html 			  $(INSTALL_DIR)
	$(INSTALL_SCRIPT) gen_contents_index 					  $(INSTALL_DIR)
	# Hacks:
	$(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
	$(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.js  $(INSTALL_DIR)
	$(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
182
endif
Ian Lynagh's avatar
Ian Lynagh committed
183

184
185
186
187
# Cabal doesn't let us ask to install docs only, so do nothing here
install-docs:
	@:

Ian Lynagh's avatar
Ian Lynagh committed
188
189
190
191
192
193
# Ideally this would depend on a stamp/build.library.%, but if it does
# then we can't change the libraries and then just rerun make.
# Thus if you install without building then it will just break.
$(foreach SUBDIR,$(SUBDIRS),stamp/configure.library.install.$(SUBDIR)): \
stamp/configure.library.install.%: %/setup/Setup
	-$(RM) -f stamp/configure.library.*.$*
Ian Lynagh's avatar
Ian Lynagh committed
194
195
196
197
198
	cd $* && ../ifBuildable/ifBuildable setup/Setup configure \
	                                    $(CONFIGURE_OPTS) \
	                                    --prefix=$(prefix) \
	                                    --with-compiler=$(bindir)/ghc \
	                                    --datasubdir=ghc
Ian Lynagh's avatar
Ian Lynagh committed
199
200
201
202
203
	touch $@

# We need to reconfigure as we now need to register with the normal ghc-pkg
$(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
install.library.%: stamp/configure.library.install.% %/setup/Setup
Ian Lynagh's avatar
Ian Lynagh committed
204
	cd $* && ../ifBuildable/ifBuildable setup/Setup install
Ian Lynagh's avatar
Ian Lynagh committed
205
206
207
208
209
210

.PHONY: clean clean.library.%

clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
	$(RM) -f stamp/$(BOOTSTRAPPING_CABAL)
	$(RM) -rf $(BOOTSTRAPPING_CABAL)
Ian Lynagh's avatar
Ian Lynagh committed
211
	$(RM) -rf ifBuildable
Ian Lynagh's avatar
Ian Lynagh committed
212
213
214
215
216
217
218
	$(RM) -f libraries.txt index.html doc-index.html

$(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
clean.library.%:
	$(RM) -f stamp/configure.library.*.$*
	-cd $* && setup/Setup clean
	$(RM) -rf $*/setup
219