c32srtombs,mbsrtoc32s,mbsrtowcs,wcsrtombs: pacify GCC 14
[gnulib.git] / Makefile
blob0f0b24ee96c9f05fb37ebfa51f1406c96fc9c0fa
1 # GNU Makefile for gnulib central.
2 # Copyright (C) 2006, 2009-2024 Free Software Foundation, Inc.
4 # Copying and distribution of this file, with or without modification,
5 # in any medium, are permitted without royalty provided the copyright
6 # notice and this notice are preserved.
8 # This Makefile requires the use of GNU make. Some targets require
9 # that you have tools like git, makeinfo and cppi installed.
11 # Required for the use of <(...) below.
12 SHELL=bash
14 # Produce some files that are not stored in the repository.
15 all:
17 # Produce the documentation in readable form.
18 info html dvi pdf:
19 cd doc && $(MAKE) $@ && $(MAKE) mostlyclean
21 # Collect the names of rules starting with 'sc_'.
22 syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p'\
23 Makefile))
25 # Perform some platform independent checks on the gnulib code.
26 check: $(syntax-check-rules)
28 sc_prefer_ac_check_funcs_once:
29 @if test -d .git; then \
30 git grep -w -l AC_CHECK_FUNCS modules \
31 && { echo use AC_CHECK_FUNCS_ONCE, not AC_CHECK_FUNCS \
32 in modules/ 1>&2; exit 1; } || : \
33 else :; fi
35 sc_prohibit_leading_TABs:
36 @if test -d .git; then \
37 git grep -l '^ * ' lib m4 tests \
38 | grep -Ev '^lib/reg|Makefile|test-update-copyright' \
39 | grep . \
40 && { printf '*** %s\n' 'indent with spaces, not TABs;' \
41 1>&2; exit 1; } || : \
42 else :; fi
44 sc_prohibit_augmenting_PATH_via_TESTS_ENVIRONMENT:
45 @if test -d .git; then \
46 url=https://lists.gnu.org/r/bug-gnulib/2010-09/msg00064.html; \
47 git grep '^[ ]*TESTS_ENVIRONMENT += PATH=' modules \
48 && { printf '%s\n' 'Do not augment PATH via TESTS_ENVIRONMENT;' \
49 " see <$$url>" 1>&2; exit 1; } || : \
50 else :; fi
52 # It's easy to forget the noise-suppressing "@" at the beginning
53 # of each sc_ rule. Check for it both in maint.mk and in this file.
54 sc_prohibit_sc_omitted_at:
55 @if test -d .git; then \
56 git grep -n -A1 '^sc_[[:alnum:]_-]*:' top/maint.mk Makefile \
57 | grep -vE ':sc_|[0-9][-] @|--$$' \
58 | sed 's/-\([0-9][0-9]*\)-/:\1:/' \
59 | grep . \
60 && { printf '*** %s\n' 'oops; missing "@"' \
61 1>&2; exit 1; } || : \
62 else :; fi
64 # Run all maint.mk syntax-check tests on gnulib's sources.
65 sc_maint:
66 @rm -f maint.mk; ln -s top/maint.mk maint.mk
67 $(MAKE) -s srcdir=. gnulib_dir=. _build-aux=build-aux \
68 -f cfg.mk -f maint.mk syntax-check
69 rm -f maint.mk
71 # Files in m4/ that (exceptionally) may use AC_LIBOBJ.
72 # Do not include their ".m4" suffix.
73 allow_AC_LIBOBJ = \
74 close \
75 dprintf \
76 dup2 \
77 faccessat \
78 fchdir \
79 fclose \
80 fcntl \
81 fprintf-posix \
82 open \
83 printf-posix \
84 snprintf \
85 sprintf-posix \
86 stdio_h \
87 termcap \
88 terminfo \
89 vasnprintf \
90 vasprintf \
91 vdprintf \
92 vfprintf-posix \
93 vprintf-posix \
94 vsnprintf \
95 vsprintf-posix
97 allow_AC_LIBOBJ_or := $(shell echo $(allow_AC_LIBOBJ) | tr -s ' ' '|')
99 sc_prohibit_AC_LIBOBJ_in_m4:
100 @url=https://lists.gnu.org/r/bug-gnulib/2011-06/msg00051.html; \
101 if test -d .git; then \
102 git ls-files m4 \
103 | grep -Ev '^m4/($(allow_AC_LIBOBJ_or))\.m4$$' \
104 | xargs grep '^ *AC_LIBOBJ(' \
105 && { printf '%s\n' 'Do not use AC_LIBOBJ in m4/*.m4;' \
106 "see <$$url>"; exit 1; } || :; \
107 else :; fi
109 sc_pragma_columns:
110 @if test -d .git; then \
111 git ls-files|grep '\.in\.h$$' \
112 | xargs grep -l '^@PRAGMA_SYSTEM_HEADER@' \
113 | xargs grep -L '^@PRAGMA_COLUMNS@' \
114 | grep . \
115 && { printf '%s\n' \
116 'the files listed above use @PRAGMA_SYSTEM_HEADER@' \
117 'without also using @PRAGMA_COLUMNS@' 1>&2; \
118 exit 1; } || :; \
119 else :; fi
121 # Verify that certain (for now, only Jim Meyering and Eric Blake's)
122 # *.c files are consistently cpp indented.
123 sc_cpp_indent_check:
124 @./gnulib-tool --extract-filelist \
125 $$(cd ./modules; grep -ilrE '(meyering|blake)' .) \
126 | sort -u \
127 | grep '\.c$$' \
128 | grep -vE '/(stdio-(read|write)|getloadavg)\.c$$' \
129 | xargs cppi -c
131 # Ensure that the list of symbols checked for by the
132 # sc_prohibit_intprops_without_use rule match those in the actual file.
133 # Extract the symbols from the .h file and compare with the list of
134 # symbols extracted from the rule in maint.mk.
135 sc_check_sym_list:
136 @i=lib/intprops.h; \
137 diff -u <(perl -lne '/^# *define ([A-Z]\w+)\(/ and print $$1' $$i|fmt) \
138 <(sed -n /^_intprops_name/,/^_intprops_syms_re/p top/maint.mk \
139 |sed '/^_/d;s/^ //;s/ *\\$$//')
142 # List of C macros defined through AH_VERBATIM in m4/extern-inline.m4:
143 config_h_MACROS1 = \
144 _GL_INLINE \
145 _GL_EXTERN_INLINE \
146 _GL_INLINE_HEADER_BEGIN \
147 _GL_INLINE_HEADER_END
148 # List of C macros defined through AH_VERBATIM in m4/gnulib-common.m4:
149 config_h_MACROS2 = \
150 _GL_GNUC_PREREQ \
151 _Noreturn \
152 _GL_ATTRIBUTE_ALLOC_SIZE \
153 _GL_ATTRIBUTE_ALWAYS_INLINE \
154 _GL_ATTRIBUTE_ARTIFICIAL \
155 _GL_ATTRIBUTE_COLD \
156 _GL_ATTRIBUTE_CONST \
157 _GL_ATTRIBUTE_DEALLOC \
158 _GL_ATTRIBUTE_DEPRECATED \
159 _GL_ATTRIBUTE_ERROR \
160 _GL_ATTRIBUTE_WARNING \
161 _GL_ATTRIBUTE_EXTERNALLY_VISIBLE \
162 _GL_ATTRIBUTE_FALLTHROUGH \
163 _GL_ATTRIBUTE_FORMAT \
164 _GL_ATTRIBUTE_LEAF \
165 _GL_ATTRIBUTE_MALLOC \
166 _GL_ATTRIBUTE_MAY_ALIAS \
167 _GL_ATTRIBUTE_MAYBE_UNUSED \
168 _GL_UNUSED \
169 _GL_ATTRIBUTE_NODISCARD \
170 _GL_ATTRIBUTE_NOINLINE \
171 _GL_ATTRIBUTE_NONNULL \
172 _GL_ATTRIBUTE_NONSTRING \
173 _GL_ATTRIBUTE_NOTHROW \
174 _GL_ATTRIBUTE_PACKED \
175 _GL_ATTRIBUTE_PURE \
176 _GL_ATTRIBUTE_RETURNS_NONNULL \
177 _GL_ATTRIBUTE_SENTINEL \
178 _GL_ATTRIBUTE_UNUSED \
179 _GL_UNUSED_LABEL \
180 _GL_BEGIN_C_LINKAGE \
181 _GL_END_C_LINKAGE \
182 _GL_ASYNC_SAFE \
183 _GL_CMP
184 # List of C macros defined through AH_VERBATIM in m4/nullptr.m4:
185 config_h_MACROS3 = \
186 nullptr
187 # List of C macros defined through AH_VERBATIM in m4/posixcheck.m4:
188 config_h_MACROS4 = \
189 GNULIB_POSIXCHECK
190 # List of C macros defined through AH_VERBATIM in m4/sh-filename.m4:
191 config_h_MACROS5 = \
192 BOURNE_SHELL
193 # List of C macros defined through AH_VERBATIM in m4/stdalign.m4:
194 config_h_MACROS6 = \
195 alignof \
196 alignas
197 # List of C macros defined through AH_VERBATIM in m4/stdarg.m4:
198 config_h_MACROS7 = \
199 va_copy
200 # List of C macros defined through AH_VERBATIM in m4/threads_h.m4:
201 config_h_MACROS8 = \
202 _Thread_local
203 # List of C macros defined through AH_VERBATIM (only the most important ones):
204 config_h_MACROS = \
205 $(config_h_MACROS1) $(config_h_MACROS2) $(config_h_MACROS3) \
206 $(config_h_MACROS4) $(config_h_MACROS5) $(config_h_MACROS6) \
207 $(config_h_MACROS7) $(config_h_MACROS8)
209 # Ensure that .h files that use macros from config.h contain a reminder to
210 # include <config.h>.
211 sc_check_config_h_reminder:
212 fail=0; \
213 for file in `grep -l -F -w -f <(for macro in $(config_h_MACROS); do echo $$macro; done) lib/*.h lib/*/*.h`; do \
214 : "Filter out .h files that are not public header files of their respective module."; \
215 include_pattern='[<"]'`echo $$file | sed -e 's,^lib/,,' -e 's,[.]in[.]h,.h,' -e 's,_,[/_],g' -e 's,[.],[.],g'`'[>"]' ; \
216 if ./gnulib-tool --extract-include-directive `./gnulib-tool --find $$file` | grep "$$include_pattern" >/dev/null; then \
217 grep '# *error "Please include config[.]h first[.]"' $$file >/dev/null \
218 || { echo -n "File $$file lacks a config.h reminder. Needed for:"; \
219 for macro in $(config_h_MACROS); do \
220 if grep -F -w $$macro $$file >/dev/null; then echo -n " $$macro"; fi; \
221 done; \
222 if grep -F HAVE_RAW_DECL_ $$file >/dev/null; then echo -n " HAVE_RAW_DECL_*"; fi; \
223 echo; \
224 fail=1; \
225 }; \
226 fi; \
227 done; \
228 exit $$fail
231 # Ensure that .h files that invoke _GL_INLINE_HEADER_BEGIN also invoke
232 # _GL_INLINE_HEADER_END. Otherwise, some GCC diagnostics remain turned off
233 # for the rest of the compilation unit.
234 sc_check_GL_INLINE_HEADER_use:
235 fail=0; \
236 for file in `grep -l -F -w _GL_INLINE_HEADER_BEGIN lib/*.h lib/*/*.h`; do \
237 grep -l -F -w _GL_INLINE_HEADER_END $$file >/dev/null \
238 || { echo "File $$file lacks an invocation of _GL_INLINE_HEADER_END."; \
239 fail=1; \
240 }; \
241 done; \
242 exit $$fail
244 # Ensure that the copyright statements in files and in the module descriptions
245 # are consistent.
246 sc_check_copyright:
247 @./check-copyright
249 # Regenerate some files that are stored in the repository.
250 regen: build-aux/bootstrap MODULES.html
252 # build-aux/bootstrap needs to be regenerated from top/bootstrap*.
253 build-aux/bootstrap: top/gen-bootstrap.sed top/bootstrap top/bootstrap-funclib.sh
254 sed -f top/gen-bootstrap.sed < top/bootstrap > build-aux/bootstrap-tmp
255 chmod a+x build-aux/bootstrap-tmp
256 mv build-aux/bootstrap-tmp build-aux/bootstrap
258 # MODULES.html is periodically being generated and copied to the web pages at
259 # :ext:USER@cvs.savannah.gnu.org:/web/gnulib/gnulib/
260 # where it then appears at <https://www.gnu.org/software/gnulib/MODULES.html>.
261 MODULES.html: MODULES.html.sh
262 ./MODULES.html.sh > MODULES.html
264 # A perl BEGIN block to set Y to the current year number and W to Y-1.
265 _year_and_prev = BEGIN{@t=localtime(time); $$y=$$t[5]+1900; $$w=$$y-1}
267 # Which TZ setting to use when updating copyright.
268 COPYRIGHT_TZ = UTC0
270 # Run this rule once per year (usually early in January)
271 # to update all FSF copyright year lists here.
272 # We exclude the files listed in srclist.txt (maintained elsewhere)
273 # as well as those in tests/unictype (generated).
274 # Also exclude any file that includes the "GENERATED AUTOMATICALLY" comment,
275 # being careful not to exclude code that merely generates the comment.
276 # Also exclude doc/INSTALL*, since they too are generated.
277 # Also adjust template-style files that must start with a single
278 # (the current) year number in some places.
279 # Also adjust version-etc.c and gendocs.sh.
280 update-copyright:
281 export TZ='$(COPYRIGHT_TZ)'; \
282 exempt=$$(mktemp); \
283 grep -v '^#' config/srclist.txt|grep -v '^$$' \
284 | while read top src dst options; do \
285 test -f "$$dst" && { echo "$$dst"; continue; }; \
286 test -d "$$dst" || continue; \
287 echo "$$dst"/$$(basename "$$src"); \
288 done > $$exempt; \
289 git ls-files doc/INSTALL* >> $$exempt; \
290 for file in $$(git ls-files); do \
291 test ! -h $$file || echo $$file; \
292 done >> $$exempt; \
293 git ls-files | grep -vFf $$exempt \
294 | xargs grep -L '^/\*.*GENERATED AUTOMATICALLY' \
295 | UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79 \
296 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
297 xargs build-aux/update-copyright
298 export TZ='$(COPYRIGHT_TZ)'; \
299 perl -pi -e '$(_year_and_prev) s/(copyright.*)\b$$w\b/$$1$$y/i' \
300 lib/version-etc.c doc/gnulib.texi build-aux/gendocs.sh
301 export TZ='$(COPYRIGHT_TZ)'; \
302 perl -pi -e '$(_year_and_prev) s/ $$w-$$y / $$y /g' \
303 doc/gendocs_template* build-aux/gendocs.sh
304 export TZ='$(COPYRIGHT_TZ)'; \
305 perl -pi -e \
306 '$(_year_and_prev) s/^(scriptversion=)$$w.*/$$1$$y-01-01.00/i' \
307 build-aux/gendocs.sh