Makefile 7.01 KB
Newer Older
1 2 3 4 5 6 7
# -----------------------------------------------------------------------------
#
# (c) 2009 The University of Glasgow
#
# This file is part of the GHC build system.
#
# To understand how the build system works and how to modify it, see
8 9
#      http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
#      http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 11
#
# -----------------------------------------------------------------------------
12

thomie's avatar
thomie committed
13 14 15 16 17 18 19 20
# Eliminate use of the built-in implicit rules, and clear out the default list
# of suffixes for suffix rules. Speeds up make quite a bit. Both are needed
# for the shortest `make -d` output.
# Don't set --no-builtin-variables; some rules might stop working if you do
# (e.g. 'make clean' in testsuite/ currently relies on an implicit $RM).
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:

21 22 23 24 25 26 27

# -----------------------------------------------------------------------------
# Sanitize environment

# See Trac #11530
export GREP_OPTIONS :=

28 29 30 31 32 33 34 35 36 37 38 39
ifneq "$(filter maintainer-clean distclean clean clean_% help,$(MAKECMDGOALS))" ""
-include mk/config.mk
else
include mk/config.mk
ifeq "$(ProjectVersion)" ""
$(error Please run ./configure first)
endif
endif

include mk/custom-settings.mk


Ian Lynagh's avatar
Ian Lynagh committed
40
ifeq "$(wildcard distrib/)" ""
41

Ian Lynagh's avatar
Ian Lynagh committed
42
# We're in a bindist
43

Ian Lynagh's avatar
Ian Lynagh committed
44 45 46 47
.PHONY: default
default:
	@echo 'Run "make install" to install'
	@false
48

Ian Lynagh's avatar
Ian Lynagh committed
49 50
.PHONY: install show
install show:
thomie's avatar
thomie committed
51
	$(MAKE) --no-print-directory -f ghc.mk $@ BINDIST=YES NO_INCLUDE_DEPS=YES
52

53 54 55 56 57 58 59 60 61 62 63 64 65 66
# Note [install-strip]
#
# install-strip is like install, but it strips the executable files while
# installing them.
#
# From http://www.gnu.org/prep/standards/html_node/Standard-Targets.html:
#
#   "install-strip should not strip the executables in the build directory
#   which are being copied for installation. It should only strip the copies
#   that are installed. "

.PHONY: install-strip
install-strip:
	# 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
Ian Lynagh's avatar
Ian Lynagh committed
72 73
default : all
	@:
74

75 76
# For help, type 'make help'
.PHONY: help
Kyle J. Van Berendonck's avatar
Kyle J. Van Berendonck committed
77
help:
Austin Seipp's avatar
Austin Seipp committed
78
	@cat MAKEHELP.md
79

Ian Lynagh's avatar
Ian Lynagh committed
80
# No need to update makefiles for these targets:
81 82 83 84
# (the ones we're filtering out)
REALGOALS=$(filter-out \
    binary-dist \
    binary-dist-prep \
85
    install-strip \
86 87 88 89 90 91 92 93 94 95 96 97 98
    sdist sdist-ghc \
    sdist-ghc-prep \
    sdist-windows-tarballs \
    sdist-windows-tarballs-prep \
    sdist-testsuite \
    sdist-testsuite-prep \
    bootstrapping-files \
    framework-pkg \
    clean \
    clean_% \
    distclean \
    maintainer-clean \
    show \
99
    show! \
100 101 102 103
    echo \
    help \
    test \
    fulltest \
104
    slowtest \
105 106
    fasttest \
  ,$(MAKECMDGOALS))
107

108 109 110 111
# configure touches certain files even if they haven't changed.  This
# can mean a lot of unnecessary recompilation after a re-configure, so
# here we cache the old versions of these files so we can restore the
# timestamps.
kili's avatar
kili committed
112
%.old:  %
113
	@set -x && test -f $@ && cmp -s $< $@ || cp -p $< $@
kili's avatar
kili committed
114 115
	touch -r $@ $<

116

Ian Lynagh's avatar
Ian Lynagh committed
117 118
# NB. not the same as saying '%: ...', which doesn't do the right thing:
# it does nothing if we specify a target that already exists.
119
.PHONY: $(REALGOALS) all
kili's avatar
kili committed
120
$(REALGOALS) all: mk/config.mk.old mk/project.mk.old compiler/ghc.cabal.old
121
ifneq "$(OMIT_PHASE_0)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
122
	@echo "===--- building phase 0"
thomie's avatar
thomie committed
123
	$(MAKE) --no-print-directory -f ghc.mk phase=0 phase_0_builds
124
endif
125
ifneq "$(OMIT_PHASE_1)" "YES"
Ian Lynagh's avatar
Ian Lynagh committed
126
	@echo "===--- building phase 1"
thomie's avatar
thomie committed
127
	$(MAKE) --no-print-directory -f ghc.mk phase=1 phase_1_builds
Ian Lynagh's avatar
Ian Lynagh committed
128 129
endif
	@echo "===--- building final phase"
thomie's avatar
thomie committed
130
	$(MAKE) --no-print-directory -f ghc.mk phase=final $@
131

132 133 134 135 136 137
# if BINARY_DIST_DIR is not set, assume we want the old
# behaviour of placing the binary dist into the current
# directory. Provide BINARY_DIST_DIR to put the final
# binary distribution elsewhere.
BINARY_DIST_DIR ?= .

