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