1## Freeze M4 files.
2
3## Copyright (C) 2002, 2004, 2006 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, write to the Free Software
17## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18## 02110-1301, USA.
19
20
21## ----------------- ##
22## Freeze M4 files.  ##
23## ----------------- ##
24
25SUFFIXES = .m4 .m4f
26
27AUTOM4TE_CFG = $(top_builddir)/lib/autom4te.cfg
28$(AUTOM4TE_CFG): $(top_srcdir)/lib/autom4te.in
29	cd $(top_builddir)/lib && $(MAKE) $(AM_MAKEFLAGS) autom4te.cfg
30
31# Do not use AUTOM4TE here, since Makefile.maint (my-distcheck)
32# checks if we are independent of Autoconf by defining AUTOM4TE (and
33# others) to `false'.  Autoconf provides autom4te, so that doesn't
34# apply to us.
35MY_AUTOM4TE =									\
36	autom4te_perllibdir='$(top_srcdir)'/lib					\
37	AUTOM4TE_CFG='$(AUTOM4TE_CFG)'         $(top_builddir)/bin/autom4te	\
38		-B '$(top_builddir)'/lib -B '$(top_srcdir)'/lib        # keep ` '
39
40# When processing the file with diversion disabled, there must be no
41# output but comments and empty lines.
42# If freezing produces output, something went wrong: a bad `divert',
43# or an improper paren etc.
44# It may happen that the output does not end with an end of line, hence
45# force an end of line when reporting errors.
46.m4.m4f:
47	$(MY_AUTOM4TE)				\
48		--language=$*			\
49		--freeze			\
50		--output=$@
51
52# Factor the dependencies between all the frozen files.
53# Some day we should explain to Automake how to use autom4te to compute
54# the dependencies...
55src_libdir   = $(top_srcdir)/lib
56build_libdir = $(top_builddir)/lib
57
58m4f_dependencies = $(top_builddir)/bin/autom4te $(AUTOM4TE_CFG)
59
60# For parallel builds.
61$(build_libdir)/m4sugar/version.m4:
62	cd $(build_libdir)/m4sugar && $(MAKE) $(AM_MAKEFLAGS) version.m4
63
64m4sugar_m4f_dependencies =			\
65	$(m4f_dependencies)			\
66	$(src_libdir)/m4sugar/m4sugar.m4	\
67	$(build_libdir)/m4sugar/version.m4
68
69m4sh_m4f_dependencies =				\
70	$(m4sugar_m4f_dependencies)		\
71	$(src_libdir)/m4sugar/m4sh.m4
72
73autotest_m4f_dependencies =			\
74	$(m4sh_m4f_dependencies)		\
75	$(src_libdir)/autotest/autotest.m4	\
76	$(src_libdir)/autotest/general.m4
77
78autoconf_m4f_dependencies =			\
79	$(m4sh_m4f_dependencies)		\
80	$(src_libdir)/autoconf/autoscan.m4	\
81	$(src_libdir)/autoconf/general.m4	\
82	$(src_libdir)/autoconf/autoheader.m4	\
83	$(src_libdir)/autoconf/autoupdate.m4	\
84	$(src_libdir)/autoconf/autotest.m4	\
85	$(src_libdir)/autoconf/status.m4	\
86	$(src_libdir)/autoconf/oldnames.m4	\
87	$(src_libdir)/autoconf/specific.m4	\
88	$(src_libdir)/autoconf/lang.m4		\
89	$(src_libdir)/autoconf/c.m4		\
90	$(src_libdir)/autoconf/fortran.m4	\
91	$(src_libdir)/autoconf/erlang.m4	\
92	$(src_libdir)/autoconf/functions.m4	\
93	$(src_libdir)/autoconf/headers.m4	\
94	$(src_libdir)/autoconf/types.m4		\
95	$(src_libdir)/autoconf/libs.m4		\
96	$(src_libdir)/autoconf/programs.m4	\
97	$(src_libdir)/autoconf/autoconf.m4
98
99
100## --------------------------- ##
101## Run ETAGS on some M4 code.  ##
102## --------------------------- ##
103
104ETAGS_FOR_M4 = \
105  --lang=none \
106  --regex='/\(m4_define\|define\)(\[\([^]]*\)\]/\2/'
107
108ETAGS_FOR_M4SUGAR = \
109  $(ETAGS_FOR_M4) \
110  --regex='/m4_defun(\[\([^]]*\)\]/\1/'
111
112ETAGS_FOR_AUTOCONF = \
113  $(ETAGS_FOR_M4SUGAR) \
114  --regex='/\(A[CU]_DEFUN\|AU_ALIAS\)(\[\([^]]*\)\]/\2/' \
115  --regex='/AN_\(FUNCTION\|HEADER\|IDENTIFIER\|LIBRARY\|MAKEVAR\|PROGRAM\)(\[\([^]]*\)\]/\2/'
116
117
118## ---------- ##
119## Run GREP.  ##
120## ---------- ##
121
122GREP = @GREP@
123
124
125## -------------------------------- ##
126## Looking for forbidden patterns.  ##
127## -------------------------------- ##
128
129check-forbidden-patterns:
130	@if (cd $(srcdir) && \
131	    $(GREP) $(forbidden_patterns) $(forbidden_patterns_files)) \
132	    >forbidden.log; then \
133	  echo "ERROR: forbidden patterns were found:" >&2; \
134	  sed "s,^,$*.m4: ," <forbidden.log >&2; \
135	  echo >&2; \
136	  exit 1; \
137	else \
138	  rm -f forbidden.log; \
139	fi
140