1# We want the all target to be the implicit target (if no target is
2# given explicitly on the command line) so mention it first.
3all:
4
5# Sub-directory Makefile.local fragments can append to these variables
6# to have directory-specific cflags as necessary.
7
8extra_cflags :=
9extra_cxxflags :=
10
11# Get settings from the output of configure by running it to generate
12# Makefile.config if it doesn't exist yet.
13
14# If Makefile.config doesn't exist, then srcdir won't be
15# set. Conditionally set it (assuming a plain srcdir build) so that
16# the rule to generate Makefile.config can actually work.
17srcdir ?= .
18
19include Makefile.config
20
21# We make all targets depend on the Makefiles themselves.
22global_deps = Makefile Makefile.config Makefile.local \
23	$(subdirs:%=%/Makefile) $(subdirs:%=%/Makefile.local)
24
25INCLUDE_MORE := yes
26ifneq ($(filter clean distclean dataclean, $(word 1, $(MAKECMDGOALS))),)
27CLEAN_GOAL := $(word 1, $(MAKECMDGOALS))
28
29# If there are more goals following CLEAN_GOAL, run $(MAKE)s in parts.
30ifneq ($(word 2, $(MAKECMDGOALS)),)
31INCLUDE_MORE := no
32FOLLOWING_GOALS := $(wordlist 2, 99, $(MAKECMDGOALS))
33
34.PHONY: $(FOLLOWING_GOALS) make_in_parts
35$(FOLLOWING_GOALS):
36	@true
37$(CLEAN_GOAL): make_in_parts
38make_in_parts:
39	$(MAKE) $(CLEAN_GOAL)
40	$(MAKE) $(FOLLOWING_GOALS) configure_options="$(configure_options)"
41endif
42
43else
44CLEAN_GOAL :=
45endif
46
47# Potentially speedup make clean, distclean and dataclean ; avoid
48# re-creating Makefile.config if it exists but configure is newer.
49ifneq ($(CLEAN_GOAL),)
50Makefile.config: | $(srcdir)/configure
51else
52Makefile.config: $(srcdir)/configure
53endif
54ifeq ($(configure_options),)
55	@echo ""
56	@echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
57	@echo "      but if you want to specify any arguments (such as an alternate prefix"
58	@echo "      into which to install), call ./configure explicitly and then make again."
59	@echo "      See \"./configure --help\" for more details."
60	@echo ""
61endif
62	$(srcdir)/configure $(configure_options)
63
64ifeq ($(INCLUDE_MORE),yes)
65# runtime variable definitions available in all subdirs
66include $(srcdir)/Makefile.global
67# Finally, include all of the Makefile.local fragments where all the
68# real work is done.
69
70include $(subdirs:%=%/Makefile.local) Makefile.local
71endif
72