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