Merge branch 'missing-not-touch-just-warn'
[platform/upstream/automake.git] / GNUmakefile
1 # Maintainer makefile for Automake.  Requires GNU make.
2
3 # Copyright (C) 2012 Free Software Foundation, Inc.
4 #
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)
8 # any later version.
9 #
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.
14 #
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/>.
17
18 ifeq ($(filter bootstrap,$(MAKECMDGOALS)),)
19
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'.)
25   $(error Fatal Error)
26 endif
27 include ./Makefile
28 include $(srcdir)/syntax-checks.mk
29
30 else # ! bootstrap in $(MAKECMDGOALS)
31
32 other-targets := $(filter-out bootstrap,$(MAKECMDGOALS))
33 config-status := $(wildcard ./config.status)
34
35 BOOTSTRAP_SHELL ?= /bin/sh
36 export BOOTSTRAP_SHELL
37
38 # Allow the user (or more likely the developer) to ask for a bootstrap
39 # of the package.
40 #
41 # Two issues that must be kept in mind in the implementation below:
42 #
43 #  [1] "make bootstrap" can be invoked before 'configure' is run (and in
44 #      fact, even before it is created, if we are bootstrapping from a
45 #      freshly-cloned checkout).
46 #
47 #  [2] When re-bootstrapping an already configured tree, we must ensure
48 #      that the automatic remake rules for Makefile and company do not
49 #      kick in, because the tree might be in an inconsistent state (e.g.,
50 #      we have just switched from 'maint' to 'master', and have the built
51 #      'automake' script left from 'maint', but the files 'lib/am/*.am'
52 #      are from 'master': if 'automake' gets run and used those files --
53 #      boom!).
54
55 ifdef config-status # Bootstrap from an already-configured tree.
56   # We need the definition of $(srcdir) in the 'bootstrap' rule
57   # below.
58   srcdir := $(shell echo @srcdir@ | $(config-status) --file=-)
59   ifndef srcdir
60     $(error Could not obtain $$(srcdir) from $(config-status))
61   endif
62   # Also, if we are re-bootstrapping an already-configured tree, we
63   # want to re-configure it with the same pre-existing configuration.
64   old-configure-flags := $(shell $(config-status) --config)
65 else # Assume we are bootstrapping from an unconfigured srcdir.
66   srcdir := .
67   old-configure-flags :=
68 endif
69
70 configure-flags := $(old-configure-flags) $(BOOTSTRAP_CONFIGURE_FLAGS)
71
72 .PHONY: bootstrap
73 bootstrap:
74         cd $(srcdir) && $(SHELL) ./bootstrap.sh
75         $(srcdir)/configure $(configure-flags)
76         $(MAKE) clean
77         $(MAKE) check TESTS=t/get-sysconf
78
79 # Ensure that all the specified targets but 'bootstrap' (if any) are
80 # run with a properly re-bootstrapped tree.
81 ifdef other-targets
82 $(other-targets): restart
83 .PHONY: $(other-targets) restart
84 restart: bootstrap; $(MAKE) $(AM_MAKEFLAGS) $(other-targets)
85 endif
86
87 endif # ! bootstrap in $(MAKECMDGOALS)