1 # Maintainer makefile for Automake. Requires GNU make.
3 # Copyright (C) 2012 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ifeq ($(filter bootstrap,$(MAKECMDGOALS)),)
20 ifeq ($(wildcard Makefile),)
21 # Any target but 'bootstrap' specified in an unconfigured tree
22 # is an error, even when the user is running GNU make.
23 $(warning There seems to be no Makefile in this directory.)
24 $(warning You must run ./configure before running 'make'.)
28 include $(srcdir)/maint.mk
29 include $(srcdir)/syntax-checks.mk
31 else # ! bootstrap in $(MAKECMDGOALS)
33 other-targets := $(filter-out bootstrap,$(MAKECMDGOALS))
34 config-status := $(wildcard ./config.status)
36 BOOTSTRAP_SHELL ?= /bin/sh
37 export BOOTSTRAP_SHELL
39 # Allow the user (or more likely the developer) to ask for a bootstrap
42 # Two issues that must be kept in mind in the implementation below:
44 # [1] "make bootstrap" can be invoked before 'configure' is run (and in
45 # fact, even before it is created, if we are bootstrapping from a
46 # freshly-cloned checkout).
48 # [2] When re-bootstrapping an already configured tree, we must ensure
49 # that the automatic remake rules for Makefile and company do not
50 # kick in, because the tree might be in an inconsistent state (e.g.,
51 # we have just switched from 'maint' to 'master', and have the built
52 # 'automake' script left from 'maint', but the files 'lib/am/*.am'
53 # are from 'master': if 'automake' gets run and used those files --
56 ifdef config-status # Bootstrap from an already-configured tree.
57 # We need the definition of $(srcdir) in the 'bootstrap' rule
59 srcdir := $(shell echo @srcdir@ | $(config-status) --file=-)
61 $(error Could not obtain $$(srcdir) from $(config-status))
63 # Also, if we are re-bootstrapping an already-configured tree, we
64 # want to re-configure it with the same pre-existing configuration.
65 old-configure-flags := $(shell $(config-status) --config)
66 else # Assume we are bootstrapping from an unconfigured srcdir.
68 old-configure-flags :=
71 configure-flags := $(old-configure-flags) $(BOOTSTRAP_CONFIGURE_FLAGS)
75 cd $(srcdir) && $(SHELL) ./bootstrap.sh
76 $(srcdir)/configure $(configure-flags)
78 $(MAKE) check TESTS=t/get-sysconf
80 # Ensure that all the specified targets but 'bootstrap' (if any) are
81 # run with a properly re-bootstrapped tree.
83 $(other-targets): restart
84 .PHONY: $(other-targets) restart
85 restart: bootstrap; $(MAKE) $(AM_MAKEFLAGS) $(other-targets)
88 endif # ! bootstrap in $(MAKECMDGOALS)