Make GNUmakefile work with in-place builds.
[m4/ericb.git] / GNUmakefile
blob1477e0890e6c6e3ae062530b3dd0032615fc8f08
1 # Having a separate GNUmakefile lets me `include' both Makefile.maint
2 # and Makefile.
3 # This makefile is used only if you run GNU Make.
4 # It is necessary if you want to build targets usually of interest
5 # only to the maintainer.
7 # Copyright (C) 2001, 2003, 2006, 2007, 2008 Free Software Foundation,
8 # Inc.
10 # This file is part of GNU M4.
12 # GNU M4 is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # GNU M4 is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 # Systems where /bin/sh is not the default shell need this. The $(shell)
26 # command below won't work with e.g. stock DOS/Windows shells.
27 ifeq ($(wildcard /bin/s[h]),/bin/sh)
28 SHELL = /bin/sh
29 else
30 # will be used only with the next shell-test line, then overwritten
31 # by a configured-in value
32 SHELL = sh
33 endif
35 _have-Makefile := $(shell test -f Makefile && echo yes)
37 # If the user runs GNU make but has not yet run ./configure,
38 # give them a diagnostic.
39 ifeq ($(_have-Makefile),yes)
41 # Make tar archive easier to reproduce.
42 export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
44 include Makefile
46 _curr-ver := $(VERSION)
48 # Ensure that $(VERSION) is up to date for dist-related targets, but not
49 # for others: running autoreconf and recompiling everything isn't cheap.
50 ifeq (0,$(MAKELEVEL))
51 _is-dist-target = $(filter-out %clean, \
52 $(filter dist% alpha beta major,$(MAKECMDGOALS)))
53 ifneq (,$(_is-dist-target))
54 _curr-ver := $(shell cd $(srcdir) && build-aux/git-version-gen \
55 $(srcdir)/.tarball-version)
56 ifneq ($(_curr-ver),$(VERSION))
57 $(info INFO: running autoreconf for new version string: $(_curr-ver))
58 _dummy := $(shell (cd $(srcdir) && rm -rf autom4te.cache && autoreconf))
59 _created_version_file = 1
60 endif
61 endif
62 endif
64 ifneq ($(_curr-ver),$(VERSION))
65 _dummy := $(shell echo $(_curr-ver) > .version)
66 endif
68 ifneq ($(_created_version_file),1)
69 _dummy := $(shell test -f .version || echo $(VERSION) > .version)
70 endif
72 include $(srcdir)/Makefile.cfg
73 include $(srcdir)/Makefile.maint
75 else
77 all:
78 @echo There seems to be no Makefile in this directory. 1>&2
79 @echo "You must run ./configure before running \`make'." 1>&2
80 @exit 1
82 check dist distcheck install: all
84 endif
86 # Tell version 3.79 and up of GNU make to not build goals in this
87 # directory in parallel. This is necessary in case someone tries to
88 # build multiple targets on one command line.
89 .NOTPARALLEL: