Improve diagnostic when using `make fast` in top directory
[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
22 # -----------------------------------------------------------------------------
23 # Sanitize environment
24
25 # See Trac #11530
26 export GREP_OPTIONS :=
27
28 ifneq "$(filter maintainer-clean distclean clean clean_% help,$(MAKECMDGOALS))" ""
29 -include mk/config.mk
30 else
31 include mk/config.mk
32 ifeq "$(ProjectVersion)" ""
33 $(error Please run ./configure first)
34 endif
35 endif
36
37 include mk/custom-settings.mk
38
39
40 ifeq "$(wildcard distrib/)" ""
41
42 # We're in a bindist
43
44 .PHONY: default
45 default:
46 @echo 'Run "make install" to install'
47 @false
48
49 .PHONY: install show
50 install show:
51 $(MAKE) --no-print-directory -f ghc.mk $@ BINDIST=YES NO_INCLUDE_DEPS=YES
52
53 # Note [install-strip]
54 #
55 # install-strip is like install, but it strips the executable files while
56 # installing them.
57 #
58 # From http://www.gnu.org/prep/standards/html_node/Standard-Targets.html:
59 #
60 # "install-strip should not strip the executables in the build directory
61 # which are being copied for installation. It should only strip the copies
62 # that are installed. "
63
64 .PHONY: install-strip
65 install-strip:
66 # See Note [install-strip].
67 $(MAKE) --no-print-directory -f ghc.mk INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install BINDIST=YES NO_INCLUDE_DEPS=YES
68
69 else
70
71 .PHONY: default
72 default : all
73 @:
74
75 # For help, type 'make help'
76 .PHONY: help
77 help:
78 @cat MAKEHELP.md
79
80 # No need to update makefiles for these targets:
81 # (the ones we're filtering out)
82 REALGOALS=$(filter-out \
83 binary-dist \
84 binary-dist-prep \
85 install-strip \
86 sdist sdist-ghc \
87 sdist-ghc-prep \
88 sdist-windows-tarballs \
89 sdist-windows-tarballs-prep \
90 sdist-testsuite \
91 sdist-testsuite-prep \
92 bootstrapping-files \
93 framework-pkg \
94 clean \
95 clean_% \
96 distclean \
97 maintainer-clean \
98 show \
99 show! \
100 echo \
101 help \
102 test \
103 fulltest \
104 slowtest \
105 fasttest \
106 fast \
107 ,$(MAKECMDGOALS))
108
109 # configure touches certain files even if they haven't changed. This
110 # can mean a lot of unnecessary recompilation after a re-configure, so
111 # here we cache the old versions of these files so we can restore the
112 # timestamps.
113 %.old: %
114 @set -x && test -f $@ && cmp -s $< $@ || cp -p $< $@
115 touch -r $@ $<
116
117
118 # NB. not the same as saying '%: ...', which doesn't do the right thing:
119 # it does nothing if we specify a target that already exists.
120 .PHONY: $(REALGOALS) all
121 $(REALGOALS) all: mk/config.mk.old mk/project.mk.old compiler/ghc.cabal.old
122 ifneq "$(OMIT_PHASE_0)" "YES"
123 @echo "===--- building phase 0"
124 $(MAKE) --no-print-directory -f ghc.mk phase=0 phase_0_builds
125 endif
126 ifneq "$(OMIT_PHASE_1)" "YES"
127 @echo "===--- building phase 1"
128 $(MAKE) --no-print-directory -f ghc.mk phase=1 phase_1_builds
129 endif
130 @echo "===--- building final phase"
131 $(MAKE) --no-print-directory -f ghc.mk phase=final $@
132
133 # if BINARY_DIST_DIR is not set, assume we want the old
134 # behaviour of placing the binary dist into the current
135 # directory. Provide BINARY_DIST_DIR to put the final
136 # binary distribution elsewhere.
137 BINARY_DIST_DIR ?= .
138
139 .PHONY: binary-dist
140 binary-dist: binary-dist-prep
141 mv bindistprep/*.tar.$(TAR_COMP_EXT) "$(BINARY_DIST_DIR)"
142
143 .PHONY: binary-dist-prep
144 binary-dist-prep:
145 ifeq "$(mingw32_TARGET_OS)" "1"
146 $(MAKE) --no-print-directory -f ghc.mk windows-binary-dist-prep
147 else
148 rm -f bindist-list
149 $(MAKE) --no-print-directory -f ghc.mk bindist-list BINDIST=YES
150 $(MAKE) --no-print-directory -f ghc.mk unix-binary-dist-prep
151 endif
152
153 .PHONY: install-strip
154 install-strip:
155 # See Note [install-strip].
156 $(MAKE) --no-print-directory -f ghc.mk INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
157
158 .PHONY: sdist sdist-ghc sdist-ghc-prep sdist-windows-tarballs sdist-windows-tarballs-prep sdist-testsuite sdist-testsuite-prep
159 # Just running `./boot && ./configure && make sdist` should work, so skip
160 # phase 0 and 1 and don't build any dependency files.
161 sdist sdist-ghc sdist-ghc-prep sdist-windows-tarballs sdist-windows-tarballs-prep sdist-testsuite sdist-testsuite-prep :
162 $(MAKE) --no-print-directory -f ghc.mk $@ NO_INCLUDE_DEPS=YES NO_INCLUDE_PKGDATA=YES
163
164 .PHONY: clean distclean maintainer-clean
165 clean distclean maintainer-clean:
166 $(MAKE) --no-print-directory -f ghc.mk $@ CLEANING=YES
167 test ! -d testsuite || $(MAKE) -C testsuite $@
168
169 .PHONY: $(filter clean_%,$(MAKECMDGOALS))
170 $(filter clean_%, $(MAKECMDGOALS)) : clean_% :
171 $(MAKE) --no-print-directory -f ghc.mk $@ CLEANING=YES
172
173 .PHONY: bootstrapping-files show echo
174 bootstrapping-files show echo:
175 $(MAKE) --no-print-directory -f ghc.mk $@
176
177 .PHONY: show!
178 show!:
179 $(MAKE) --no-print-directory -f ghc.mk show NO_INCLUDE_PKGDATA=YES
180
181 ifeq "$(darwin_TARGET_OS)" "1"
182 .PHONY: framework-pkg
183 framework-pkg:
184 $(MAKE) -C distrib/MacOS $@
185 endif
186
187 # If the user says 'make A B', then we don't want to invoke two
188 # instances of the rule above in parallel:
189 .NOTPARALLEL:
190
191 endif
192
193 # Note [validate and testsuite speed]
194 #
195 # There are 3 different validate and testsuite speed settings:
196 # fast, normal and slow.
197 #
198 # how how used
199 # cd tests config. many many by
200 # validate && make speed= tests ways whom
201 # =============================================================================
202 # --fast fast 2 some 1+exs Travis (to stay within time limit)
203 # --normal test 1 all 1+exs Phabricator (slow takes too long?)
204 # --slow slow 0 all all Nightly (slow is ok)
205 #
206 # accept 1 all 1
207 #
208 # `--fast` and `--normal` run one default way, as well as any other ways which
209 # are explicitly requested by the test using extra_ways().
210 #
211 # `make accept` should run all tests exactly once. There is no point in
212 # accepting a test for multiple ways, since it should produce the same output
213 # for all ways.
214 #
215 # To make sure all .stderr and .stdout files in the testsuite are never
216 # out-of-date, it is useful if Phabricator, via a normal `./validate` and `make
217 # test`, runs each test at least once.
218 .PHONY: fasttest
219 fasttest:
220 $(MAKE) -C testsuite/tests CLEANUP=1 SUMMARY_FILE=../../testsuite_summary.txt fast
221
222 .PHONY: test
223 test:
224 $(MAKE) -C testsuite/tests CLEANUP=1 SUMMARY_FILE=../../testsuite_summary.txt
225
226 .PHONY: slowtest fulltest
227 slowtest fulltest:
228 $(MAKE) -C testsuite/tests CLEANUP=1 SUMMARY_FILE=../../testsuite_summary.txt slow
229
230 .PHONY: fast
231 fast:
232 @echo "You can use 'make fast' only from inside a sub-component directory."
233 @exit 1