diff options
author | Ján Tomko <jtomko@redhat.com> | 2016-07-26 16:28:16 +0200 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2016-08-01 07:43:25 -0700 |
commit | b23fd9d8c3d005650e482a87a67a9654384fa931 (patch) | |
tree | 420dfbc12b950b08a2427a7edc0616b4e8a92d2a /top | |
parent | 04fd8821111d3af23e8485f0f78b60f42babda1d (diff) | |
download | gnulib-b23fd9d8c3d005650e482a87a67a9654384fa931.tar.gz |
maint.mk: speed up require_config_h_first
Instead of spawning three processes per file,
rewrite the check in perl and run it once for all the files.
* top/maint.mk (perl_config_h_first_): Define.
(sc_require_config_h_first): Use it in place of shell code.
Diffstat (limited to 'top')
-rw-r--r-- | top/maint.mk | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/top/maint.mk b/top/maint.mk index c82afbef4e..9ca2bd3b32 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -437,17 +437,26 @@ sc_require_config_h: halt='the above files do not include <config.h>' \ $(_sc_search_regexp) +# Print each file name for which the first #include does not match +# $(config_h_header). Like grep -m 1, this only looks at the first match. +perl_config_h_first_ = \ + -e 'BEGIN {$$ret = 0}' \ + -e 'if (/^\# *include\b/) {' \ + -e ' if (not m{^\# *include $(config_h_header)}) {' \ + -e ' print "$$ARGV\n";' \ + -e ' $$ret = 1;' \ + -e ' }' \ + -e ' \# Move on to next file after first include' \ + -e ' close ARGV;' \ + -e '}' \ + -e 'END {exit $$ret}' + # 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. sc_require_config_h_first: @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \ - fail=0; \ - for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do \ - grep '^# *include\>' $$i | $(SED) 1q \ - | grep -E '^# *include $(config_h_header)' > /dev/null \ - || { echo $$i; fail=1; }; \ - done; \ - test $$fail = 1 && \ + files=$$($(VC_LIST_EXCEPT) | grep '\.c$$') && \ + perl -n $(perl_config_h_first_) $$files || \ { echo '$(ME): the above files include some other header' \ 'before <config.h>' 1>&2; exit 1; } || :; \ else :; \ |