• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Having a separate GNUmakefile lets me 'include' the dynamically
2# generated rules created via cfg.mk (package-local configuration)
3# as well as maint.mk (generic maintainer rules).
4# This makefile is used only if you run GNU Make.
5# It is necessary if you want to build targets usually of interest
6# only to the maintainer.
7
8# Copyright (C) 2001, 2003, 2006-2012 Free Software Foundation, Inc.
9
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU General Public License for more details.
19
20# You should have received a copy of the GNU General Public License
21# along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23# If the user runs GNU make but has not yet run ./configure,
24# give them a diagnostic.
25_gl-Makefile := $(wildcard [M]akefile)
26ifneq ($(_gl-Makefile),)
27
28# Make tar archive easier to reproduce.
29export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
30
31# Allow the user to add to this in the Makefile.
32ALL_RECURSIVE_TARGETS =
33
34include Makefile
35
36# Some projects override e.g., _autoreconf here.
37-include $(srcdir)/cfg.mk
38
39# Allow cfg.mk to override these.
40_build-aux ?= build-aux
41_autoreconf ?= autoreconf -v
42
43include $(srcdir)/maint.mk
44
45# Ensure that $(VERSION) is up to date for dist-related targets, but not
46# for others: rerunning autoreconf and recompiling everything isn't cheap.
47_have-git-version-gen := \
48  $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes)
49ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL))
50  _is-dist-target ?= $(filter-out %clean, \
51    $(filter maintainer-% dist% alpha beta stable,$(MAKECMDGOALS)))
52  _is-install-target ?= $(filter-out %check, $(filter install%,$(MAKECMDGOALS)))
53  ifneq (,$(_is-dist-target)$(_is-install-target))
54    _curr-ver := $(shell cd $(srcdir)				\
55                   && $(_build-aux)/git-version-gen		\
56                         .tarball-version			\
57                         $(git-version-gen-tag-sed-script))
58    ifneq ($(_curr-ver),$(VERSION))
59      ifeq ($(_curr-ver),UNKNOWN)
60        $(info WARNING: unable to verify if $(VERSION) is the correct version)
61      else
62        ifneq (,$(_is-install-target))
63          # GNU Coding Standards state that 'make install' should not cause
64          # recompilation after 'make all'.  But as long as changing the version
65          # string alters config.h, the cost of having 'make all' always have an
66          # up-to-date version is prohibitive.  So, as a compromise, we merely
67          # warn when installing a version string that is out of date; the user
68          # should run 'autoreconf' (or something like 'make distcheck') to
69          # fix the version, 'make all' to propagate it, then 'make install'.
70          $(info WARNING: version string $(VERSION) is out of date;)
71          $(info run '$(MAKE) _version' to fix it)
72        else
73          $(info INFO: running autoreconf for new version string: $(_curr-ver))
74GNUmakefile: _version
75	touch GNUmakefile
76        endif
77      endif
78    endif
79  endif
80endif
81
82.PHONY: _version
83_version:
84	cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf)
85	$(MAKE) $(AM_MAKEFLAGS) Makefile
86
87else
88
89.DEFAULT_GOAL := abort-due-to-no-makefile
90srcdir = .
91
92# The package can override .DEFAULT_GOAL to run actions like autoreconf.
93-include ./cfg.mk
94
95# Allow cfg.mk to override these.
96_build-aux ?= build-aux
97_autoreconf ?= autoreconf -v
98
99include ./maint.mk
100
101ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
102$(MAKECMDGOALS): abort-due-to-no-makefile
103endif
104
105abort-due-to-no-makefile:
106	@echo There seems to be no Makefile in this directory.   1>&2
107	@echo "You must run ./configure before running 'make'." 1>&2
108	@exit 1
109
110endif
111
112# Tell version 3.79 and up of GNU make to not build goals in this
113# directory in parallel, in case someone tries to build multiple
114# targets, and one of them can cause a recursive target to be invoked.
115
116# Only set this if Automake doesn't provide it.
117AM_RECURSIVE_TARGETS ?= $(RECURSIVE_TARGETS:-recursive=) \
118  $(RECURSIVE_CLEAN_TARGETS:-recursive=) \
119  dist distcheck tags ctags
120
121ALL_RECURSIVE_TARGETS += $(AM_RECURSIVE_TARGETS)
122
123ifneq ($(word 2, $(MAKECMDGOALS)), )
124ifneq ($(filter $(ALL_RECURSIVE_TARGETS), $(MAKECMDGOALS)), )
125.NOTPARALLEL:
126endif
127endif
128