Improve documentation for transform list-comps
[ghc.git] / Makefile
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 # http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 # Eliminate use of the built-in implicit rules, and clear out the default list
14 # of suffixes for suffix rules. Speeds up make quite a bit. Both are needed
15 # for the shortest `make -d` output.
16 # Don't set --no-builtin-variables; some rules might stop working if you do
17 # (e.g. 'make clean' in testsuite/ currently relies on an implicit $RM).
18 MAKEFLAGS += --no-builtin-rules
19 .SUFFIXES:
20
21 ifeq "$(wildcard distrib/)" ""
22
23 # We're in a bindist
24
25 .PHONY: default
26 default:
27 @echo 'Run "make install" to install'
28 @false
29
30 .PHONY: install show
31 install show:
32 $(MAKE) --no-print-directory -f ghc.mk $@ BINDIST=YES NO_INCLUDE_DEPS=YES
33
34 # Note [install-strip]
35 #
36 # install-strip is like install, but it strips the executable files while
37 # installing them.
38 #
39 # From http://www.gnu.org/prep/standards/html_node/Standard-Targets.html:
40 #
41 # "install-strip should not strip the executables in the build directory
42 # which are being copied for installation. It should only strip the copies
43 # that are installed. "
44
45 .PHONY: install-strip
46 install-strip:
47 # See Note [install-strip].
48 $(MAKE) --no-print-directory -f ghc.mk INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
49
50 else
51
52 .PHONY: default
53 default : all
54 @:
55
56 # For help, type 'make help'
57 .PHONY: help
58 help:
59 @cat MAKEHELP.md
60
61 ifneq "$(filter maintainer-clean distclean clean clean_% help,$(MAKECMDGOALS))" ""
62 -include mk/config.mk
63 else
64 include mk/config.mk
65 ifeq "$(ProjectVersion)" ""
66 $(error Please run ./configure first)
67 endif
68 endif
69
70 include mk/custom-settings.mk
71
72 # Verify that stage 0 LLVM backend isn't affected by Bug #9439 if needed
73 ifeq "$(GHC_LLVM_AFFECTED_BY_9439)" "1"
74 ifneq "$(findstring -fllvm,$(SRC_HC_OPTS) $(GhcHcOpts) $(GhcStage1HcOpts))" ""
75 $(error Stage 0 compiler is affected by Bug #9439. Refusing to bootstrap with -fllvm)
76 endif
77 endif
78
79 # No need to update makefiles for these targets:
80 # (the ones we're filtering out)
81 REALGOALS=$(filter-out \
82 binary-dist \
83 binary-dist-prep \
84 install-strip \
85 sdist sdist-ghc \
86 sdist-ghc-prep \
87 sdist-windows-tarballs \
88 sdist-windows-tarballs-prep \
89 sdist-testsuite \
90 sdist-testsuite-prep \
91 bootstrapping-files \
92 framework-pkg \
93 clean \
94 clean_% \
95 distclean \
96 maintainer-clean \
97 show \
98 show! \
99 echo \
100 help \
101 test \
102 fulltest \
103 slowtest \
104 fasttest \
105 ,$(MAKECMDGOALS))
106
107 # configure touches certain files even if they haven't changed. This
108 # can mean a lot of unnecessary recompilation after a re-configure, so
109 # here we cache the old versions of these files so we can restore the
110 # timestamps.
111 %.old: %
112 @set -x && test -f $@ && cmp -s $< $@ || cp -p $< $@
113 touch -r $@ $<
114
115
116 # NB. not the same as saying '%: ...', which doesn't do the right thing:
117 # it does nothing if we specify a target that already exists.
118 .PHONY: $(REALGOALS) all
119 $(REALGOALS) all: mk/config.mk.old mk/project.mk.old compiler/ghc.cabal.old
120 ifneq "$(OMIT_PHASE_0)" "YES"
121 @echo "===--- building phase 0"
122 $(MAKE) --no-print-directory -f ghc.mk phase=0 phase_0_builds
123 endif
124 ifneq "$(OMIT_PHASE_1)" "YES"
125 @echo "===--- building phase 1"
126 $(MAKE) --no-print-directory -f ghc.mk phase=1 phase_1_builds
127 endif
128 @echo "===--- building final phase"
129 $(MAKE) --no-print-directory -f ghc.mk phase=final $@
130
131 .PHONY: binary-dist
132 binary-dist: binary-dist-prep
133 mv bindistprep/*.tar.$(TAR_COMP_EXT) .
134
135 .PHONY: binary-dist-prep
136 binary-dist-prep:
137 ifeq "$(mingw32_TARGET_OS)" "1"
138 $(MAKE) --no-print-directory -f ghc.mk windows-binary-dist-prep
139 else
140 rm -f bindist-list
141 $(MAKE) --no-print-directory -f ghc.mk bindist-list BINDIST=YES
142 $(MAKE) --no-print-directory -f ghc.mk unix-binary-dist-prep
143 endif
144
145 .PHONY: install-strip
146 install-strip:
147 # See Note [install-strip].
148 $(MAKE) --no-print-directory -f ghc.mk INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
149
150 .PHONY: sdist sdist-ghc sdist-ghc-prep sdist-windows-tarballs sdist-windows-tarballs-prep sdist-testsuite sdist-testsuite-prep
151 # Just running `./boot && ./configure && make sdist` should work, so skip
152 # phase 0 and 1 and don't build any dependency files.
153 sdist sdist-ghc sdist-ghc-prep sdist-windows-tarballs sdist-windows-tarballs-prep sdist-testsuite sdist-testsuite-prep :
154 $(MAKE) --no-print-directory -f ghc.mk $@ NO_INCLUDE_DEPS=YES NO_INCLUDE_PKGDATA=YES
155
156 .PHONY: clean distclean maintainer-clean
157 clean distclean maintainer-clean:
158 $(MAKE) --no-print-directory -f ghc.mk $@ CLEANING=YES
159 test ! -d testsuite || $(MAKE) -C testsuite $@
160
161 .PHONY: $(filter clean_%,$(MAKECMDGOALS))
162 $(filter clean_%, $(MAKECMDGOALS)) : clean_% :
163 $(MAKE) --no-print-directory -f ghc.mk $@ CLEANING=YES
164
165 .PHONY: bootstrapping-files show echo
166 bootstrapping-files show echo:
167 $(MAKE) --no-print-directory -f ghc.mk $@
168
169 .PHONY: show!
170 show!:
171 $(MAKE) --no-print-directory -f ghc.mk show NO_INCLUDE_PKGDATA=YES
172
173 ifeq "$(darwin_TARGET_OS)" "1"
174 .PHONY: framework-pkg
175 framework-pkg:
176 $(MAKE) -C distrib/MacOS $@
177 endif
178
179 # If the user says 'make A B', then we don't want to invoke two
180 # instances of the rule above in parallel:
181 .NOTPARALLEL:
182
183 endif
184
185 # Note [validate and testsuite speed]
186 #
187 # There are 3 different validate and testsuite speed settings:
188 # fast, normal and slow.
189 #
190 # how how used
191 # cd tests config. many many by
192 # validate && make speed= tests ways whom
193 # =============================================================================
194 # --fast fast 2 some 1 Travis (to stay within time limit)
195 # --normal test 1 all 1 Phabricator (slow takes too long?)
196 # --slow slow 0 all all Nightly (slow is ok)
197 #
198 # accept 1 all 1
199 #
200 # `make accept` should run all tests exactly once. There is no point in
201 # accepting a test for multiple ways, since it should produce the same output
202 # for all ways.
203 #
204 # To make sure all .stderr and .stdout files in the testsuite are never
205 # out-of-date, it is useful if Phabricator, via a normal `./validate` and `make
206 # test`, runs each test at least once.
207 .PHONY: fasttest
208 fasttest:
209 $(MAKE) -C testsuite/tests CLEANUP=1 SUMMARY_FILE=../../testsuite_summary.txt fast
210
211 .PHONY: test
212 test:
213 $(MAKE) -C testsuite/tests CLEANUP=1 SUMMARY_FILE=../../testsuite_summary.txt
214
215 .PHONY: slowtest fulltest
216 slowtest fulltest:
217 $(MAKE) -C testsuite/tests CLEANUP=1 SUMMARY_FILE=../../testsuite_summary.txt slow