1# Make Autoconf commands.
2
3# Copyright (C) 1999-2007, 2009-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 3 of the License, or
8# (at your option) 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
18include ../lib/freeze.mk
19
20bin_SCRIPTS = autom4te \
21	      autoconf autoheader autoreconf ifnames autoscan autoupdate
22
23EXTRA_DIST = autoconf.as autoheader.in autoreconf.in autoupdate.in ifnames.in \
24	     autoscan.in autom4te.in
25
26# Files that should be removed, but which Automake does not know.
27MOSTLYCLEANFILES = $(bin_SCRIPTS) autoconf.in *.tmp
28
29# Get the release year from ../ChangeLog.
30RELEASE_YEAR = \
31  `sed 's/^\([0-9][0-9][0-9][0-9]\).*/\1/;q' $(top_srcdir)/ChangeLog`
32
33## ------------- ##
34## The scripts.  ##
35## ------------- ##
36
37edit = sed \
38	-e 's|@SHELL[@]|$(SHELL)|g' \
39	-e 's|@PERL[@]|$(PERL)|g' \
40	-e 's|@PERL_FLOCK[@]|$(PERL_FLOCK)|g' \
41	-e 's|@bindir[@]|$(bindir)|g' \
42	-e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
43	-e 's|@prefix[@]|$(prefix)|g' \
44	-e 's|@autoconf-name[@]|'`echo autoconf | sed '$(transform)'`'|g' \
45	-e 's|@autoheader-name[@]|'`echo autoheader | sed '$(transform)'`'|g' \
46	-e 's|@autom4te-name[@]|'`echo autom4te | sed '$(transform)'`'|g' \
47	-e 's|@M4[@]|$(M4)|g' \
48	-e 's|@M4_DEBUGFILE[@]|$(M4_DEBUGFILE)|g' \
49	-e 's|@M4_GNU[@]|$(M4_GNU)|g' \
50	-e 's|@AWK[@]|$(AWK)|g' \
51	-e 's|@RELEASE_YEAR[@]|'$(RELEASE_YEAR)'|g' \
52	-e 's|@VERSION[@]|$(VERSION)|g' \
53	-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
54	-e 's|@configure_input[@]|Generated from $@.in; do not edit by hand.|g'
55
56$(top_builddir)/bin/autom4te: autom4te
57
58# autoconf is written in M4sh.
59# FIXME: this target should depend on the frozen files below lib/m4sugar,
60# otherwise autom4te may pick up a frozen m4sh.m4f from an earlier
61# installation below the same $(prefix); work around this with --melt.
62autoconf.in: $(srcdir)/autoconf.as $(m4sh_m4f_dependencies)
63	$(MY_AUTOM4TE) --language M4sh --cache '' --melt $(srcdir)/autoconf.as -o $@
64
65## All the scripts depend on Makefile so that they are rebuilt when the
66## prefix etc. changes.  It took quite a while to have the rule correct,
67## don't break it!
68## Use chmod -w to prevent people from editing the wrong file by accident.
69$(bin_SCRIPTS): Makefile
70	rm -f $@ $@.tmp
71	srcdir=''; \
72	  test -f ./$@.in || srcdir=$(srcdir)/; \
73	  $(edit) $${srcdir}$@.in >$@.tmp
74	chmod +x $@.tmp
75	chmod a-w $@.tmp
76	mv $@.tmp $@
77
78autoconf: autoconf.in
79autoheader: $(srcdir)/autoheader.in
80autom4te: $(srcdir)/autom4te.in
81autoreconf: $(srcdir)/autoreconf.in
82autoscan: $(srcdir)/autoscan.in
83autoupdate: $(srcdir)/autoupdate.in
84ifnames: $(srcdir)/ifnames.in
85
86
87## --------------- ##
88## Building TAGS.  ##
89## --------------- ##
90
91TAGS_DEPENDENCIES = $(EXTRA_DIST)
92
93letters = abcdefghijklmnopqrstuvwxyz
94LETTERS = ABCDEFGHIJKLMNOPQRSTUVWXYZ
95DIGITS = 0123456789
96WORD_REGEXP = [$(LETTERS)$(letters)_][$(LETTERS)$(letters)$(DIGITS)_]*
97ETAGS_PERL = --lang=perl \
98  autoheader.in autoreconf.in autoupdate.in autoscan.in autom4te.in \
99  ifnames.in
100ETAGS_SH = --lang=none --regex='/\($(WORD_REGEXP)\)=/\1/' \
101  autoconf.in
102
103ETAGS_ARGS = $(ETAGS_PERL) $(ETAGS_SH)
104