Build system improvements
[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://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 ifeq "$(wildcard distrib/)" ""
14
15 # We're in a bindist
16
17 .PHONY: default
18 default:
19 @echo 'Run "make install" to install'
20 @false
21
22 .PHONY: install show
23 install show:
24 $(MAKE) -r --no-print-directory -f ghc.mk $@ BINDIST=YES NO_INCLUDE_DEPS=YES
25
26 else
27
28 default : all
29 @:
30
31 # For help, type 'make help'
32 .PHONY: help
33 help :
34 @cat MAKEHELP
35
36 ifneq "$(findstring clean,$(MAKECMDGOALS))" ""
37 -include mk/config.mk
38 else
39 include mk/config.mk
40 ifeq "$(ProjectVersion)" ""
41 $(error Please run ./configure first)
42 endif
43 endif
44
45 include mk/custom-settings.mk
46
47 # No need to update makefiles for these targets:
48 REALGOALS=$(filter-out binary-dist binary-dist-prep bootstrapping-files framework-pkg clean clean_% distclean maintainer-clean show help install-docs test fulltest,$(MAKECMDGOALS))
49
50 # configure touches certain files even if they haven't changed. This
51 # can mean a lot of unnecessary recompilation after a re-configure, so
52 # here we cache the old versions of these files so we can restore the
53 # timestamps.
54 %.old: %
55 @set -x && test -f $@ && cmp -s $< $@ || cp -p $< $@
56 touch -r $@ $<
57
58
59 # NB. not the same as saying '%: ...', which doesn't do the right thing:
60 # it does nothing if we specify a target that already exists.
61 .PHONY: $(REALGOALS)
62 $(REALGOALS) all: mk/config.mk.old mk/project.mk.old compiler/ghc.cabal.old
63 @echo "===--- building phase 0"
64 $(MAKE) -r --no-print-directory -f ghc.mk phase=0 all
65 ifneq "$(OMIT_PHASE_1)" "YES"
66 @echo "===--- building phase 1"
67 $(MAKE) -r --no-print-directory -f ghc.mk phase=1 all
68 endif
69 ifneq "$(OMIT_PHASE_2)" "YES"
70 @echo "===--- building phase 2"
71 $(MAKE) -r --no-print-directory -f ghc.mk phase=2 all
72 endif
73 ifneq "$(OMIT_PHASE_3)" "YES"
74 @echo "===--- building phase 3"
75 $(MAKE) -r --no-print-directory -f ghc.mk phase=3 all
76 endif
77 ifneq "$(OMIT_PHASE_4)" "YES"
78 @echo "===--- building phase 4"
79 $(MAKE) -r --no-print-directory -f ghc.mk phase=4 all
80 endif
81 @echo "===--- building final phase"
82 $(MAKE) -r --no-print-directory -f ghc.mk $@
83
84 binary-dist: binary-dist-prep
85 ifeq "$(mingw32_TARGET_OS)" "1"
86 mv bindistprep/*.exe .
87 endif
88 mv bindistprep/*.tar.bz2 .
89
90 binary-dist-prep:
91 ifeq "$(mingw32_TARGET_OS)" "1"
92 $(MAKE) -r --no-print-directory -f ghc.mk windows-binary-dist-prep
93 $(MAKE) -r --no-print-directory -f ghc.mk windows-installer
94 else
95 rm -f bindist-list
96 $(MAKE) -r --no-print-directory -f ghc.mk bindist BINDIST=YES
97 $(MAKE) -r --no-print-directory -f ghc.mk unix-binary-dist-prep
98 endif
99
100 clean distclean maintainer-clean:
101 $(MAKE) -r --no-print-directory -f ghc.mk $@ CLEANING=YES
102 test ! -d testsuite || $(MAKE) -C testsuite $@
103
104 $(filter clean_%, $(MAKECMDGOALS)) : clean_% :
105 $(MAKE) -r --no-print-directory -f ghc.mk $@ CLEANING=YES
106
107 bootstrapping-files show:
108 $(MAKE) -r --no-print-directory -f ghc.mk $@
109
110 ifeq "$(darwin_TARGET_OS)" "1"
111 framework-pkg:
112 $(MAKE) -C distrib/MacOS $@
113 endif
114
115 # install-docs is a historical target that isn't supported in GHC 6.12. See #3662.
116 install-docs:
117 @echo "The install-docs target is not supported in GHC 6.12.1 and later."
118 @echo "'make install' now installs everything, including documentation."
119 @exit 1
120
121 # If the user says 'make A B', then we don't want to invoke two
122 # instances of the rule above in parallel:
123 .NOTPARALLEL:
124
125 endif
126
127 .PHONY: test
128 test:
129 $(MAKE) -C testsuite/tests/ghc-regress CLEANUP=1 OUTPUT_SUMMARY=../../../testsuite_summary.txt fast
130
131 .PHONY: fulltest
132 fulltest:
133 $(MAKE) -C testsuite/tests/ghc-regress CLEANUP=1 OUTPUT_SUMMARY=../../../testsuite_summary.txt
134