Go back to requiring only Perl 5.6+ for users
[autoconf.git] / lib / freeze.mk
blob12ed4f9d1c83ce38526759559d92c7e69b53f948
1 # Freeze M4 files.
3 # Copyright (C) 2002, 2004, 2006-2017, 2020-2023 Free Software
4 # Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
20 ## ----------------- ##
21 ## Freeze M4 files. ##
22 ## ----------------- ##
24 SUFFIXES += .m4 .m4f
26 AUTOM4TE_CFG = lib/autom4te.cfg
28 # Do not use AUTOM4TE here, since maint.mk (my-distcheck)
29 # checks if we are independent of Autoconf by defining AUTOM4TE (and
30 # others) to 'false'. Autoconf provides autom4te, so that doesn't
31 # apply to us.
32 MY_AUTOM4TE = \
33 autom4te_perllibdir='$(top_srcdir)'/lib \
34 AUTOM4TE_CFG='$(AUTOM4TE_CFG)' $(top_build_prefix)bin/autom4te \
35 -B '$(top_build_prefix)'lib -B '$(top_srcdir)'/lib # keep ' '
37 # When processing the file with diversion disabled, there must be no
38 # output but comments and empty lines.
39 # If freezing produces output, something went wrong: a bad 'divert',
40 # or an improper paren etc.
41 # It may happen that the output does not end with an end of line, hence
42 # force an end of line when reporting errors.
43 .m4.m4f:
44 $(MKDIR_P) $(@D)
45 lang=`echo '$*' | sed 's,.*/,,'` \
46 && if test $$lang = autoconf; then \
47 lang=autoconf-without-aclocal-m4; \
48 else :; fi \
49 && $(MY_AUTOM4TE) \
50 --language=$$lang \
51 --freeze \
52 --output=$@
54 # Factor the dependencies between all the frozen files.
55 # Some day we should explain to Automake how to use autom4te to compute
56 # the dependencies...
57 src_libdir = $(top_srcdir)/lib
58 build_libdir = $(top_build_prefix)lib
60 m4f_dependencies = $(top_build_prefix)bin/autom4te $(AUTOM4TE_CFG)
62 m4sugar_m4f_dependencies = \
63 $(m4f_dependencies) \
64 $(src_libdir)/m4sugar/m4sugar.m4 \
65 $(build_libdir)/version.m4
67 m4sh_m4f_dependencies = \
68 $(m4sugar_m4f_dependencies) \
69 $(src_libdir)/m4sugar/m4sh.m4
71 autotest_m4f_dependencies = \
72 $(m4sh_m4f_dependencies) \
73 $(src_libdir)/autotest/autotest.m4 \
74 $(src_libdir)/autotest/general.m4 \
75 $(src_libdir)/autotest/specific.m4
77 autoconf_m4f_dependencies = \
78 $(m4sh_m4f_dependencies) \
79 $(src_libdir)/autoconf/autoscan.m4 \
80 $(src_libdir)/autoconf/general.m4 \
81 $(src_libdir)/autoconf/autoheader.m4 \
82 $(src_libdir)/autoconf/autoupdate.m4 \
83 $(src_libdir)/autoconf/autotest.m4 \
84 $(src_libdir)/autoconf/status.m4 \
85 $(src_libdir)/autoconf/oldnames.m4 \
86 $(src_libdir)/autoconf/specific.m4 \
87 $(src_libdir)/autoconf/lang.m4 \
88 $(src_libdir)/autoconf/c.m4 \
89 $(src_libdir)/autoconf/fortran.m4 \
90 $(src_libdir)/autoconf/erlang.m4 \
91 $(src_libdir)/autoconf/go.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
100 ## --------------------------- ##
101 ## Run ETAGS on some M4 code. ##
102 ## --------------------------- ##
104 ETAGS_FOR_M4 = \
105 --lang=none \
106 --regex='/\(m4_define\|define\)(\[\([^]]*\)\]/\2/'
108 ETAGS_FOR_M4SUGAR = \
109 $(ETAGS_FOR_M4) \
110 --regex='/m4_defun(\[\([^]]*\)\]/\1/'
112 ETAGS_FOR_AUTOCONF = \
113 $(ETAGS_FOR_M4SUGAR) \
114 --regex='/\(A[CU]_DEFUN\|AU_ALIAS\)(\[\([^]]*\)\]/\2/' \
115 --regex='/AN_\(FUNCTION\|HEADER\|IDENTIFIER\|LIBRARY\|MAKEVAR\|PROGRAM\)(\[\([^]]*\)\]/\2/'
118 ## -------------------------------- ##
119 ## Looking for forbidden patterns. ##
120 ## -------------------------------- ##
122 check-forbidden-patterns:
123 @if (cd $(srcdir) && \
124 $(GREP) $(forbidden_patterns) $(forbidden_patterns_files)) \
125 >forbidden.log; then \
126 echo "ERROR: forbidden patterns were found:" >&2; \
127 sed "s|^|$*.m4: |" <forbidden.log >&2; \
128 echo >&2; \
129 exit 1; \
130 else \
131 rm -f forbidden.log; \