X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=top%2Fmaint.mk;h=76741adf66c97d41169f81de2f37b65c3d158777;hb=caefbc9f759c39878987f78e7ba0bd5df63b491d;hp=25f4736a3b42eb74cc1919ed32c74e53d7a4b526;hpb=10a2340451a5dc1ff5972183fafd81de246c6931;p=pspp diff --git a/top/maint.mk b/top/maint.mk index 25f4736a3b..76741adf66 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -126,8 +126,13 @@ syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \ $(srcdir)/$(ME) $(_cfg_mk))) .PHONY: $(syntax-check-rules) -local-checks-available = \ - $(syntax-check-rules) +ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0) +local-checks-available += $(syntax-check-rules) +else +local-checks-available += no-vc-detected +no-vc-detected: + @echo "No version control files detected; skipping syntax check" +endif .PHONY: $(local-checks-available) # Arrange to print the name of each syntax-checking rule just before running it. @@ -571,6 +576,13 @@ sc_prohibit_intprops_without_use: re='\<($(_intprops_syms_re)) *\(' \ $(_sc_header_without_use) +_stddef_syms_re = NULL|offsetof|ptrdiff_t|size_t|wchar_t +# Prohibit the inclusion of stddef.h without an actual use. +sc_prohibit_stddef_without_use: + @h='' \ + re='\<($(_stddef_syms_re)) *\(' \ + $(_sc_header_without_use) + sc_obsolete_symbols: @prohibit='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \ halt='do not use HAVE''_FCNTL_H or O'_NDELAY \ @@ -647,7 +659,7 @@ sc_two_space_separator_in_usage: sc_unmarked_diagnostics: @grep -nE \ '\&2; \ exit 1; } || : @@ -766,17 +778,22 @@ sc_prohibit_cvs_keyword: # perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ... # but that would be far less efficient, reading the entire contents # of each file, rather than just the last two bytes of each. +# In addition, while the code below detects both blank lines and a missing +# newline at EOF, the above detects only the former. # # This is a perl script that is expected to be the single-quoted argument # to a command-line "-le". The remaining arguments are file names. -# Print the name of each file that ends in two or more newline bytes. +# Print the name of each file that ends in exactly one newline byte. +# I.e., warn if there are blank lines (2 or more newlines), or if the +# last byte is not a newline. However, currently we don't complain +# about any file that contains exactly one byte. # Exit nonzero if at least one such file is found, otherwise, exit 0. # Warn about, but otherwise ignore open failure. Ignore seek/read failure. # # Use this if you want to remove trailing empty lines from selected files: # perl -pi -0777 -e 's/\n\n+$/\n/' files... # -detect_empty_lines_at_EOF_ = \ +require_exactly_one_NL_at_EOF_ = \ foreach my $$f (@ARGV) \ { \ open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \ @@ -786,12 +803,14 @@ detect_empty_lines_at_EOF_ = \ defined $$p and $$p = sysread F, $$last_two_bytes, 2; \ close F; \ $$c = "ignore read failure"; \ - $$p && $$last_two_bytes eq "\n\n" and (print $$f), $$fail=1; \ + $$p && ($$last_two_bytes eq "\n\n" \ + || substr ($$last_two_bytes,1) ne "\n") \ + and (print $$f), $$fail=1; \ } \ END { exit defined $$fail } sc_prohibit_empty_lines_at_EOF: - @perl -le '$(detect_empty_lines_at_EOF_)' $$($(VC_LIST_EXCEPT)) \ - || { echo '$(ME): the above files end with empty line(s)' \ + @perl -le '$(require_exactly_one_NL_at_EOF_)' $$($(VC_LIST_EXCEPT)) \ + || { echo '$(ME): empty line(s) or no newline at EOF' \ 1>&2; exit 1; } || :; \ # Make sure we don't use st_blocks. Use ST_NBLOCKS instead. @@ -1127,13 +1146,21 @@ submodule-checks ?= no-submodule-changes public-submodule-commit public-submodule-commit: $(AM_V_GEN)if test -d $(srcdir)/.git; then \ cd $(srcdir) && \ - git submodule --quiet foreach 'test $$(git rev-parse origin)' \ - = '"$$(git merge-base --independent origin $$sha1)"' \ + git submodule --quiet foreach test '$$(git rev-parse $$sha1)' \ + = '$$(git merge-base origin $$sha1)' \ || { echo '$(ME): found non-public submodule commit' >&2; \ exit 1; }; \ else \ : ; \ fi +# This rule has a high enough utility/cost ratio that it should be a +# dependent of "check" by default. However, some of us do occasionally +# commit a temporary change that deliberately points to a non-public +# submodule commit, and want to be able to use rules like "make check". +# In that case, run e.g., "make check gl_public_submodule_commit=" +# to disable this test. +gl_public_submodule_commit ?= public-submodule-commit +check: $(gl_public_submodule_commit) .PHONY: alpha beta stable ALL_RECURSIVE_TARGETS += alpha beta stable