thomie's avatar
thomie committed
138
.PHONY: binary-dist
Ian Lynagh's avatar
Ian Lynagh committed
139
binary-dist: binary-dist-prep
140
	mv bindistprep/*.tar.$(TAR_COMP_EXT) "$(BINARY_DIST_DIR)"
Ian Lynagh's avatar
Ian Lynagh committed
141

thomie's avatar
thomie committed
142
.PHONY: binary-dist-prep
Ian Lynagh's avatar
Ian Lynagh committed
143 144
binary-dist-prep:
ifeq "$(mingw32_TARGET_OS)" "1"
thomie's avatar
thomie committed
145
	$(MAKE) --no-print-directory -f ghc.mk windows-binary-dist-prep
146
else
Ian Lynagh's avatar
Ian Lynagh committed
147
	rm -f bindist-list
148
	$(MAKE) --no-print-directory -f ghc.mk bindist-list BINDIST=YES
thomie's avatar
thomie committed
149
	$(MAKE) --no-print-directory -f ghc.mk unix-binary-dist-prep
150
endif
151

152 153 154 155 156
.PHONY: install-strip
install-strip:
	# See Note [install-strip].
	$(MAKE) --no-print-directory -f ghc.mk INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install

157 158 159 160 161 162
.PHONY: sdist sdist-ghc sdist-ghc-prep sdist-windows-tarballs sdist-windows-tarballs-prep sdist-testsuite sdist-testsuite-prep
# Just running `./boot && ./configure && make sdist` should work, so skip
# phase 0 and 1 and don't build any dependency files.
sdist sdist-ghc sdist-ghc-prep sdist-windows-tarballs sdist-windows-tarballs-prep sdist-testsuite sdist-testsuite-prep :
	$(MAKE) --no-print-directory -f ghc.mk $@ NO_INCLUDE_DEPS=YES NO_INCLUDE_PKGDATA=YES

thomie's avatar
thomie committed
163
.PHONY: clean distclean maintainer-clean
164
clean distclean maintainer-clean:
thomie's avatar
thomie committed
165
	$(MAKE) --no-print-directory -f ghc.mk $@ CLEANING=YES
Ian Lynagh's avatar
Ian Lynagh committed
166
	test ! -d testsuite || $(MAKE) -C testsuite $@
Ian Lynagh's avatar
Ian Lynagh committed
167

thomie's avatar
thomie committed
168
.PHONY: $(filter clean_%,$(MAKECMDGOALS))
169
$(filter clean_%, $(MAKECMDGOALS)) : clean_% :
thomie's avatar
thomie committed
170
	$(MAKE) --no-print-directory -f ghc.mk $@ CLEANING=YES
171

thomie's avatar
thomie committed
172
.PHONY: bootstrapping-files show echo
173
bootstrapping-files show echo:
thomie's avatar
thomie committed
174
	$(MAKE) --no-print-directory -f ghc.mk $@
sof's avatar
sof committed
175

176 177 178 179
.PHONY: show!
show!:
	$(MAKE) --no-print-directory -f ghc.mk show NO_INCLUDE_PKGDATA=YES

180
ifeq "$(darwin_TARGET_OS)" "1"
thomie's avatar
thomie committed
181
.PHONY: framework-pkg
182 183 184 185
framework-pkg:
	$(MAKE) -C distrib/MacOS $@
endif

Ian Lynagh's avatar
Ian Lynagh committed
186 187 188
# If the user says 'make A B', then we don't want to invoke two
# instances of the rule above in parallel:
.NOTPARALLEL:
189

Ian Lynagh's avatar
Ian Lynagh committed
190
endif
191

192 193 194 195 196 197 198 199 200
# Note [validate and testsuite speed]
#
# There are 3 different validate and testsuite speed settings:
# fast, normal and slow.
#
#                              how    how   used
#           cd tests  config.  many   many  by
# validate  && make   speed=   tests  ways  whom
# =============================================================================
201 202
# --fast    fast      2        some   1+exs Travis (to stay within time limit)
# --normal  test      1        all    1+exs Phabricator (slow takes too long?)
203 204 205 206
# --slow    slow      0        all    all   Nightly (slow is ok)
#
#           accept    1        all    1
#
207 208 209
# `--fast` and `--normal` run one default way, as well as any other ways which
# are explicitly requested by the test using extra_ways().
#
210 211 212 213 214 215 216
# `make accept` should run all tests exactly once. There is no point in
# accepting a test for multiple ways, since it should produce the same output
# for all ways.
#
# To make sure all .stderr and .stdout files in the testsuite are never
# out-of-date, it is useful if Phabricator, via a normal `./validate` and `make
# test`, runs each test at least once.
217
.PHONY: fasttest
218
fasttest: testsuite_utils
thomie's avatar
thomie committed
219
	$(MAKE) -C testsuite/tests CLEANUP=1 SUMMARY_FILE=../../testsuite_summary.txt fast
220

221
.PHONY: test
222
test: testsuite_utils
thomie's avatar
thomie committed
223
	$(MAKE) -C testsuite/tests CLEANUP=1 SUMMARY_FILE=../../testsuite_summary.txt
224 225

.PHONY: slowtest fulltest
226
slowtest fulltest: testsuite_utils
227
	$(MAKE) -C testsuite/tests CLEANUP=1 SUMMARY_FILE=../../testsuite_summary.txt slow
228 229 230 231

.PHONY: testsuite_utils
testsuite_utils:
	$(MAKE) -f ghc.mk testsuite_utils