9913803ebee93fa3012a220f9f9a0a94263d0887
[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 else
35
36 .PHONY: default
37 default : all
38 @:
39
40 # For help, type 'make help'
41 .PHONY: help
42 help:
43 @cat MAKEHELP.md
44
45 ifneq "$(filter maintainer-clean distclean clean clean_% help,$(MAKECMDGOALS))" ""
46 -include mk/config.mk
47 else
48 include mk/config.mk
49 ifeq "$(ProjectVersion)" ""
50 $(error Please run ./configure first)
51 endif
52 endif
53
54 include mk/custom-settings.mk
55
56 # Verify that stage 0 LLVM backend isn't affected by Bug #9439 if needed
57 ifeq "$(GHC_LLVM_AFFECTED_BY_9439)" "1"
58 ifneq "$(findstring -fllvm,$(GhcHcOpts) $(GhcStage1HcOpts))" ""
59 $(error Stage 0 compiler is affected by Bug #9439. Refusing to bootstrap with -fllvm)
60 endif
61 endif
62
63 # No need to update makefiles for these targets:
64 REALGOALS=$(filter-out binary-dist binary-dist-prep bootstrapping-files framework-pkg clean clean_% distclean maintainer-clean show echo help test fulltest fasttest,$(MAKECMDGOALS))
65
66 # configure touches certain files even if they haven't changed. This
67 # can mean a lot of unnecessary recompilation after a re-configure, so
68 # here we cache the old versions of these files so we can restore the
69 # timestamps.
70 %.old: %
71 @set -x && test -f $@ && cmp -s $< $@ || cp -p $< $@
72 touch -r $@ $<
73
74
75 # NB. not the same as saying '%: ...', which doesn't do the right thing:
76 # it does nothing if we specify a target that already exists.
77 .PHONY: $(REALGOALS) all
78 $(REALGOALS) all: mk/config.mk.old mk/project.mk.old compiler/ghc.cabal.old
79 ifneq "$(OMIT_PHASE_0)" "YES"
80 @echo "===--- building phase 0"
81 $(MAKE) --no-print-directory -f ghc.mk phase=0 phase_0_builds
82 endif
83 ifneq "$(OMIT_PHASE_1)" "YES"
84 @echo "===--- building phase 1"
85 $(MAKE) --no-print-directory -f ghc.mk phase=1 phase_1_builds
86 endif
87 @echo "===--- building final phase"
88 $(MAKE) --no-print-directory -f ghc.mk phase=final $@
89
90 .PHONY: binary-dist
91 binary-dist: binary-dist-prep
92 mv bindistprep/*.tar.$(TAR_COMP_EXT) .
93
94 .PHONY: binary-dist-prep
95 binary-dist-prep:
96 ifeq "$(mingw32_TARGET_OS)" "1"
97 $(MAKE) --no-print-directory -f ghc.mk windows-binary-dist-prep
98 else
99 rm -f bindist-list
100 $(MAKE) --no-print-directory -f ghc.mk bindist BINDIST=YES
101 $(MAKE) --no-print-directory -f ghc.mk unix-binary-dist-prep
102 endif
103
104 .PHONY: clean distclean maintainer-clean
105 clean distclean maintainer-clean:
106 $(MAKE) --no-print-directory -f ghc.mk $@ CLEANING=YES
107 test ! -d testsuite || $(MAKE) -C testsuite $@
108
109 .PHONY: $(filter clean_%,$(MAKECMDGOALS))
110 $(filter clean_%, $(MAKECMDGOALS)) : clean_% :
111 $(MAKE) --no-print-directory -f ghc.mk $@ CLEANING=YES
112
113 .PHONY: bootstrapping-files show echo
114 bootstrapping-files show echo:
115 $(MAKE) --no-print-directory -f ghc.mk $@
116
117 ifeq "$(darwin_TARGET_OS)" "1"
118 .PHONY: framework-pkg
119 framework-pkg:
120 $(MAKE) -C distrib/MacOS $@
121 endif
122
123 # If the user says 'make A B', then we don't want to invoke two
124 # instances of the rule above in parallel:
125 .NOTPARALLEL:
126
127 endif
128
129 .PHONY: fasttest
130 fasttest:
131 $(MAKE) -C testsuite/tests CLEANUP=1 OUTPUT_SUMMARY=../../testsuite_summary.txt fast
132
133 .PHONY: fulltest test
134 fulltest test:
135 $(MAKE) -C testsuite/tests CLEANUP=1 OUTPUT_SUMMARY=../../testsuite_summary.txt