summaryrefslogtreecommitdiffstats
path: root/maint.mk
diff options
context:
space:
mode:
Diffstat (limited to 'maint.mk')
-rw-r--r--maint.mk128
1 files changed, 111 insertions, 17 deletions
diff --git a/maint.mk b/maint.mk
index 44f3db9..c30e71b 100644
--- a/maint.mk
+++ b/maint.mk
@@ -2,7 +2,7 @@
# This Makefile fragment tries to be general-purpose enough to be
# used by many projects via the gnulib maintainer-makefile module.
-## Copyright (C) 2001-2023 Free Software Foundation, Inc.
+## Copyright (C) 2001-2024 Free Software Foundation, Inc.
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -180,7 +180,7 @@ no-vc-detected:
endif
.PHONY: $(local-checks-available)
-# Arrange to print the name of each syntax-checking rule just before running it.
+# Arrange to prine the name of each syntax-checking rule just before running it.
$(syntax-check-rules): %: %.m
sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules))
.PHONY: $(sc_m_rules_)
@@ -503,6 +503,7 @@ sc_prohibit_have_config_h:
# Nearly all .c files must include <config.h>. However, we also permit this
# via inclusion of a package-specific header, if cfg.mk specified one.
# config_h_header must be suitable for grep -E.
+# Rationale: The Gnulib documentation, node 'Include <config.h>'.
config_h_header ?= <config\.h>
sc_require_config_h:
@require='^# *include $(config_h_header)' \
@@ -526,6 +527,7 @@ perl_config_h_first_ = \
# You must include <config.h> before including any other header file.
# This can possibly be via a package-specific header, if given by cfg.mk.
+# Rationale: The Gnulib documentation, node 'Include <config.h>'.
sc_require_config_h_first:
@if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \
files=$$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$') && \
@@ -535,6 +537,89 @@ sc_require_config_h_first:
else :; \
fi
+# Generated headers that override system headers.
+# Keep sorted.
+gl_prefer_angle_bracket_headers_ ?= \
+ alloca.h \
+ arpa/inet.h \
+ assert.h \
+ ctype.h \
+ dirent.h \
+ errno.h \
+ error.h \
+ fcntl.h \
+ fenv.h \
+ float.h \
+ fnmatch.h \
+ getopt.h \
+ glob.h \
+ iconv.h \
+ inttypes.h \
+ langinfo.h \
+ limits.h \
+ locale.h \
+ malloc.h \
+ math.h \
+ monetary.h \
+ netdb.h \
+ net/if.h \
+ netinet/in.h \
+ omp.h \
+ poll.h \
+ pthread.h \
+ pty.h \
+ sched.h \
+ search.h \
+ selinux/selinux.h \
+ signal.h \
+ spawn.h \
+ stdalign.h \
+ stdarg.h \
+ stddef.h \
+ stdint.h \
+ stdio.h \
+ stdlib.h \
+ string.h \
+ strings.h \
+ sysexits.h \
+ sys/file.h \
+ sys/ioctl.h \
+ sys/msg.h \
+ sys/random.h \
+ sys/resource.h \
+ sys/select.h \
+ sys/sem.h \
+ sys/shm.h \
+ sys/socket.h \
+ sys/stat.h \
+ sys/time.h \
+ sys/times.h \
+ sys/types.h \
+ sys/uio.h \
+ sys/utsname.h \
+ sys/wait.h \
+ termios.h \
+ threads.h \
+ time.h \
+ uchar.h \
+ unistd.h \
+ utime.h \
+ utmp.h \
+ wchar.h \
+ wctype.h
+
+# Remove each .h suffix and change each space to "|".
+angle_bracket_header_re = \
+ $(subst $(_sp),|,$(patsubst %.h,%,$(gl_prefer_angle_bracket_headers_)))
+
+# Suggest using '#include <header.h>' instead of '#include "header.h"' for
+# headers that override system headers.
+# Rationale: The Gnulib documentation, node 'Style of #include statements'.
+sc_prefer_angle_bracket_headers:
+ @prohibit='^ *# *include "($(angle_bracket_header_re))\.h"' \
+ halt='Use #include <hdr.h>, not #include "hdr.h" for the above' \
+ $(_sc_search_regexp)
+
sc_prohibit_HAVE_MBRTOWC:
@prohibit='\bHAVE_MBRTOWC\b' \
halt="do not use $$prohibit; it is always defined" \
@@ -598,23 +683,14 @@ sc_prohibit_error_without_use:
re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
$(_sc_header_without_use)
-# Don't include xalloc.h unless you use one of its functions.
+# Don't include xalloc.h unless you use one of its symbols.
# Consider these symbols:
# perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
-# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/xalloc.h
+# perl -lne 'm{^(?:_Noreturn )?(?:void|char) \*?(\w+) *\(} and print $1' lib/xalloc.h
# Divide into two sets on case, and filter each through this:
# | sort | perl -MRegexp::Assemble -le \
# 'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
-# Note this was produced by the above:
-# _xa1 = \
-#x(((2n?)?re|c(har)?|n(re|m)|z)alloc|alloc_(oversized|die)|m(alloc|emdup)|strdup)
-# But we can do better, in at least two ways:
-# 1) take advantage of two "dup"-suffixed strings:
-# x(((2n?)?re|c(har)?|n(re|m)|[mz])alloc|alloc_(oversized|die)|(mem|str)dup)
-# 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more readable
-# "char|[cmz]"
-# x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
-_xa1 = x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup)
+_xa1 = x(i(m(emdup0?|alloc)|realloc(array)?|([cz]|nm)alloc)|([pz]|c(har)?|2n?re|nm)alloc|realloc(array)?|m(alloc|emdup)|alloc_die|strdup)
_xa2 = X([CZ]|N?M)ALLOC
sc_prohibit_xalloc_without_use:
@h='xalloc.h' \
@@ -745,7 +821,8 @@ sc_prohibit_intprops_without_use:
re='\<($(_intprops_syms_re)) *\(' \
$(_sc_header_without_use)
-_stddef_syms_re = NULL|offsetof|ptrdiff_t|size_t|wchar_t
+_stddef_syms_re = \
+ NULL|max_align_t|nullptr_t|offsetof|ptrdiff_t|size_t|unreachable|wchar_t
# Prohibit the inclusion of stddef.h without an actual use.
sc_prohibit_stddef_without_use:
@h='stddef.h' \
@@ -922,6 +999,7 @@ sc_prohibit_always-defined_macros:
exit 1; } \
|| :; \
fi
+
# ==================================================================
# Prohibit checked in backup files.
@@ -1006,12 +1084,12 @@ sc_prohibit_empty_lines_at_EOF:
exit 1; } \
|| :
-# Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
+# Make sure we don't use st_blocks. Use ST_NBLOCKS or STP_NBLOCKS instead.
# This is a bit of a kludge, since it prevents use of the string
# even in comments, but for now it does the job with no false positives.
sc_prohibit_stat_st_blocks:
@prohibit='[.>]st_blocks' \
- halt='do not use st_blocks; use ST_NBLOCKS' \
+ halt='do not use st_blocks; use ST_NBLOCKS or STP_NBLOCKS' \
$(_sc_search_regexp)
# Make sure we don't define any S_IS* macros in src/*.c files.
@@ -1377,6 +1455,22 @@ sc_unportable_grep_q:
@prohibit='grep -q' halt="unportable 'grep -q', use >/dev/null instead" \
$(_sc_search_regexp)
+# The GNU Coding standards say that README should refer to both
+# INSTALL and the file that contains the copying conditions. This
+# shall be COPYING for GPL and COPYING.LESSER for LGPL.
+
+sc_readme_link_install:
+ @require='INSTALL' \
+ in_vc_files='^README$$' \
+ halt='The README file should refer to INSTALL' \
+ $(_sc_search_regexp)
+
+sc_readme_link_copying:
+ @require='COPYING' \
+ in_vc_files='^README$$' \
+ halt='The README file should refer to COPYING[.LESSER]' \
+ $(_sc_search_regexp)
+
vc-diff-check:
$(AM_V_GEN)(unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || :
$(AM_V_at)if test -s vc-diffs; then \