From fb992bae4c490dd00dbe1a55143e98efad87158b Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 26 Dec 2008 15:39:41 +0100 Subject: maint: move coreutils-specific syntax check rules into cfg.mk * maint.mk (sc_dd_max_sym_length, sc_prohibit_jm_in_m4): (sc_root_tests, sc_always_defined_macros, sc_system_h_headers): (sc_sun_os_names, sc_tight_scope, sc_no_exec_perl_coreutils): Move rules into cfg.mk. (sc_strftime_check): Renamed from strftime-check, and moved, too. * cfg.mk: Add the above rules. --- cfg.mk | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) (limited to 'cfg.mk') diff --git a/cfg.mk b/cfg.mk index 7e08026ed..8266afe90 100644 --- a/cfg.mk +++ b/cfg.mk @@ -57,3 +57,138 @@ sc_dd_O_FLAGS: test "$$diff" \ && { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2; \ exit 1; } || : + +# Ensure that dd's definition of LONGEST_SYMBOL stays in sync +# with the strings from the two affected variables. +dd_c = $(srcdir)/src/dd.c +sc_dd_max_sym_length: +ifneq ($(wildcard $(dd_c)),) + @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\ + sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \ + |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \ + | wc --max-line-length); \ + max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \ + |tr -d '"' | wc --max-line-length); \ + if test "$$len" = "$$max"; then :; else \ + echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \ + exit 1; \ + fi +endif + +# Many m4 macros names once began with `jm_'. +# On 2004-04-13, they were all changed to start with gl_ instead. +# Make sure that none are inadvertently reintroduced. +sc_prohibit_jm_in_m4: + @grep -nE 'jm_[A-Z]' \ + $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \ + { echo '$(ME): do not use jm_ in m4 macro names' \ + 1>&2; exit 1; } || : + +# Ensure that each root-requiring test is run via the "check-root" rule. +sc_root_tests: + @if test -d tests \ + && grep check-root tests/Makefile.am>/dev/null 2>&1; then \ + t1=sc-root.expected; t2=sc-root.actual; \ + grep -nl '^require_root_$$' \ + $$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1; \ + sed -n '/^root_tests =[ ]*\\$$/,/[^\]$$/p' \ + $(srcdir)/tests/Makefile.am \ + | sed 's/^ *//;/^root_tests =/d' \ + | tr -s '\012\\' ' ' | fmt -1 | sort > $$t2; \ + diff -u $$t1 $$t2 || diff=1 || diff=; \ + rm -f $$t1 $$t2; \ + test "$$diff" \ + && { echo 'tests/Makefile.am: missing check-root action'>&2; \ + exit 1; } || :; \ + fi + +headers_with_interesting_macro_defs = \ + exit.h \ + fcntl_.h \ + fnmatch_.h \ + intprops.h \ + inttypes_.h \ + lchown.h \ + openat.h \ + stat-macros.h \ + stdint_.h + +# Create a list of regular expressions matching the names +# of macros that are guaranteed by parts of gnulib to be defined. +.re-defmac: + @(cd $(srcdir)/lib; \ + for f in $(headers_with_interesting_macro_defs); do \ + test -f $$f && \ + sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \ + done; \ + ) | sort -u \ + | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \ + | sed 's/^/^# *define /' \ + > $@-t + @mv $@-t $@ + +# Don't define macros that we already get from gnulib header files. +sc_always_defined_macros: .re-defmac + @if test -f $(srcdir)/src/system.h; then \ + trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \ + grep -f .re-defmac $$($(VC_LIST)) \ + && { echo '$(ME): define the above via some gnulib .h file' \ + 1>&2; exit 1; } || :; \ + fi + +# Create a list of regular expressions matching the names +# of files included from system.h. Exclude a couple. +.re-list: + @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \ + | grep -Ev 'sys/(param|file)\.h' \ + | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \ + > $@-t + @mv $@-t $@ + +# Files in src/ should not include directly any of +# the headers already included via system.h. +sc_system_h_headers: .re-list + @if test -f $(srcdir)/src/system.h; then \ + trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \ + grep -nE -f .re-list \ + $$($(VC_LIST) src | \ + grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \ + && { echo '$(ME): the above are already included via system.h'\ + 1>&2; exit 1; } || :; \ + fi + +sc_sun_os_names: + @grep -nEi \ + 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \ + $$($(VC_LIST_EXCEPT)) && \ + { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \ + exit 1; } || : + +sc_tight_scope: + $(MAKE) -C src $@ + +# Perl-based tests used to exec perl from a #!/bin/sh script. +# Now they all start with #!/usr/bin/perl and the portability +# infrastructure is in tests/Makefile.am. Make sure no old-style +# script sneaks back in. +sc_no_exec_perl_coreutils: + @if test -f $(srcdir)/tests/Coreutils.pm; then \ + grep '^exec *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) && \ + { echo 1>&2 '$(ME): found anachronistic Perl-based tests'; \ + exit 1; } || :; \ + fi + +# Ensure that date's --help output stays in sync with the info +# documentation for GNU strftime. The only exception is %N, +# which date accepts but GNU strftime does not. +extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/' +sc_strftime_check: + if test -f $(srcdir)/src/date.c; then \ + grep '^ %. ' $(srcdir)/src/date.c | sort \ + | $(extract_char) > $@-src; \ + { echo N; \ + info libc date calendar format | grep '^ `%.'\' \ + | $(extract_char); } | sort > $@-info; \ + diff -u $@-src $@-info || exit 1; \ + rm -f $@-src $@-info; \ + fi -- cgit v1.2.3-54-g00ecf