[project @ 2004-09-10 09:46:21 by simonmar]
[ghc-hetmet.git] / mk / boilerplate.mk
1 #################################################################################
2 #
3 #                           mk/boilerplate.mk
4 #
5 #               The Glorious fptools Boilerplate Makefile
6 #
7 # This one file should be included (directly or indirectly) by all Makefiles 
8 # in the fptools hierarchy.
9 #
10 #################################################################################
11
12 # We want to disable all the built-in rules that make uses; having them
13 # just slows things down, and we write all the rules ourselves.
14 # Setting .SUFFIXES to empty disables them all.
15 MAKEFLAGS += --no-builtin-rules
16
17 # FPTOOLS_TOP is the *relative* path to the fptools toplevel directory from the
18 # location where a project Makefile was invoked. It is set by looking at the
19 # current value of TOP.
20 #
21 FPTOOLS_TOP := $(TOP)
22
23
24 # This rule makes sure that "all" is the default target, regardless of where it appears
25 #               THIS RULE MUST REMAIN FIRST!
26 default: all
27
28
29 # -----------------------------------------------------------------------------
30 #       make sure the autoconf stuff is up to date...
31
32 $(TOP)/configure : $(TOP)/configure.ac $(TOP)/aclocal.m4
33         @echo "Running autoreconf in $(FPTOOLS_TOP)  ..."
34         @( cd $(FPTOOLS_TOP) && autoreconf )
35
36 $(TOP)/config.status : $(TOP)/configure
37         @if test ! -f $(FPTOOLS_TOP)/config.status; then \
38                 echo "You haven't run $(FPTOOLS_TOP)/configure yet."; \
39                 exit 1; \
40         fi
41         echo "configure changed, reconfiguring with same settings..."; \
42         ( cd $(FPTOOLS_TOP) && ./config.status --recheck ); \
43
44 $(TOP)/mk/config.mk : $(TOP)/mk/config.mk.in $(TOP)/mk/config.h.in $(TOP)/configure $(TOP)/config.status
45         @echo "Running $(FPTOOLS_TOP)/config.status to update configuration info...";
46         @( cd $(FPTOOLS_TOP) && ./config.status )
47
48 # -----------------------------------------------------------------------------
49 # Misc bits
50
51 # If $(way) is set then we define $(way_) and $(_way) from it in the
52 # obvious fashion.  This must be done before suffix.mk is included,
53 # because the pattern rules in that file depend on these variables.
54
55 ifneq "$(way)" ""
56   way_ := $(way)_
57   _way := _$(way)
58 endif
59
60
61 # When using $(patsubst ...) and friends, you can't use a literal comma
62 # freely - so we use ${comma} instead.  (See PACKAGE_CPP_OPTS in package.mk
63 # for an example usage.)
64 comma=,
65
66 # -----------------------------------------------------------------------------
67 #       Now follow the pieces of boilerplate
68 #       The "-" signs tell make not to complain if they don't exist
69
70 include $(TOP)/mk/config.mk
71 # All configuration information
72 #       (generated by "configure" from config.mk.in)
73 #
74
75
76 include $(TOP)/mk/paths.mk
77 # Variables that say where things belong (e.g install directories)
78 # and where we are right now
79 # Also defines variables for standard files (SRCS, LIBS etc)
80
81
82 include $(TOP)/mk/opts.mk
83 # Variables that control the option flags for all the
84 # language processors
85
86 ifeq "$(BootingFromHc)" "YES"
87 include $(TOP)/mk/bootstrap.mk
88 endif
89
90 -include $(TOP)/mk/build.mk
91 # (Optional) build-specific configuration
92 #
93
94 ifndef FAST
95 -include .depend
96 endif
97 # The dependencies file from the current directory