ltmain.in: Use func_warning for all warnings
[libtool.git] / cfg.mk
blobff6ad6b0d8d5152d9d71dc846f435f69313dad62
1 # cfg.mk -- Configuration for maintainer-makefile
3 # Copyright (c) 2011-2019, 2021-2024 Free Software Foundation, Inc.
4 # Written by Gary V. Vaughan, 2011
6 # This file is part of GNU Libtool.
8 # GNU Libtool is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # GNU Libtool is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Libtool; see the file COPYING. If not, a copy
20 # can be downlodad from http://www.gnu.org/licenses/gpl.html,
21 # or obtained by writing to the Free Software Foundation, Inc.,
22 # 51 Franklin Street, Boston, # MA 02111-1301, USA.
24 update-copyright-env := UPDATE_COPYRIGHT_FORCE=1 UPDATE_COPYRIGHT_USE_INTERVALS=1
26 update-copyright: update-release-year
27 update-release-year:
28 $(AM_V_GEN)year=`date +%Y`; \
29 sed -i \
30 -e "/_LT_COPY/,+1 { /Copyright/ {s:[0-9][0-9][0-9][0-9]:$$year:} }" \
31 -e "/^Copyright/ {s:[0-9][0-9][0-9][0-9]:$$year:} " \
32 m4/libtool.m4
34 # Set format of NEWS.
35 old_NEWS_hash := cee442f628bc31384f4a830f2bded8eb
37 manual_title = Portable Dynamic Shared Object Management
39 # Set the release announcement email addresses, maint.mk will email the
40 # translation-project instead of autotools-announce otherwise.
41 ifeq ($(RELEASE_TYPE),stable)
42 announcement_Cc_ = autotools-announce@gnu.org
43 else
44 announcement_Cc_ = autotools-announce@gnu.org, $(PACKAGE_BUGREPORT)
45 endif
47 # Don't syntax check the mail subdirectory or patches to gnulib itself.
48 VC_LIST_ALWAYS_EXCLUDE_REGEX = ^(mail|gl)/
50 local-checks-to-fix = \
51 sc_require_config_h \
52 sc_require_config_h_first
54 local-checks-to-skip = \
55 $(local-checks-to-fix) \
56 sc_GPL_version \
57 sc_cast_of_x_alloc_return_value \
58 sc_indent \
59 sc_prohibit_always-defined_macros \
60 sc_prohibit_always_true_header_tests \
61 sc_prohibit_strncpy \
62 sc_trailing_blank \
63 sc_unmarked_diagnostics
65 # GPL_version: checks for GPLv3, which we don't use
66 # cast_of_x_alloc_return_value:
67 # We support C++ compilation, which does require casting here.
68 # prohibit_always-defined_macros:
69 # we have our own argz and dirent, which use the same macros but
70 # are not always-defined in our case.
71 # prohibit_always_true_header_tests:
72 # we have our own argz and dirent, which are not *always* true,
73 # so the guards cannot be removed in our case.
74 # prohibit_strncpy:
75 # what's so bad about strncpy anyway?
76 # trailing_blank: flags valid rfc3676 separators
77 # unmarked_diagnostics: libtool isn't internationalized
80 # Check for correct usage of $cc_basename in libtool.m4.
81 sc_libtool_m4_cc_basename:
82 @$(SED) -n "/case \\\$$cc_basename in/,/esac/ { \
83 /^[ ]*[a-zA-Z][a-zA-Z0-9+]*[^*][ ]*)/p; \
84 }" '$(srcdir)/$(macro_dir)/libtool.m4' | grep . && { \
85 msg="\$$cc_basename matches should include a trailing '*'." \
86 $(_sc_say_and_exit) } || :
88 # Check for old-style `quoting'.
89 exclude_file_name_regexp--sc_old_style_quoting = (^bootstrap|^cfg.mk|\.texi)$$
90 sc_old_style_quoting:
91 @prohibit="^[^\`]*[^=]\`[^'\`]*[a-zA-Z0-9][^'\`]*'[^\`]*[^\\\`]$$" \
92 halt="quote 'like this' not \`like this' in comments and output" \
93 $(_sc_search_regexp)
95 # Check for uses of Xsed without corresponding echo "X
96 exclude_file_name_regexp--sc_prohibit_Xsed_without_X = ^cfg.mk$$
97 sc_prohibit_Xsed_without_X:
98 @files=$$($(VC_LIST_EXCEPT)); \
99 if test -n "$$files"; then \
100 grep -nE '\$$Xsed' $$files | grep -vE '(func_echo_all|\$$ECHO) \\*"X' && { \
101 msg="occurrences of '\$$Xsed' without '\$$ECHO "\""X' on the same line" \
102 $(_sc_say_and_exit) } || :; \
103 else :; \
104 fi || :
106 # Use a consistent dirname and basename idiom.
107 sc_prohibit_bare_basename:
108 @prohibit='\|[ ]*\$$(base|dir)name' \
109 halt='use '\''|$$SED "$$basename"'\'' instead of '\''|$$basename'\' \
110 $(_sc_search_regexp)
112 sc_prohibit_basename_with_dollar_sed:
113 @prohibit='(base|dir)name="?(\$$SED|sed)[ "]' \
114 halt='use '\''basename='\''s|^.*/||'\'' instead of '\''basename="$$SED...' \
115 $(_sc_search_regexp)
117 # Check for using '[' instead of 'test'.
118 exclude_file_name_regexp--sc_prohibit_bracket_as_test = ^cfg.mk$$
119 sc_prohibit_bracket_as_test:
120 @prohibit='if[ ]+\[' \
121 halt="use 'if test' instead of 'if ['" \
122 $(_sc_search_regexp)
124 # : ${foo=`bar`} is not perfectly portable (see Shellology in autoconf's manual)
125 exclude_file_name_regexp--sc_prohibit_command_in_subst = ^cfg.mk$$
126 sc_prohibit_command_in_subst:
127 @prohibit='\$$\{[^`}]*`[^`]*`[^}]*}' \
128 halt='do not use `command` in $${ } substitution`' \
129 $(_sc_search_regexp)
131 # Check for quotes within backquotes within quotes "`"bar"`"
132 exclude_file_name_regexp--sc_prohibit_nested_quotes = ^cfg.mk$$
133 sc_prohibit_nested_quotes:
134 @prohibit='"[^`"]*`[^"`]*"[^"`]*".*`[^`"]*"' \
135 halt='found nested double quotes' \
136 $(_sc_search_regexp_or_exclude)
138 # Commas in filenames are quite common, so using them routinely for sed is
139 # asking for trouble!
140 sc_prohibit_sed_s_comma:
141 @explicit='($$SED|sed)[ ]+(-e[ ]+)?['\''"]?s,' \
142 implicit='['\''";][ ]*s,[^,]*,[^,]*,g?['\''";]' \
143 literal='^[ ]*s,[^,]*,[^,]*,g?['\''";]?$$' \
144 prohibit='('$$implicit'|'$$explicit'|'$$literal')' \
145 halt='found use of comma separator in sed substitution' \
146 $(_sc_search_regexp)
148 # Check for using shift after set dummy (same or following line).
149 exclude_file_name_regexp--sc_prohibit_set_dummy_without_shift = ^cfg.mk$$
150 sc_prohibit_set_dummy_without_shift:
151 @files=$$($(VC_LIST_EXCEPT)); \
152 if test -n "$$files"; then \
153 grep -nE '(set dummy|shift)' $$files | \
154 $(SED) -n "/set[ ][ ]*dummy/{ \
155 /set.*dummy.*;.*shift/d; \
156 N; \
157 /\n.*shift/D; \
158 p; \
159 }" | grep -n . && { \
160 msg="use 'shift' after 'set dummy'" \
161 $(_sc_say_and_exit) } || :; \
162 else :; \
163 fi || :
165 # Check for using set -- instead of set dummy
166 exclude_file_name_regexp--sc_prohibit_set_minus_minus = ^cfg.mk$$
167 sc_prohibit_set_minus_minus:
168 @prohibit='set[ ]+--[ ]+' \
169 halt="use 'set dummy ...' instead of 'set -- ...'" \
170 $(_sc_search_regexp)
172 # Make sure there is no spurious whitespace before trailing semi-colons
173 sc_prohibit_space_semicolon:
174 @prohibit='[^ ][ ]+;[ ]*((do|done|elif|else|then)[ ]*)?$$' \
175 halt='found spurious whitespace before trailing semi-colon' \
176 $(_sc_search_regexp)
178 # Check for using test X"... instead of test "X...
179 exclude_file_name_regexp--sc_prohibit_test_X = ^cfg.mk$$
180 sc_prohibit_test_X:
181 @prohibit='test[ ]+(![ ])?(-.[ ]+)?[Xx]["'\'']' \
182 halt='use '\''test "X..."'\'' instead of '\''test X"'\' \
183 $(_sc_search_regexp)
185 # Check for bad binary operators.
186 sc_prohibit_test_binary_operators:
187 @prohibit='if[ ]+["'\'']?\$$[^ ]+[ ]+(=|-[lg][te]|-eq|-ne)' \
188 halt="Use 'if test \$$something =' instead of 'if \$$something ='" \
189 $(_sc_search_regexp)
191 # Check for using test $... instead of test "$...
192 exclude_file_name_regexp--sc_prohibit_test_dollar = ^cfg.mk$$
193 sc_prohibit_test_dollar:
194 @prohibit='test[ ]+(![ ])?(-.[ ]+)?X?\$$[^?#]' \
195 exclude='test \$${[A-Za-z_][A-Za-z0-9_]+\+y}' \
196 halt='use '\''test "$$..."'\'' instead of '\''test $$'\' \
197 $(_sc_search_regexp)
199 # Never use test -e.
200 exclude_file_name_regexp--sc_prohibit_test_minus_e = ^cfg.mk$$
201 sc_prohibit_test_minus_e:
202 @prohibit='test[ ]+(![ ])?-e' \
203 halt="use 'test -f' instead of 'test -e'" \
204 $(_sc_search_regexp)
206 # Check for bad unary operators.
207 sc_prohibit_test_unary_operators:
208 @prohibit='if[ ]+-[a-z]' \
209 halt="use 'if test -X' instead of 'if -X'" \
210 $(_sc_search_regexp)
212 # Don't add noisy characters on the front of the left operand of a test
213 # to prevent arguments being passed inadvertently (e.g. LHS is '-z'),
214 # when the other operand is a constant -- just swap them, and remove the
215 # spurious leading 'x'.
216 sc_prohibit_test_const_follows_var:
217 @var='[ ]+"[^$$"]*\$$[0-9A-Za-z_][^"]*"' \
218 op='[ ]+(!?=|-[lgn][et]|-eq)' \
219 const='[ ]+[^-$$][^$$; ]*' \
220 prohibit='test'$$var$$op$$const'[ ]*(&&|\|\||;|\\?$$)' \
221 halt='use '\''test a = "$$b"'\'' instead of '\''test "x$$b" = xa'\' \
222 $(_sc_search_regexp)
224 # Check for opening brace on next line in shell function definition.
225 exclude_file_name_regexp--sc_require_function_nl_brace = (^HACKING|\.[ch]|\.texi)$$
226 sc_require_function_nl_brace:
227 @for file in $$($(VC_LIST_EXCEPT)); do \
228 $(SED) -n "/^func_[^ ]*[ ]*(/{ \
229 N; \
230 /^func_[^ ]* ()\n{$$/d; \
231 p; \
232 }" $$file | grep -E . && { \
233 msg="found malformed function_definition in $$file" \
234 $(_sc_say_and_exit) } || :; \
235 done
237 sc_trailing_blank-non-rfc3676:
238 @prohibit='([^-][^-][ ][ ]*|^[ ][ ]*)$$' \
239 halt='found trailing blank(s)' \
240 $(_sc_search_regexp)
242 # Avoid useless quotes around assignments with no shell metacharacters.
243 # Backtick and dollar expansions are not resplit on the RHS of an
244 # assignment, so those metachars are not listed in the prohibit regex,
245 # although @ is listed, since it most likely indicates that something
246 # will be spliced in before the shell executes, and it may need to be
247 # quoted if it contains any metacharacters after splicing.
248 define _sc_search_regexp_or_exclude
249 files=$$($(VC_LIST_EXCEPT)); \
250 if test -n "$$files"; then \
251 grep -nE "$$prohibit" $$files | grep -v '## exclude from $@' \
252 && { msg="$$halt" $(_sc_say_and_exit) } || :; \
253 else :; \
254 fi || :;
255 endef
257 exclude_file_name_regexp--sc_useless_braces_in_variable_derefs = \
258 test-funclib-quote.sh$$
259 sc_useless_braces_in_variable_derefs:
260 @prohibit='\$${[0-9A-Za-z_]+}[^0-9A-Za-z_]' \
261 halt='found spurious braces around variable dereference' \
262 $(_sc_search_regexp)
264 sc_useless_quotes_in_assignment:
265 @prohibit='^[ ]*[A-Za-z_][A-Za-z0-9_]*="[^ !#&()*;<>?@~^{|}]*"$$' \
266 halt='found spurious quotes around assignment value' \
267 $(_sc_search_regexp_or_exclude)
269 # Avoid useless quotes around case arguments such as:
270 # case "$foo" in ...
271 exclude_file_name_regexp--sc_useless_quotes_in_case = ^cfg.mk$$
272 sc_useless_quotes_in_case:
273 @prohibit='case "[^ "]*"[ ][ ]*in' \
274 halt='found spurious quotes around case argument' \
275 $(_sc_search_regexp)
277 # List syntax-check exempted files.
278 exclude_file_name_regexp--sc_prohibit_strcmp = \
279 ^doc/libtool.texi$$
280 exclude_file_name_regexp--sc_prohibit_test_minus_ao = \
281 ^m4/libtool.m4$$
282 exclude_file_name_regexp--sc_space_tab = (\.diff|test-funclib-quote.sh)$$
283 exclude_file_name_regexp--sc_trailing_blank-non-rfc3676 = \.diff$$