2 ifeq "$(wildcard distrib/)" ""
8 @echo 'Run "make install" to install'
13 $(MAKE) -r --no-print-directory -f ghc.mk install BINDIST=YES NO_INCLUDE_DEPS=YES
17 $(MAKE) -r --no-print-directory -f ghc.mk $@
21 # The problem we need to solve is as follows.
23 # GNU make supports included Makefiles, and it is clever enough to try
24 # to update those Makefiles when they are out-of-date or missing. It
25 # first reads all the Makefiles, and then tries to build each one if
26 # it is out-of-date, using the rules in the Makefiles themselves.
27 # When it has brought all the Makefiles up-to-date, it restarts itself
28 # to read the newly-generated Makefiles.
30 # This works fine, unless there are dependencies *between* the
31 # Makefiles. For example in the GHC build, for each package we have a
32 # package-data.mk file which is generated by the ghc-cabal program,
33 # and we have a .depend file. The .depend file cannot be generated
34 # until package-data.mk has been generated and make has been restarted
35 # to read in its contents, because it is the package-data.mk file that
36 # tells us which modules are in the package. But make always makes
37 # all the Makefiles before restarting - it doesn't take into account a
38 # dependency between Makefiles and restart itself earlier.
40 # Consider the following makefile:
42 # --------------------
54 # --------------------
59 # fail.mk:3: inc1.mk: No such file or directory
60 # fail.mk:8: inc2.mk: No such file or directory
61 # echo "X = C" >inc1.mk
62 # echo "Y = " >inc2.mk
63 # make: Nothing to be done for `all'.
65 # make built both inc1.mk and inc2.mk without restarting itself
66 # between the two (even though we added a dependency on inc1.mk from
69 # The solution we adopt in the GHC build system is essentially this:
71 # --------------------
86 # ifneq "$(PHASE)" "0"
94 # rm -f inc1.mk inc2.mk
95 # --------------------
97 # That is, every time make is invoked, we force it to update inc1.mk
98 # and then restart. In the GHC build system we need to divide the
99 # build into 4 phases in fact, with a restart between each phase. See
100 # ghc.mk for the details on what happens in each phase and why.
105 # No need to update makefiles for these targets:
106 REALGOALS=$(filter-out clean clean_% distclean maintainer-clean show,$(MAKECMDGOALS))
108 # NB. not the same as saying '%: ...', which doesn't do the right thing:
109 # it does nothing if we specify a target that already exists.
112 @echo "===--- updating makefiles phase 0"
113 $(MAKE) -r --no-print-directory -f ghc.mk phase=0 just-makefiles
114 @echo "===--- updating makefiles phase 1"
115 $(MAKE) -r --no-print-directory -f ghc.mk phase=1 just-makefiles
116 @echo "===--- updating makefiles phase 2"
117 $(MAKE) -r --no-print-directory -f ghc.mk phase=2 just-makefiles
118 @echo "===--- updating makefiles phase 3"
119 $(MAKE) -r --no-print-directory -f ghc.mk phase=3 just-makefiles
120 @echo "===--- finished updating makefiles"
121 $(MAKE) -r --no-print-directory -f ghc.mk $@
125 $(MAKE) -r --no-print-directory -f ghc.mk bindist BINDIST=YES
126 $(MAKE) -r --no-print-directory -f ghc.mk binary-dist
128 clean distclean maintainer-clean:
129 $(MAKE) -r --no-print-directory -f ghc.mk $@
130 test ! -d testsuite || $(MAKE) -C testsuite $@
132 $(filter clean_%, $(MAKECMDGOALS)) : clean_% :
133 $(MAKE) -r --no-print-directory -f ghc.mk $@
136 $(MAKE) -r --no-print-directory -f ghc.mk $@
138 # If the user says 'make A B', then we don't want to invoke two
139 # instances of the rule above in parallel: