From nobody Sun Feb 8 03:33:10 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570549739; cv=none; d=zoho.com; s=zohoarc; b=GzOwEQ/ZaDa2mZoC0mtDn8FcGSo0x8v1n+7b7Kj5OMfSLqahYJZrGIroUAjtDALipF2aTQLRZuO0kp+lzyIdujC76Ou7EpadqDChVmXNgk9nKrYXciLnonNwwozhXzOJ06JLvF+iMfhnI0pfqZuoJ5H/74LO7yonanKkQdSmzCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570549739; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aA410k1kXuXaeUf89di+YEH6B2vc1uJwI7HMOcNG7Dg=; b=A4KtZGeFyJqrY/c7DKhk2+/0aBiYSl+B7aDZiKQg8fpf5rTDVqhaBSD5M0ZQqjrsEUDYMeTdwIaoj60QXM1LJjrgz/GlOVGLNjR6r0Hhu37oVPXkjLoNljBDtaKVGhPCZNtGlDAyZqKKMnMe0a9NsXtLnsegMVdErc2jf1tXZYk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1570549739130151.09971711025594; Tue, 8 Oct 2019 08:48:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 14F5511A2A; Tue, 8 Oct 2019 15:48:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCBE86012C; Tue, 8 Oct 2019 15:48:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5665E4EE69; Tue, 8 Oct 2019 15:48:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x98FmrLC006478 for ; Tue, 8 Oct 2019 11:48:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE4D95C21F; Tue, 8 Oct 2019 15:48:53 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (dhcp-94.gsslab.fab.redhat.com [10.33.9.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AA995C223; Tue, 8 Oct 2019 15:48:52 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 8 Oct 2019 16:48:40 +0100 Message-Id: <20191008154844.29327-2-berrange@redhat.com> In-Reply-To: <20191008154844.29327-1-berrange@redhat.com> References: <20191008154844.29327-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Michal Privoznik Subject: [libvirt] [PATCH v2 1/5] build: import gnulib's syntax-check make rules X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 08 Oct 2019 15:48:57 +0000 (UTC) We're going to be eliminating autotools and gnulib, but we still wish to have the 'make syntax-check' functionality. This imports the minimal set of gnulib files required to keep this working. Signed-off-by: Daniel P. Berrang=C3=A9 --- .gitignore | 9 +- GNUmakefile | 127 +++ Makefile.am | 6 + bootstrap.conf | 4 - build-aux/useless-if-before-free | 226 ++++ build-aux/vc-list-files | 113 ++ cfg.mk | 2 +- configure.ac | 6 + maint.mk | 1756 ++++++++++++++++++++++++++++++ 9 files changed, 2240 insertions(+), 9 deletions(-) create mode 100644 GNUmakefile create mode 100755 build-aux/useless-if-before-free create mode 100755 build-aux/vc-list-files create mode 100644 maint.mk diff --git a/.gitignore b/.gitignore index 82495e8692..42c3cd0790 100644 --- a/.gitignore +++ b/.gitignore @@ -37,12 +37,15 @@ .sc-start-sc_* .ycm_extra_conf.py /AUTHORS -/GNUmakefile /INSTALL /NEWS /aclocal.m4 /autom4te.cache -/build-aux/* +/build-aux/.gitignore +/build-aux/compile +/build-aux/depcomp +/build-aux/missing +/build-aux/test-driver /build/ /ci/scratch/ /confdefs.h @@ -95,7 +98,6 @@ /ltconfig /ltmain.sh /m4/* -/maint.mk /mingw-libvirt.spec /mkinstalldirs /po/*gmo @@ -264,7 +266,6 @@ stamp-h stamp-h.in stamp-h1 tags -!/build-aux/*.pl !/gnulib/lib/Makefile.am !/gnulib/tests/Makefile.am !/m4/virt-*.m4 diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000000..da25113fc3 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,127 @@ +# Having a separate GNUmakefile lets me 'include' the dynamically +# generated rules created via cfg.mk (package-local configuration) +# as well as maint.mk (generic maintainer rules). +# This makefile is used only if you run GNU Make. +# It is necessary if you want to build targets usually of interest +# only to the maintainer. + +# Copyright (C) 2001, 2003, 2006-2019 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# If the user runs GNU make but has not yet run ./configure, +# give them a diagnostic. +_gl-Makefile :=3D $(wildcard [M]akefile) +ifneq ($(_gl-Makefile),) + +# Make tar archive easier to reproduce. +export TAR_OPTIONS =3D --owner=3D0 --group=3D0 --numeric-owner + +# Allow the user to add to this in the Makefile. +ALL_RECURSIVE_TARGETS =3D + +include Makefile + +# Some projects override e.g., _autoreconf here. +-include $(srcdir)/cfg.mk + +# Allow cfg.mk to override these. +_build-aux ?=3D build-aux +_autoreconf ?=3D autoreconf -v + +include $(srcdir)/maint.mk + +# Ensure that $(VERSION) is up to date for dist-related targets, but not +# for others: rerunning autoreconf and recompiling everything isn't cheap. +_have-git-version-gen :=3D \ + $(shell test -f $(srcdir)/$(_build-aux)/git-version-gen && echo yes) +ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL)) + _is-dist-target ?=3D $(filter-out %clean, \ + $(filter maintainer-% dist% alpha beta stable,$(MAKECMDGOALS))) + _is-install-target ?=3D $(filter-out %check, $(filter install%,$(MAKECMD= GOALS))) + ifneq (,$(_is-dist-target)$(_is-install-target)) + _curr-ver :=3D $(shell cd $(srcdir) \ + && $(_build-aux)/git-version-gen \ + .tarball-version \ + $(git-version-gen-tag-sed-script)) + ifneq ($(_curr-ver),$(VERSION)) + ifeq ($(_curr-ver),UNKNOWN) + $(info WARNING: unable to verify if $(VERSION) is the correct vers= ion) + else + ifneq (,$(_is-install-target)) + # GNU Coding Standards state that 'make install' should not cause + # recompilation after 'make all'. But as long as changing the v= ersion + # string alters config.h, the cost of having 'make all' always h= ave an + # up-to-date version is prohibitive. So, as a compromise, we me= rely + # warn when installing a version string that is out of date; the= user + # should run 'autoreconf' (or something like 'make distcheck') to + # fix the version, 'make all' to propagate it, then 'make instal= l'. + $(info WARNING: version string $(VERSION) is out of date;) + $(info run '$(MAKE) _version' to fix it) + else + $(info INFO: running autoreconf for new version string: $(_curr-= ver)) +GNUmakefile: _version + touch GNUmakefile + endif + endif + endif + endif +endif + +.PHONY: _version +_version: + cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf) + $(MAKE) $(AM_MAKEFLAGS) Makefile + +else + +.DEFAULT_GOAL :=3D abort-due-to-no-makefile +srcdir =3D . + +# The package can override .DEFAULT_GOAL to run actions like autoreconf. +-include ./cfg.mk + +# Allow cfg.mk to override these. +_build-aux ?=3D build-aux +_autoreconf ?=3D autoreconf -v + +include ./maint.mk + +ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile) +$(MAKECMDGOALS): abort-due-to-no-makefile +endif + +abort-due-to-no-makefile: + @echo There seems to be no Makefile in this directory. 1>&2 + @echo "You must run ./configure before running 'make'." 1>&2 + @exit 1 + +endif + +# Tell version 3.79 and up of GNU make to not build goals in this +# directory in parallel, in case someone tries to build multiple +# targets, and one of them can cause a recursive target to be invoked. + +# Only set this if Automake doesn't provide it. +AM_RECURSIVE_TARGETS ?=3D $(RECURSIVE_TARGETS:-recursive=3D) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=3D) \ + dist distcheck tags ctags + +ALL_RECURSIVE_TARGETS +=3D $(AM_RECURSIVE_TARGETS) + +ifneq ($(word 2, $(MAKECMDGOALS)), ) +ifneq ($(filter $(ALL_RECURSIVE_TARGETS), $(MAKECMDGOALS)), ) +.NOTPARALLEL: +endif +endif diff --git a/Makefile.am b/Makefile.am index 1a9f3af66d..c91e7c55a5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,6 +42,8 @@ EXTRA_DIST =3D \ Makefile.nonreentrant \ autogen.sh \ cfg.mk \ + GNUmakefile \ + maint.mk \ run.in \ README.md \ AUTHORS.in \ @@ -108,6 +110,10 @@ clean-cov: =20 MAINTAINERCLEANFILES =3D .git-module-status =20 +distclean-local: clean-GNUmakefile +clean-GNUmakefile: + test '$(srcdir)' =3D . || rm -f $(top_builddir)/GNUmakefile + dist-hook: gen-AUTHORS =20 .PHONY: gen-AUTHORS diff --git a/bootstrap.conf b/bootstrap.conf index e40170a77b..358d783a6b 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -49,13 +49,11 @@ getpass getpeername getsockname gettimeofday -gnumakefile intprops ioctl largefile listen localeconv -maintainer-makefile manywarnings mgetgroups mkdtemp @@ -98,11 +96,9 @@ timegm ttyname_r uname unsetenv -useless-if-before-free usleep vasprintf verify -vc-list-files vsnprintf waitpid warnings diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before= -free new file mode 100755 index 0000000000..6ac8aa9196 --- /dev/null +++ b/build-aux/useless-if-before-free @@ -0,0 +1,226 @@ +#!/bin/sh +#! -*-perl-*- + +# Detect instances of "if (p) free (p);". +# Likewise "if (p !=3D 0)", "if (0 !=3D p)", or with NULL; and with braces. + +# Copyright (C) 2008-2019 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Written by Jim Meyering + +# This is a prologue that allows to run a perl script as an executable +# on systems that are compliant to a POSIX version before POSIX:2017. +# On such systems, the usual invocation of an executable through execlp() +# or execvp() fails with ENOEXEC if it is a script that does not start +# with a #! line. The script interpreter mentioned in the #! line has +# to be /bin/sh, because on GuixSD systems that is the only program that +# has a fixed file name. The second line is essential for perl and is +# also useful for editing this file in Emacs. The next two lines below +# are valid code in both sh and perl. When executed by sh, they re-execute +# the script through the perl program found in $PATH. The '-x' option +# is essential as well; without it, perl would re-execute the script +# through /bin/sh. When executed by perl, the next two lines are a no-op. +eval 'exec perl -wSx "$0" "$@"' + if 0; + +my $VERSION =3D '2018-03-07 03:47'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +use strict; +use warnings; +use Getopt::Long; + +(my $ME =3D $0) =3D~ s|.*/||; + +# use File::Coda; # https://meyering.net/code/Coda/ +END { + defined fileno STDOUT or return; + close STDOUT and return; + warn "$ME: failed to close standard output: $!\n"; + $? ||=3D 1; +} + +sub usage ($) +{ + my ($exit_code) =3D @_; + my $STREAM =3D ($exit_code =3D=3D 0 ? *STDOUT : *STDERR); + if ($exit_code !=3D 0) + { + print $STREAM "Try '$ME --help' for more information.\n"; + } + else + { + print $STREAM < sub { usage 0 }, + version =3D> sub { print "$ME version $VERSION\n"; exit }, + list =3D> \$list, + 'name=3Ds@' =3D> \@name, + ) or usage 1; + + # Make sure we have the right number of non-option arguments. + # Always tell the user why we fail. + @ARGV < 1 + and (warn "$ME: missing FILE argument\n"), usage EXIT_ERROR; + + my $or =3D join '|', @name; + my $regexp =3D qr/(?:$or)/; + + # Set the input record separator. + # Note: this makes it impractical to print line numbers. + $/ =3D '"'; + + my $found_match =3D 0; + FILE: + foreach my $file (@ARGV) + { + open FH, '<', $file + or (warn "$ME: can't open '$file' for reading: $!\n"), + $err =3D EXIT_ERROR, next; + while (defined (my $line =3D )) + { + # Skip non-matching lines early to save time + $line =3D~ /\bif\b/ + or next; + while ($line =3D~ + /\b(if\s*\(\s*([^)]+?)(?:\s*!=3D\s*([^)]+?))?\s*\) + # 1 2 3 + (?: \s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;| + \s*\{\s*$regexp\s*\((?:\s*\([^)]+\))?\s*([^)]+)\)\s*;\s*\}= ))/sxg) + { + my $all =3D $1; + my ($lhs, $rhs) =3D ($2, $3); + my ($free_opnd, $braced_free_opnd) =3D ($4, $5); + my $non_NULL; + if (!defined $rhs) { $non_NULL =3D $lhs } + elsif (is_NULL $rhs) { $non_NULL =3D $lhs } + elsif (is_NULL $lhs) { $non_NULL =3D $rhs } + else { next } + + # Compare the non-NULL part of the "if" expression and the + # free'd expression, without regard to white space. + $non_NULL =3D~ tr/ \t//d; + my $e2 =3D defined $free_opnd ? $free_opnd : $braced_free_op= nd; + $e2 =3D~ tr/ \t//d; + if ($non_NULL eq $e2) + { + $found_match =3D 1; + $list + and (print "$file\0"), next FILE; + print "$file: $all\n"; + } + } + } + } + continue + { + close FH; + } + + $found_match && $err =3D=3D EXIT_NO_MATCH + and $err =3D EXIT_MATCH; + + exit $err; +} + +my $foo =3D <<'EOF'; +# The above is to *find* them. +# This adjusts them, removing the unnecessary "if (p)" part. + +# FIXME: do something like this as an option (doesn't do braces): +free=3Dxfree +git grep -l -z "$free *(" \ + | xargs -0 useless-if-before-free -l --name=3D"$free" \ + | xargs -0 perl -0x3b -pi -e \ + 's/\bif\s*\(\s*(\S+?)(?:\s*!=3D\s*(?:0|NULL))?\s*\)\s+('"$free"'\s*\((?= :\s*\([^)]+\))?\s*\1\s*\)\s*;)/$2/s' + +# Use the following to remove redundant uses of kfree inside braces. +# Note that -0777 puts perl in slurp-whole-file mode; +# but we have plenty of memory, these days... +free=3Dkfree +git grep -l -z "$free *(" \ + | xargs -0 useless-if-before-free -l --name=3D"$free" \ + | xargs -0 perl -0777 -pi -e \ + 's/\bif\s*\(\s*(\S+?)(?:\s*!=3D\s*(?:0|NULL))?\s*\)\s*\{\s*('"$free"'= \s*\((?:\s*\([^)]+\))?\s*\1\s*\);)\s*\}[^\n]*$/$2/gms' + +Be careful that the result of the above transformation is valid. +If the matched string is followed by "else", then obviously, it won't be. + +When modifying files, refuse to process anything other than a regular file. +EOF + +## Local Variables: +## mode: perl +## indent-tabs-mode: nil +## eval: (add-hook 'before-save-hook 'time-stamp) +## time-stamp-line-limit: 50 +## time-stamp-start: "my $VERSION =3D '" +## time-stamp-format: "%:y-%02m-%02d %02H:%02M" +## time-stamp-time-zone: "UTC0" +## time-stamp-end: "'; # UTC" +## End: diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files new file mode 100755 index 0000000000..af6b1c0f8a --- /dev/null +++ b/build-aux/vc-list-files @@ -0,0 +1,113 @@ +#!/bin/sh +# List version-controlled file names. + +# Print a version string. +scriptversion=3D2018-03-07.03; # UTC + +# Copyright (C) 2006-2019 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# List the specified version-controlled files. +# With no argument, list them all. With a single DIRECTORY argument, +# list the version-controlled files in that directory. + +# If there's an argument, it must be a single, "."-relative directory name. +# cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/ + +postprocess=3D +case $1 in + --help) cat <. +EOF + exit ;; + + --version) + year=3D`echo "$scriptversion" | sed 's/[^0-9].*//'` + cat < +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. +EOF + exit ;; + + -C) + test "$2" =3D . || postprocess=3D"| sed 's|^|$2/|'" + cd "$2" || exit 1 + shift; shift ;; +esac + +test $# =3D 0 && set . + +for dir +do + if test -d .git || test -f .git; then + test "x$dir" =3D x. \ + && dir=3D sed_esc=3D \ + || { dir=3D"$dir/"; sed_esc=3D`echo "$dir"|env sed 's,\([\\/]\),\\\\= \1,g'`; } + # Ignore git symlinks - either they point into the tree, in which case + # we don't need to visit the target twice, or they point somewhere + # else (often into a submodule), in which case the content does not + # belong to this package. + eval exec git ls-tree -r 'HEAD:"$dir"' \ + \| sed -n '"s/^100[^ ]*./$sed_esc/p"' $postprocess + elif test -d .hg; then + eval exec hg locate '"$dir/*"' $postprocess + elif test -d .bzr; then + test "$postprocess" =3D '' && postprocess=3D"| sed 's|^\./||'" + eval exec bzr ls -R --versioned '"$dir"' $postprocess + elif test -d CVS; then + test "$postprocess" =3D '' && postprocess=3D"| sed 's|^\./||'" + if test -x build-aux/cvsu; then + eval build-aux/cvsu --find --types=3DAFGM '"$dir"' $postprocess + elif (cvsu --help) >/dev/null 2>&1; then + eval cvsu --find --types=3DAFGM '"$dir"' $postprocess + else + eval awk -F/ \''{ \ + if (!$1 && $3 !~ /^-/) { \ + f=3DFILENAME; \ + if (f ~ /CVS\/Entries$/) \ + f =3D substr(f, 1, length(f)-11); \ + print f $2; \ + }}'\'' \ + `find "$dir" -name Entries -print` /dev/null' $postprocess + fi + elif test -d .svn; then + eval exec svn list -R '"$dir"' $postprocess + else + echo "$0: Failed to determine type of version control used in `pwd`" 1= >&2 + exit 1 + fi +done + +# Local variables: +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=3D" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/cfg.mk b/cfg.mk index 3eae469165..2224d4da25 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1209,7 +1209,7 @@ exclude_file_name_regexp--sc_copyright_format =3D \ ^cfg\.mk$$ =20 exclude_file_name_regexp--sc_copyright_usage =3D \ - ^COPYING(|\.LESSER)$$ + ^(COPYING(|\.LESSER))|maint\.mk$$ =20 exclude_file_name_regexp--sc_flags_usage =3D \ ^(cfg\.mk|docs/|src/util/virnetdevtap\.c$$|tests/((vir(cgroup|pci|test|u= sb)|nss|qemuxml2argv|qemusecurity)mock|virfilewrapper)\.c$$) diff --git a/configure.ac b/configure.ac index 40e93e251e..f6bf4fb60a 100644 --- a/configure.ac +++ b/configure.ac @@ -915,6 +915,12 @@ AC_DEFINE_UNQUOTED([isbase64],[libvirt_gl_isbase64],[H= ack to avoid symbol clash] AC_DEFINE_UNQUOTED([base64_encode],[libvirt_gl_base64_encode],[Hack to avo= id symbol clash]) AC_DEFINE_UNQUOTED([base64_encode_alloc],[libvirt_gl_base64_encode_alloc],= [Hack to avoid symbol clash]) =20 +GNUmakefile=3DGNUmakefile +m4_if(m4_version_compare([2.61a.100], + m4_defn([m4_PACKAGE_VERSION])), [1], [], + [AC_CONFIG_LINKS([$GNUmakefile:$GNUmakefile], [], + [GNUmakefile=3D$GNUmakefile])]) + AC_CONFIG_FILES([run], [chmod +x,-w run]) AC_CONFIG_FILES([\ diff --git a/maint.mk b/maint.mk new file mode 100644 index 0000000000..16e936022c --- /dev/null +++ b/maint.mk @@ -0,0 +1,1756 @@ +# -*-Makefile-*- +# This Makefile fragment tries to be general-purpose enough to be +# used by many projects via the gnulib maintainer-makefile module. + +## Copyright (C) 2001-2019 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 +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . + +# This is reported not to work with make-3.79.1 +# ME :=3D $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) +ME :=3D maint.mk + +# These variables ought to be defined through the configure.ac section +# of the module description. But some packages import this file directly, +# ignoring the module description. +AWK ?=3D awk +GREP ?=3D grep +SED ?=3D sed + +# Helper variables. +_empty =3D +_sp =3D $(_empty) $(_empty) + +# _equal,S1,S2 +# ------------ +# If S1 =3D=3D S2, return S1, otherwise the empty string. +_equal =3D $(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) + +# member-check,VARIABLE,VALID-VALUES +# ---------------------------------- +# Check that $(VARIABLE) is in the space-separated list of VALID-VALUES, a= nd +# return it. Die otherwise. +member-check =3D \ + $(strip \ + $(if $($(1)), \ + $(if $(findstring $(_sp),$($(1))), \ + $(error invalid $(1): '$($(1))', expected $(2)), \ + $(or $(findstring $(_sp)$($(1))$(_sp),$(_sp)$(2)$(_sp)), \ + $(error invalid $(1): '$($(1))', expected $(2)))), \ + $(error $(1) undefined))) + +# Do not save the original name or timestamp in the .tar.gz file. +# Use --rsyncable if available. +gzip_rsyncable :=3D \ + $(shell gzip --help 2>/dev/null|$(GREP) rsyncable >/dev/null \ + && printf %s --rsyncable) +GZIP_ENV =3D '--no-name --best $(gzip_rsyncable)' + +GIT =3D git +VC =3D $(GIT) + +VC_LIST =3D $(srcdir)/$(_build-aux)/vc-list-files -C $(srcdir) + +# You can override this variable in cfg.mk if your gnulib submodule lives +# in a different location. +gnulib_dir ?=3D $(srcdir)/gnulib + +# You can override this variable in cfg.mk to set your own regexp +# matching files to ignore. +VC_LIST_ALWAYS_EXCLUDE_REGEX ?=3D ^$$ + +# This is to preprocess robustly the output of $(VC_LIST), so that even +# when $(srcdir) is a pathological name like "....", the leading sed comma= nd +# removes only the intended prefix. +_dot_escaped_srcdir =3D $(subst .,\.,$(srcdir)) + +# Post-process $(VC_LIST) output, prepending $(srcdir)/, but only +# when $(srcdir) is not ".". +ifeq ($(srcdir),.) + _prepend_srcdir_prefix =3D +else + _prepend_srcdir_prefix =3D | $(SED) 's|^|$(srcdir)/|' +endif + +# In order to be able to consistently filter "."-relative names, +# (i.e., with no $(srcdir) prefix), this definition is careful to +# remove any $(srcdir) prefix, and to restore what it removes. +_sc_excl =3D \ + $(or $(exclude_file_name_regexp--$@),^$$) +VC_LIST_EXCEPT =3D \ + $(VC_LIST) | $(SED) 's|^$(_dot_escaped_srcdir)/||' \ + | if test -f $(srcdir)/.x-$@; then $(GREP) -vEf $(srcdir)/.x-$@; \ + else $(GREP) -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \ + | $(GREP) -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \ + $(_prepend_srcdir_prefix) + +ifeq ($(origin prev_version_file), undefined) + prev_version_file =3D $(srcdir)/.prev-version +endif + +PREV_VERSION :=3D $(shell cat $(prev_version_file) 2>/dev/null) +VERSION_REGEXP =3D $(subst .,\.,$(VERSION)) +PREV_VERSION_REGEXP =3D $(subst .,\.,$(PREV_VERSION)) + +ifeq ($(VC),$(GIT)) + this-vc-tag =3D v$(VERSION) + this-vc-tag-regexp =3D v$(VERSION_REGEXP) +else + tag-package =3D $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]') + tag-this-version =3D $(subst .,_,$(VERSION)) + this-vc-tag =3D $(tag-package)-$(tag-this-version) + this-vc-tag-regexp =3D $(this-vc-tag) +endif +my_distdir =3D $(PACKAGE)-$(VERSION) + +# Old releases are stored here. +release_archive_dir ?=3D ../release + +# If RELEASE_TYPE is undefined, but RELEASE is, use its second word. +# But overwrite VERSION. +ifdef RELEASE + VERSION :=3D $(word 1, $(RELEASE)) + RELEASE_TYPE ?=3D $(word 2, $(RELEASE)) +endif + +# Validate and return $(RELEASE_TYPE), or die. +RELEASE_TYPES =3D alpha beta stable +release-type =3D $(call member-check,RELEASE_TYPE,$(RELEASE_TYPES)) + +# Override gnu_rel_host and url_dir_list in cfg.mk if these are not right. +# Use alpha.gnu.org for alpha and beta releases. +# Use ftp.gnu.org for stable releases. +gnu_ftp_host-alpha =3D alpha.gnu.org +gnu_ftp_host-beta =3D alpha.gnu.org +gnu_ftp_host-stable =3D ftp.gnu.org +gnu_rel_host ?=3D $(gnu_ftp_host-$(release-type)) + +url_dir_list ?=3D $(if $(call _equal,$(gnu_rel_host),ftp.gnu.org), \ + https://ftpmirror.gnu.org/$(PACKAGE), \ + https://$(gnu_rel_host)/gnu/$(PACKAGE)) + +# Override this in cfg.mk if you are using a different format in your +# NEWS file. +today =3D $(shell date +%Y-%m-%d) + +# Select which lines of NEWS are searched for $(news-check-regexp). +# This is a sed line number spec. The default says that we search +# lines 1..10 of NEWS for $(news-check-regexp). +# If you want to search only line 3 or only lines 20-22, use "3" or "20,22= ". +news-check-lines-spec ?=3D 1,10 +news-check-regexp ?=3D '^\*.* $(VERSION_REGEXP) \($(today)\)' + +# Prevent programs like 'sort' from considering distinct strings to be equ= al. +# Doing it here saves us from having to set LC_ALL elsewhere in this file. +export LC_ALL =3D C + +## --------------- ## +## Sanity checks. ## +## --------------- ## + +ifneq ($(_gl-Makefile),) +_cfg_mk :=3D $(wildcard $(srcdir)/cfg.mk) + +# Collect the names of rules starting with 'sc_'. +syntax-check-rules :=3D $(sort $(shell $(SED) -n \ + 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(srcdir)/$(ME) $(_cfg_mk))) +.PHONY: $(syntax-check-rules) + +ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0) + local-checks-available +=3D $(syntax-check-rules) +else + local-checks-available +=3D 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 runni= ng it. +$(syntax-check-rules): %: %.m +sc_m_rules_ =3D $(patsubst %, %.m, $(syntax-check-rules)) +.PHONY: $(sc_m_rules_) +$(sc_m_rules_): + @echo $(patsubst sc_%.m, %, $@) + @date +%s.%N > .sc-start-$(basename $@) + +# Compute and print the elapsed time for each syntax-check rule. +sc_z_rules_ =3D $(patsubst %, %.z, $(syntax-check-rules)) +.PHONY: $(sc_z_rules_) +$(sc_z_rules_): %.z: % + @end=3D$$(date +%s.%N); \ + start=3D$$(cat .sc-start-$*); \ + rm -f .sc-start-$*; \ + $(AWK) -v s=3D$$start -v e=3D$$end \ + 'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev/null + +# The patsubst here is to replace each sc_% rule with its sc_%.z wrapper +# that computes and prints elapsed time. +local-check :=3D \ + $(patsubst sc_%, sc_%.z, \ + $(filter-out $(local-checks-to-skip), $(local-checks-available))) + +syntax-check: $(local-check) +endif + +# _sc_search_regexp +# +# This macro searches for a given construct in the selected files and +# then takes some action. +# +# Parameters (shell variables): +# +# prohibit | require +# +# Regular expression (ERE) denoting either a forbidden construct +# or a required construct. Those arguments are exclusive. +# +# exclude +# +# Regular expression (ERE) denoting lines to ignore that matched +# a prohibit construct. For example, this can be used to exclude +# comments that mention why the nearby code uses an alternative +# construct instead of the simpler prohibited construct. +# +# in_vc_files | in_files +# +# grep-E-style regexp selecting the files to check. For in_vc_files, +# the regexp is used to select matching files from the list of all +# version-controlled files; for in_files, it's from the names printed +# by "find $(srcdir)". When neither is specified, use all files that +# are under version control. +# +# containing | non_containing +# +# Select the files (non) containing strings matching this regexp. +# If both arguments are specified then CONTAINING takes +# precedence. +# +# with_grep_options +# +# Extra options for grep. +# +# ignore_case +# +# Ignore case. +# +# halt +# +# Message to display before to halting execution. +# +# Finally, you may exempt files based on an ERE matching file names. +# For example, to exempt from the sc_space_tab check all files with the +# .diff suffix, set this Make variable: +# +# exclude_file_name_regexp--sc_space_tab =3D \.diff$ +# +# Note that while this functionality is mostly inherited via VC_LIST_EXCEP= T, +# when filtering by name via in_files, we explicitly filter out matching +# names here as well. + +# Initialize each, so that envvar settings cannot interfere. +export require =3D +export prohibit =3D +export exclude =3D +export in_vc_files =3D +export in_files =3D +export containing =3D +export non_containing =3D +export halt =3D +export with_grep_options =3D + +# By default, _sc_search_regexp does not ignore case. +export ignore_case =3D +_ignore_case =3D $$(test -n "$$ignore_case" && printf %s -i || :) + +define _sc_say_and_exit + dummy=3D; : so we do not need a semicolon before each use; \ + { printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; }; +endef + +define _sc_search_regexp + dummy=3D; : so we do not need a semicolon before each use; \ + \ + : Check arguments; \ + test -n "$$prohibit" && test -n "$$require" \ + && { msg=3D'Cannot specify both prohibit and require' \ + $(_sc_say_and_exit) } || :; \ + test -z "$$prohibit" && test -z "$$require" \ + && { msg=3D'Should specify either prohibit or require' \ + $(_sc_say_and_exit) } || :; \ + test -z "$$prohibit" && test -n "$$exclude" \ + && { msg=3D'Use of exclude requires a prohibit pattern' \ + $(_sc_say_and_exit) } || :; \ + test -n "$$in_vc_files" && test -n "$$in_files" \ + && { msg=3D'Cannot specify both in_vc_files and in_files' \ + $(_sc_say_and_exit) } || :; \ + test "x$$halt" !=3D x \ + || { msg=3D'halt not defined' $(_sc_say_and_exit) }; \ + \ + : Filter by file name; \ + if test -n "$$in_files"; then \ + files=3D$$(find $(srcdir) | $(GREP) -E "$$in_files" \ + | $(GREP) -Ev '$(_sc_excl)'); \ + else \ + files=3D$$($(VC_LIST_EXCEPT)); \ + if test -n "$$in_vc_files"; then \ + files=3D$$(echo "$$files" | $(GREP) -E "$$in_vc_files"); \ + fi; \ + fi; \ + \ + : Filter by content; \ + test -n "$$files" \ + && test -n "$$containing" \ + && { files=3D$$(echo "$$files" | xargs $(GREP) -l "$$containing"); } \ + || :; \ + test -n "$$files" \ + && test -n "$$non_containing" \ + && { files=3D$$(echo "$$files" | xargs $(GREP) -vl "$$non_containing"= ); } \ + || :; \ + \ + : Check for the construct; \ + if test -n "$$files"; then \ + if test -n "$$prohibit"; then \ + echo "$$files" \ + | xargs $(GREP) $$with_grep_options $(_ignore_case) -nE \ + "$$prohibit" /dev/null \ + | $(GREP) -vE "$${exclude:-^$$}" \ + && { msg=3D"$$halt" $(_sc_say_and_exit) } \ + || :; \ + else \ + echo "$$files" \ + | xargs \ + $(GREP) $$with_grep_options $(_ignore_case) -LE "$$require" \ + | $(GREP) . \ + && { msg=3D"$$halt" $(_sc_say_and_exit) } \ + || :; \ + fi \ + else :; \ + fi || :; +endef + +sc_avoid_if_before_free: + @$(VC_LIST_EXCEPT) \ + | $(GREP) -v useless-if-before-free \ + | xargs \ + $(srcdir)/$(_build-aux)/useless-if-before-free \ + $(useless_free_options) \ + && { printf '$(ME): found useless "if"' \ + ' before "free" above\n' 1>&2; \ + exit 1; } \ + || : + +sc_cast_of_argument_to_free: + @prohibit=3D'\' \ + halt=3D"don't cast x*alloc return value" \ + $(_sc_search_regexp) + +sc_cast_of_alloca_return_value: + @prohibit=3D'\*\) *alloca\>' \ + halt=3D"don't cast alloca return value" \ + $(_sc_search_regexp) + +sc_space_tab: + @prohibit=3D'[ ] ' \ + halt=3D'found SPACE-TAB sequence; remove the SPACE' \ + $(_sc_search_regexp) + +# Don't use *scanf or the old ato* functions in "real" code. +# They provide no error checking mechanism. +# Instead, use strto* functions. +sc_prohibit_atoi_atof: + @prohibit=3D'\<([fs]?scanf|ato([filq]|ll)) *\(' \ + halt=3D'do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \ + $(_sc_search_regexp) + +# Use STREQ rather than comparing strcmp =3D=3D 0, or !=3D 0. +sp_ =3D strcmp *\(.+\) +sc_prohibit_strcmp: + @prohibit=3D'! *strcmp *\(|\<$(sp_) *[!=3D]=3D|[!=3D]=3D *$(sp_)' \ + exclude=3D'# *define STRN?EQ\(' \ + halt=3D'replace strcmp calls above with STREQ/STRNEQ' \ + $(_sc_search_regexp) + +# Really. You don't want to use this function. +# It may fail to NUL-terminate the destination, +# and always NUL-pads out to the specified length. +sc_prohibit_strncpy: + @prohibit=3D'\/dev/null 2>&1; then \ + (cd $(srcdir) && autoconf --trace AC_CONFIG_FILES:'$$1') | \ + tr ' ' '\n' | \ + $(SED) -ne '/Makefile/{s/\.in$$//;p;}' | \ + while read m; do \ + $(MAKE) -qp -f $$m .DUMMY-TARGET 2>/dev/null | \ + $(AWK) -v file=3D$$m -e '$($@_awk_)' || exit 1; \ + done; \ + fi + +# Using EXIT_SUCCESS as the first argument to error is misleading, +# since when that parameter is 0, error does not exit. Use '0' instead. +sc_error_exit_success: + @prohibit=3D'error *\(EXIT_SUCCESS,' \ + in_vc_files=3D'\.[chly]$$' \ + halt=3D'found error (EXIT_SUCCESS' \ + $(_sc_search_regexp) + +# "FATAL:" should be fully upper-cased in error messages +# "WARNING:" should be fully upper-cased, or fully lower-cased +sc_error_message_warn_fatal: + @$(VC_LIST_EXCEPT) \ + | xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ + | $(GREP) -E '"Warning|"Fatal|"fatal' \ + && { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \ + exit 1; } \ + || : + +# Error messages should not start with a capital letter +sc_error_message_uppercase: + @$(VC_LIST_EXCEPT) \ + | xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ + | $(GREP) -E '"[A-Z]' \ + | $(GREP) -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' \ + && { echo '$(ME): found capitalized error message' 1>&2; \ + exit 1; } \ + || : + +# Error messages should not end with a period +sc_error_message_period: + @$(VC_LIST_EXCEPT) \ + | xargs $(GREP) -nEA2 '[^rp]error *\(' /dev/null \ + | $(GREP) -E '[^."]\."' \ + && { echo '$(ME): found error message ending in period' 1>&2; \ + exit 1; } \ + || : + +sc_file_system: + @prohibit=3Dfile''system \ + exclude=3D'/proc/filesystems' \ + ignore_case=3D1 \ + halt=3D'found use of "file''system"; spell it "file system"' \ + $(_sc_search_regexp) + +# Don't use cpp tests of this symbol. All code assumes config.h is includ= ed. +sc_prohibit_have_config_h: + @prohibit=3D'^# *if.*HAVE''_CONFIG_H' \ + halt=3D'found use of HAVE''_CONFIG_H; remove' \ + $(_sc_search_regexp) + +# Nearly all .c files must include . However, we also permit th= is +# via inclusion of a package-specific header, if cfg.mk specified one. +# config_h_header must be suitable for grep -E. +config_h_header ?=3D +sc_require_config_h: + @require=3D'^# *include $(config_h_header)' \ + in_vc_files=3D'\.c$$' \ + halt=3D'the above files do not include ' \ + $(_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_ =3D \ + -e 'BEGIN {$$ret =3D 0}' \ + -e 'if (/^\# *include\b/) {' \ + -e ' if (not m{^\# *include $(config_h_header)}) {' \ + -e ' print "$$ARGV\n";' \ + -e ' $$ret =3D 1;' \ + -e ' }' \ + -e ' \# Move on to next file after first include' \ + -e ' close ARGV;' \ + -e '}' \ + -e 'END {exit $$ret}' + +# You must include 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 \ + files=3D$$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$') && \ + perl -n $(perl_config_h_first_) $$files || \ + { echo '$(ME): the above files include some other header' \ + 'before ' 1>&2; exit 1; } || :; \ + else :; \ + fi + +sc_prohibit_HAVE_MBRTOWC: + @prohibit=3D'\bHAVE_MBRTOWC\b' \ + halt=3D"do not use $$prohibit; it is always defined" \ + $(_sc_search_regexp) + +# To use this "command" macro, you must first define two shell variables: +# h: the header name, with no enclosing <> or "" +# re: a regular expression that matches IFF something provided by $h is us= ed. +define _sc_header_without_use + dummy=3D; : so we do not need a semicolon before each use; \ + h_esc=3D`echo '[<"]'"$$h"'[">]'|$(SED) 's/\./\\\\./g'`; \ + if $(VC_LIST_EXCEPT) | $(GREP) '\.c$$' > /dev/null; then \ + files=3D$$($(GREP) -l '^# *include '"$$h_esc" \ + $$($(VC_LIST_EXCEPT) | $(GREP) '\.c$$')) && \ + $(GREP) -LE "$$re" $$files | $(GREP) . && \ + { echo "$(ME): the above files include $$h but don't use it" \ + 1>&2; exit 1; } || :; \ + else :; \ + fi +endef + +# Prohibit the inclusion of assert.h without an actual use of assert. +sc_prohibit_assert_without_use: + @h=3D'assert.h' re=3D'\)' \ + $(_sc_header_without_use) + +# Don't include this header unless you use one of its functions. +sc_prohibit_long_options_without_use: + @h=3D'long-options.h' re=3D'\new(file =3D> "/dev/stdin")->as_string'|sed 's= /\?://g' +# Note this was produced by the above: +# _xa1 =3D \ +#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)du= p) +# 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more read= able +# "char|[cmz]" +# x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup) +_xa1 =3D x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|s= tr)dup) +_xa2 =3D X([CZ]|N?M)ALLOC +sc_prohibit_xalloc_without_use: + @h=3D'xalloc.h' \ + re=3D'\<($(_xa1)|$(_xa2)) *\('\ + $(_sc_header_without_use) + +# Extract function names: +# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/h= ash.h +_hash_re =3D \ +clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tu= ning +_hash_fn =3D \<($(_hash_re)) *\( +_hash_struct =3D (struct )?\<[Hh]ash_(table|tuning)\> +sc_prohibit_hash_without_use: + @h=3D'hash.h' \ + re=3D'$(_hash_fn)|$(_hash_struct)'\ + $(_sc_header_without_use) + +sc_prohibit_cloexec_without_use: + @h=3D'cloexec.h' re=3D'\<(set_cloexec_flag|dup_cloexec) *\(' \ + $(_sc_header_without_use) + +sc_prohibit_posixver_without_use: + @h=3D'posixver.h' re=3D'\' \ + $(_sc_header_without_use) + +sc_prohibit_safe_read_without_use: + @h=3D'safe-read.h' re=3D'(\|\|\<(inval= id_arg|argmatch(_exit_fn|_(in)?valid)?) *\()' \ + $(_sc_header_without_use) + +sc_prohibit_canonicalize_without_use: + @h=3D'canonicalize.h' \ + re=3D'CAN_(EXISTING|ALL_BUT_LAST|MISSING)|canonicalize_(mode_t|filename_m= ode|file_name)' \ + $(_sc_header_without_use) + +sc_prohibit_root_dev_ino_without_use: + @h=3D'root-dev-ino.h' \ + re=3D'(\|\' \ + $(_sc_header_without_use) + +# Prohibit the inclusion of c-ctype.h without an actual use. +ctype_re =3D isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islow= er\ +|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper +sc_prohibit_c_ctype_without_use: + @h=3D'c-ctype.h' re=3D'\' \ + $(_sc_header_without_use) + +# Don't include stdio--.h unless you use one of its functions. +sc_prohibit_stdio--_without_use: + @h=3D'stdio--.h' re=3D'\<((f(re)?|p)open|tmpfile) *\(' \ + $(_sc_header_without_use) + +# Don't include stdio-safer.h unless you use one of its functions. +sc_prohibit_stdio-safer_without_use: + @h=3D'stdio-safer.h' re=3D'\<((f(re)?|p)open|tmpfile)_safer *\(' \ + $(_sc_header_without_use) + +# Prohibit the inclusion of strings.h without a sensible use. +# Using the likes of bcmp, bcopy, bzero, index or rindex is not sensible. +sc_prohibit_strings_without_use: + @h=3D'strings.h' \ + re=3D'\<(strn?casecmp|ffs(ll)?)\>' \ + $(_sc_header_without_use) + +# Extract the raw list of symbol names with this: +gl_extract_define_simple =3D \ + /^\# *define ([A-Z]\w+)\(/ and print $$1 +# Filter out duplicates and convert to a space-separated list: +_intprops_names =3D \ + $(shell f=3D$(gnulib_dir)/lib/intprops.h; \ + perl -lne '$(gl_extract_define_simple)' $$f | sort -u | tr '\n' ' ') +# Remove trailing space and convert to a regular expression: +_intprops_syms_re =3D $(subst $(_sp),|,$(strip $(_intprops_names))) +# Prohibit the inclusion of intprops.h without an actual use. +sc_prohibit_intprops_without_use: + @h=3D'intprops.h' \ + re=3D'\<($(_intprops_syms_re)) *\(' \ + $(_sc_header_without_use) + +_stddef_syms_re =3D NULL|offsetof|ptrdiff_t|size_t|wchar_t +# Prohibit the inclusion of stddef.h without an actual use. +sc_prohibit_stddef_without_use: + @h=3D'stddef.h' \ + re=3D'\<($(_stddef_syms_re))\>' \ + $(_sc_header_without_use) + +_de1 =3D dirfd|(close|(fd)?open|read|rewind|seek|tell)dir(64)?(_r)? +_de2 =3D (versionsort|struct dirent|getdirentries|alphasort|scandir(at)?)(= 64)? +_de3 =3D MAXNAMLEN|DIR|ino_t|d_ino|d_fileno|d_namlen +_dirent_syms_re =3D $(_de1)|$(_de2)|$(_de3) +# Prohibit the inclusion of dirent.h without an actual use. +sc_prohibit_dirent_without_use: + @h=3D'dirent.h' \ + re=3D'\<($(_dirent_syms_re))\>' \ + $(_sc_header_without_use) + +# Prohibit the inclusion of verify.h without an actual use. +sc_prohibit_verify_without_use: + @h=3D'verify.h' \ + re=3D'\<(verify(true|expr)?|assume|static_assert) *\(' \ + $(_sc_header_without_use) + +# Don't include xfreopen.h unless you use one of its functions. +sc_prohibit_xfreopen_without_use: + @h=3D'xfreopen.h' re=3D'\' \ + halt=3D'do not use HAVE''_FCNTL_H or O'_NDELAY \ + $(_sc_search_regexp) + +# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ + +# Each nonempty ChangeLog line must start with a year number, or a TAB. +sc_changelog: + @prohibit=3D'^[^12 ]' \ + in_vc_files=3D'^ChangeLog$$' \ + halt=3D'found unexpected prefix in a ChangeLog' \ + $(_sc_search_regexp) + +# Ensure that each .c file containing a "main" function also +# calls bindtextdomain. +sc_bindtextdomain: + @require=3D'bindtextdomain *\(' \ + in_vc_files=3D'\.c$$' \ + containing=3D'\
/dev/null \ + && : || { die=3D1; echo $$i; } \ + done; \ + test $$die =3D 1 && \ + { echo 1>&2 '$(ME): the final line in each of the above is not:'; \ + echo 1>&2 'Exit something'; \ + exit 1; } || :; \ + fi + +sc_trailing_blank: + @prohibit=3D'[ ]$$' \ + halt=3D'found trailing blank(s)' \ + exclude=3D'^Binary file .* matches$$' \ + $(_sc_search_regexp) + +# Match lines like the following, but where there is only one space +# between the options and the description: +# -D, --all-repeated[=3Ddelimit-method] print all duplicate lines\n +longopt_re =3D --[a-z][0-9A-Za-z-]*(\[?=3D[0-9A-Za-z-]*\]?)? +sc_two_space_separator_in_usage: + @prohibit=3D'^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \ + halt=3D'help2man requires at least two spaces between an option and its d= escription'\ + $(_sc_search_regexp) + +# A regexp matching function names like "error" that may be used +# to emit translatable messages. +_gl_translatable_diag_func_re ?=3D error + +# Look for diagnostics that aren't marked for translation. +# This won't find any for which error's format string is on a separate lin= e. +sc_unmarked_diagnostics: + @prohibit=3D'\<$(_gl_translatable_diag_func_re) *\([^"]*"[^"]*[a-z]{3}' \ + exclude=3D'(_|ngettext ?)\(' \ + halt=3D'found unmarked diagnostic(s)' \ + $(_sc_search_regexp) + +# Avoid useless parentheses like those in this example: +# #if defined (SYMBOL) || defined (SYM2) +sc_useless_cpp_parens: + @prohibit=3D'^# *if .*defined *\(' \ + halt=3D'found useless parentheses in cpp directive' \ + $(_sc_search_regexp) + +# List headers for which HAVE_HEADER_H is always true, assuming you are +# using the appropriate gnulib module. CAUTION: for each "unnecessary" +# #if HAVE_HEADER_H that you remove, be sure that your project explicitly +# requires the gnulib module that guarantees the usability of that header. +gl_assured_headers_ =3D \ + cd $(gnulib_dir)/lib && echo *.in.h|$(SED) 's/\.in\.h//g' + +# Convert the list of names to upper case, and replace each space with "|". +az_ =3D abcdefghijklmnopqrstuvwxyz +AZ_ =3D ABCDEFGHIJKLMNOPQRSTUVWXYZ +gl_header_upper_case_or_ =3D \ + $$($(gl_assured_headers_) \ + | tr $(az_)/.- $(AZ_)___ \ + | tr -s ' ' '|' \ + ) +sc_prohibit_always_true_header_tests: + @or=3D$(gl_header_upper_case_or_); \ + re=3D"HAVE_($$or)_H"; \ + prohibit=3D'\<'"$$re"'\>' \ + halt=3D$$(printf '%s\n' \ + 'do not test the above HAVE_
_H symbol(s);' \ + ' with the corresponding gnulib module, they are always true') \ + $(_sc_search_regexp) + +sc_prohibit_defined_have_decl_tests: + @prohibit=3D'(#[ ]*ifn?def|\[ (]+HAVE_DECL_' \ + halt=3D'HAVE_DECL macros are always defined' \ + $(_sc_search_regexp) + +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +gl_other_headers_ ?=3D \ + intprops.h \ + openat.h \ + stat-macros.h + +# Perl -lne code to extract "significant" cpp-defined symbols from a +# gnulib header file, eliminating a few common false-positives. +# The exempted names below are defined only conditionally in gnulib, +# and hence sometimes must/may be defined in application code. +gl_extract_significant_defines_ =3D \ + /^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\ + && $$2 !~ /(?:rpl_|_used_without_)/\ + && $$1 !~ /^(?:NSIG|ENODATA)$$/\ + && $$1 !~ /^(?:SA_RESETHAND|SA_RESTART)$$/\ + and print $$1 + +# Create a list of regular expressions matching the names +# of macros that are guaranteed to be defined by parts of gnulib. +define def_sym_regex + gen_h=3D$(gl_generated_headers_); \ + (cd $(gnulib_dir)/lib; \ + for f in *.in.h $(gl_other_headers_); do \ + test -f $$f \ + && perl -lne '$(gl_extract_significant_defines_)' $$f; \ + done; \ + ) | sort -u \ + | $(SED) 's/^/^ *# *(define|undef) */;s/$$/\\>/' +endef + +# Don't define macros that we already get from gnulib header files. +sc_prohibit_always-defined_macros: + @if test -d $(gnulib_dir); then \ + case $$(echo all: | $(GREP) -l -f - Makefile) in Makefile);; *) \ + echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \ + esac; \ + regex=3D$$($(def_sym_regex)); export regex; \ + $(VC_LIST_EXCEPT) \ + | xargs sh -c 'echo $$regex | $(GREP) -E -f - "$$@"' \ + dummy /dev/null \ + && { printf '$(ME): define the above' \ + ' via some gnulib .h file\n' 1>&2; \ + exit 1; } \ + || :; \ + fi +# =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +# Prohibit checked in backup files. +sc_prohibit_backup_files: + @$(VC_LIST) | $(GREP) '~$$' && \ + { echo '$(ME): found version controlled backup file' 1>&2; \ + exit 1; } || : + +# Require the latest GPL. +sc_GPL_version: + @prohibit=3D'either ''version [^3]' \ + halt=3D'GPL vN, N!=3D3' \ + $(_sc_search_regexp) + +# Require the latest GFDL. Two regexp, since some .texi files end up +# line wrapping between 'Free Documentation License,' and 'Version'. +_GFDL_regexp =3D (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or= any) +sc_GFDL_version: + @prohibit=3D'$(_GFDL_regexp)' \ + halt=3D'GFDL vN, N!=3D3' \ + $(_sc_search_regexp) + +# Don't use Texinfo's @acronym{}. +# https://lists.gnu.org/r/bug-gnulib/2010-03/msg00321.html +texinfo_suffix_re_ ?=3D \.(txi|texi(nfo)?)$$ +sc_texinfo_acronym: + @prohibit=3D'@acronym\{' \ + in_vc_files=3D'$(texinfo_suffix_re_)' \ + halt=3D'found use of Texinfo @acronym{}' \ + $(_sc_search_regexp) + +cvs_keywords =3D \ + Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State + +sc_prohibit_cvs_keyword: + @prohibit=3D'\$$($(cvs_keywords))\$$' \ + halt=3D'do not use CVS keyword expansion' \ + $(_sc_search_regexp) + +# This Perl code is slightly obfuscated. Not only is each "$" doubled +# because it's in a Makefile, but the $$c's are comments; we cannot +# use "#" due to the way the script ends up concatenated onto one line. +# It would be much more concise, and would produce better output (including +# counts) if written as: +# 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 does not end in exactly one newline byt= e. +# 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... +# +require_exactly_one_NL_at_EOF_ =3D \ + foreach my $$f (@ARGV) \ + { \ + open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \ + my $$p =3D sysseek (F, -2, 2); \ + my $$c =3D "seek failure probably means file has < 2 bytes; ignore";= \ + my $$last_two_bytes; \ + defined $$p and $$p =3D sysread F, $$last_two_bytes, 2; \ + close F; \ + $$c =3D "ignore read failure"; \ + $$p && ($$last_two_bytes eq "\n\n" \ + || substr ($$last_two_bytes,1) ne "\n") \ + and (print $$f), $$fail=3D1; \ + } \ + END { exit defined $$fail } +sc_prohibit_empty_lines_at_EOF: + @$(VC_LIST_EXCEPT) \ + | xargs perl -le '$(require_exactly_one_NL_at_EOF_)' \ + || { 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. +# 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=3D'[.>]st_blocks' \ + halt=3D'do not use st_blocks; use ST_NBLOCKS' \ + $(_sc_search_regexp) + +# Make sure we don't define any S_IS* macros in src/*.c files. +# They're already defined via gnulib's sys/stat.h replacement. +sc_prohibit_S_IS_definition: + @prohibit=3D'^ *# *define *S_IS' \ + halt=3D'do not define S_IS* macros; include ' \ + $(_sc_search_regexp) + +# Perl block to convert a match to FILE_NAME:LINENO:TEST, +# that is shared by two definitions below. +perl_filename_lineno_text_ =3D \ + -e ' {' \ + -e ' $$n =3D ($$` =3D~ tr/\n/\n/ + 1);' \ + -e ' ($$v =3D $$&) =3D~ s/\n/\\n/g;' \ + -e ' print "$$ARGV:$$n:$$v\n";' \ + -e ' }' + +prohibit_doubled_words_ =3D \ + the then in an on if is it but for or at and do to +# expand the regex before running the check to avoid using expensive captu= res +prohibit_doubled_word_expanded_ =3D \ + $(join $(prohibit_doubled_words_),$(addprefix \s+,$(prohibit_doubled_w= ords_))) +prohibit_doubled_word_RE_ ?=3D \ + /\b(?:$(subst $(_sp),|,$(prohibit_doubled_word_expanded_)))\b/gims +prohibit_doubled_word_ =3D \ + -e 'while ($(prohibit_doubled_word_RE_))' \ + $(perl_filename_lineno_text_) + +# Define this to a regular expression that matches +# any filename:dd:match lines you want to ignore. +# The default is to ignore no matches. +ignore_doubled_word_match_RE_ ?=3D ^$$ + +sc_prohibit_doubled_word: + @$(VC_LIST_EXCEPT) \ + | xargs perl -n -0777 $(prohibit_doubled_word_) \ + | $(GREP) -vE '$(ignore_doubled_word_match_RE_)' \ + | $(GREP) . \ + && { echo '$(ME): doubled words' 1>&2; exit 1; } \ + || : + +# A regular expression matching undesirable combinations of words like +# "can not"; this matches them even when the two words appear on different +# lines, but not when there is an intervening delimiter like "#" or "*". +# Similarly undesirable, "See @xref{...}", since an @xref should start +# a sentence. Explicitly prohibit any prefix of "see" or "also". +# Also prohibit a prefix matching "\w+ +". +# @pxref gets the same see/also treatment and should be parenthesized; +# presume it must *not* start a sentence. +# POSIX spells it "timestamp" rather than "time\s+stamp", so we do, too. +bad_xref_re_ ?=3D (?:[\w,:;] +|(?:see|also)\s+)\@xref\{ +bad_pxref_re_ ?=3D (?:[.!?]|(?:see|also))\s+\@pxref\{ +prohibit_undesirable_word_seq_RE_ ?=3D \ + /(?:\bcan\s+not\b|\btime\s+stamps?\b|$(bad_xref_re_)|$(bad_pxref_re_))/g= ims +prohibit_undesirable_word_seq_ =3D \ + -e 'while ($(prohibit_undesirable_word_seq_RE_))' \ + $(perl_filename_lineno_text_) +# Define this to a regular expression that matches +# any filename:dd:match lines you want to ignore. +# The default is to ignore no matches. +ignore_undesirable_word_sequence_RE_ ?=3D ^$$ + +sc_prohibit_undesirable_word_seq: + @$(VC_LIST_EXCEPT) \ + | xargs perl -n -0777 $(prohibit_undesirable_word_seq_) \ + | $(GREP) -vE '$(ignore_undesirable_word_sequence_RE_)' \ + | $(GREP) . \ + && { echo '$(ME): undesirable word sequence' >&2; exit 1; } \ + || : + +# Except for shell files and for loops, double semicolon is probably a mis= take +sc_prohibit_double_semicolon: + @prohibit=3D'; *;[ {} \]*(/[/*]|$$)' \ + in_vc_files=3D'\.[chly]$$' \ + exclude=3D'\bfor *\(.*\)' \ + halt=3D"Double semicolon detected" \ + $(_sc_search_regexp) + +_ptm1 =3D use "test C1 && test C2", not "test C1 -''a C2" +_ptm2 =3D use "test C1 || test C2", not "test C1 -''o C2" +# Using test's -a and -o operators is not portable. +# We prefer test over [, since the latter is spelled [[ in configure.ac. +sc_prohibit_test_minus_ao: + @prohibit=3D'(\ /dev/null \ + || { fail=3D1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \ + done; \ + test $$fail =3D 1 && \ + { echo 1>&2 '$(ME): the above do not link with any ICONV library'; \ + exit 1; } || :; \ + fi + +# Warn about "c0nst struct Foo const foo[]", +# but not about "char const *const foo" or "#define const const". +sc_redundant_const: + @prohibit=3D'\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \ + halt=3D'redundant "const" in declarations' \ + $(_sc_search_regexp) + +sc_const_long_option: + @prohibit=3D'^ *static.*struct option ' \ + exclude=3D'const struct option|struct option const' \ + halt=3D'add "const" to the above declarations' \ + $(_sc_search_regexp) + +NEWS_hash =3D \ + $$($(SED) -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \ + $(srcdir)/NEWS \ + | perl -0777 -pe \ + 's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \ + | md5sum - \ + | $(SED) 's/ .*//') + +# Ensure that we don't accidentally insert an entry into an old NEWS block. +sc_immutable_NEWS: + @if test -f $(srcdir)/NEWS; then \ + test "$(NEWS_hash)" =3D '$(old_NEWS_hash)' && : || \ + { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \ + fi + +# Update the hash stored above. Do this after each release and +# for any corrections to old entries. +update-NEWS-hash: NEWS + perl -pi -e 's/^(old_NEWS_hash[ \t]+:?=3D[ \t]+).*/$${1}'"$(NEWS_hash)/" \ + $(srcdir)/cfg.mk + +# Ensure that we use only the standard $(VAR) notation, +# not @...@ in Makefile.am, now that we can rely on automake +# to emit a definition for each substituted variable. +# However, there is still one case in which @VAR@ use is not just +# legitimate, but actually required: when augmenting an automake-defined +# variable with a prefix. For example, gettext uses this: +# MAKEINFO =3D env LANG=3D LC_MESSAGES=3D LC_ALL=3D LANGUAGE=3D @MAKEINFO@ +# otherwise, makeinfo would put German or French (current locale) +# navigation hints in the otherwise-English documentation. +# +# Allow the package to add exceptions via a hook in cfg.mk; +# for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by +# setting this to ' && !/PRAGMA_SYSTEM_HEADER/'. +_makefile_at_at_check_exceptions ?=3D +sc_makefile_at_at_check: + @perl -ne '/\@\w+\@/' \ + -e ' && !/(\w+)\s+=3D.*\@\1\@$$/' \ + -e ''$(_makefile_at_at_check_exceptions) \ + -e 'and (print "$$ARGV:$$.: $$_"), $$m=3D1; END {exit !$$m}' \ + $$($(VC_LIST_EXCEPT) | $(GREP) -E '(^|/)(Makefile\.am|[^/]+\.mk)$$') \ + && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || : + +news-check: NEWS + $(AM_V_GEN)if $(SED) -n $(news-check-lines-spec)p $< \ + | $(GREP) -E $(news-check-regexp) >/dev/null; then \ + :; \ + else \ + echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \ + exit 1; \ + fi + +sc_makefile_TAB_only_indentation: + @prohibit=3D'^ [ ]{8}' \ + in_vc_files=3D'akefile|\.mk$$' \ + halt=3D'found TAB-8-space indentation' \ + $(_sc_search_regexp) + +sc_m4_quote_check: + @prohibit=3D'(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \ + in_vc_files=3D'(^configure\.ac|\.m4)$$' \ + halt=3D'quote the first arg to AC_DEF*' \ + $(_sc_search_regexp) + +fix_po_file_diag =3D \ +'you have changed the set of files with translatable diagnostics;\n\ +apply the above patch\n' + +# Generate a list of files in which to search for translatable strings. +perl_translatable_files_list_ =3D \ + -e 'foreach $$file (@ARGV) {' \ + -e ' \# Consider only file extensions with one or two letters' \ + -e ' $$file =3D~ /\...?$$/ or next;' \ + -e ' \# Ignore m4 and mk files' \ + -e ' $$file =3D~ /\.m[4k]$$/ and next;' \ + -e ' \# Ignore a .c or .h file with a corresponding .l or .y file' \ + -e ' $$file =3D~ /(.+)\.[ch]$$/ && (-e "$${1}.l" || -e "$${1}.y")' \ + -e ' and next;' \ + -e ' \# Skip unreadable files' \ + -e ' -r $$file or next;' \ + -e ' print "$$file ";' \ + -e '}' + +# Verify that all source files using _() (more specifically, files that +# match $(_gl_translatable_string_re)) are listed in po/POTFILES.in. +po_file ?=3D $(srcdir)/po/POTFILES.in +generated_files ?=3D $(srcdir)/lib/*.[ch] +_gl_translatable_string_re ?=3D \b(N?_|gettext *)\([^)"]*("|$$) +sc_po_check: + @if test -f $(po_file); then \ + $(GREP) -E -v '^(#|$$)' $(po_file) \ + | $(GREP) -v '^src/false\.c$$' | sort > $@-1; \ + { $(VC_LIST_EXCEPT); echo $(generated_files); } \ + | xargs perl $(perl_translatable_files_list_) \ + | xargs $(GREP) -E -l '$(_gl_translatable_string_re)' \ + | $(SED) 's|^$(_dot_escaped_srcdir)/||' \ + | sort -u > $@-2; \ + diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \ + || { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \ + rm -f $@-1 $@-2; \ + fi + +# Sometimes it is useful to change the PATH environment variable +# in Makefiles. When doing so, it's better not to use the Unix-centric +# path separator of ':', but rather the automake-provided '$(PATH_SEPARATO= R)'. +msg =3D 'Do not use ":" above; use $$(PATH_SEPARATOR) instead' +sc_makefile_path_separator_check: + @prohibit=3D'PATH[=3D].*:' \ + in_vc_files=3D'akefile|\.mk$$' \ + halt=3D$(msg) \ + $(_sc_search_regexp) + +# Check that 'make alpha' will not fail at the end of the process, +# i.e., when pkg-M.N.tar.xz already exists (either in "." or in ../release) +# and is read-only. +writable-files: + $(AM_V_GEN)if test -d $(release_archive_dir); then \ + for file in $(DIST_ARCHIVES); do \ + for p in ./ $(release_archive_dir)/; do \ + test -e $$p$$file || continue; \ + test -w $$p$$file \ + || { echo ERROR: $$p$$file is not writable; fail=3D1; }; \ + done; \ + done; \ + test "$$fail" && exit 1 || : ; \ + else :; \ + fi + +v_etc_file =3D $(gnulib_dir)/lib/version-etc.c +sample-test =3D tests/sample-test +texi =3D doc/$(PACKAGE).texi +# Make sure that the copyright date in $(v_etc_file) is up to date. +# Do the same for the $(sample-test) and the main doc/.texi file. +sc_copyright_check: + @require=3D'enum { COPYRIGHT_YEAR =3D '$$(date +%Y)' };' \ + in_files=3D$(v_etc_file) \ + halt=3D'out of date copyright in $(v_etc_file); update it' \ + $(_sc_search_regexp) + @require=3D'# Copyright \(C\) '$$(date +%Y)' Free' \ + in_vc_files=3D$(sample-test) \ + halt=3D'out of date copyright in $(sample-test); update it' \ + $(_sc_search_regexp) + @require=3D'Copyright @copyright\{\} .*'$$(date +%Y) \ + in_vc_files=3D$(texi) \ + halt=3D'out of date copyright in $(texi); update it' \ + $(_sc_search_regexp) + +# If tests/help-version exists and seems to be new enough, assume that its +# use of init.sh and path_prepend_ is correct, and ensure that every other +# use of init.sh is identical. +# This is useful because help-version cross-checks prog --version +# with $(VERSION), which verifies that its path_prepend_ invocation +# sets PATH correctly. This is an inexpensive way to ensure that +# the other init.sh-using tests also get it right. +_hv_file ?=3D $(srcdir)/tests/help-version +_hv_regex_weak ?=3D ^ *\. .*/init\.sh" +# Fix syntax-highlighters " +_hv_regex_strong ?=3D ^ *\. "\$${srcdir=3D\.}/init\.sh" +sc_cross_check_PATH_usage_in_tests: + @if test -f $(_hv_file); then \ + $(GREP) -l 'VERSION mismatch' $(_hv_file) >/dev/null \ + || { echo "$@: skipped: no such file: $(_hv_file)" 1>&2; \ + exit 0; }; \ + $(GREP) -lE '$(_hv_regex_strong)' $(_hv_file) >/dev/null \ + || { echo "$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \ + exit 1; }; \ + good=3D$$($(GREP) -E '$(_hv_regex_strong)' $(_hv_file)); \ + $(VC_LIST_EXCEPT) \ + | xargs $(GREP) -lE '$(_hv_regex_weak)' \ + | xargs $(GREP) -LFx "$$good" \ + | $(GREP) . \ + && { printf "$(ME): the above files use" \ + " path_prepend_ inconsistently\n" 1>&2; \ + exit 1; } \ + || :; \ + fi + +# BRE regex of file contents to identify a test script. +_test_script_regex ?=3D \ + +# In tests, use "compare expected actual", not the reverse. +sc_prohibit_reversed_compare_failure: + @prohibit=3D'\ vc-diffs || : + $(AM_V_at)if test -s vc-diffs; then \ + cat vc-diffs; \ + echo "Some files are locally modified:" 1>&2; \ + exit 1; \ + else \ + rm vc-diffs; \ + fi + +rel-files =3D $(DIST_ARCHIVES) + +gnulib-version =3D $$(cd $(gnulib_dir) \ + && { git describe || git rev-parse --short=3D10 HEAD; = } ) +bootstrap-tools ?=3D autoconf,automake,gnulib + +gpgv =3D $$(gpgv2 --version >/dev/null && echo gpgv2 || echo gpgv) +# If it's not already specified, derive the GPG key ID from +# the signed tag we've just applied to mark this release. +gpg_key_ID ?=3D \ + $$(cd $(srcdir) \ + && git cat-file tag v$(VERSION) \ + | $(gpgv) --status-fd 1 --keyring /dev/null - - 2>/dev/null \ + | $(AWK) '/^\[GNUPG:\] ERRSIG / {print $$3; exit}') + +translation_project_ ?=3D coordinator@translationproject.org + +# Make info-gnu the default only for a stable release. +announcement_Cc_stable =3D $(translation_project_), $(PACKAGE_BUGREPORT) +announcement_mail_headers_stable =3D \ + To: info-gnu@gnu.org \ + Cc: $(announcement_Cc_) \ + Mail-Followup-To: $(PACKAGE_BUGREPORT) + +announcement_Cc_alpha =3D $(translation_project_) +announcement_mail_headers_alpha =3D \ + To: $(PACKAGE_BUGREPORT) \ + Cc: $(announcement_Cc_) + +announcement_mail_Cc_beta =3D $(announcement_mail_Cc_alpha) +announcement_mail_headers_beta =3D $(announcement_mail_headers_alpha) + +announcement_mail_Cc_ ?=3D $(announcement_mail_Cc_$(release-type)) +announcement_mail_headers_ ?=3D $(announcement_mail_headers_$(release-type= )) +announcement: NEWS ChangeLog $(rel-files) +# Not $(AM_V_GEN) since the output of this command serves as +# announcement message: it would start with " GEN announcement". + $(AM_V_at)$(srcdir)/$(_build-aux)/announce-gen \ + --mail-headers=3D'$(announcement_mail_headers_)' \ + --release-type=3D$(release-type) \ + --package=3D$(PACKAGE) \ + --prev=3D$(PREV_VERSION) \ + --curr=3D$(VERSION) \ + --gpg-key-id=3D$(gpg_key_ID) \ + --srcdir=3D$(srcdir) \ + --news=3D$(srcdir)/NEWS \ + --bootstrap-tools=3D$(bootstrap-tools) \ + $$(case ,$(bootstrap-tools), in (*,gnulib,*) \ + echo --gnulib-version=3D$(gnulib-version);; esac) \ + --no-print-checksums \ + $(addprefix --url-dir=3D, $(url_dir_list)) + +.PHONY: release-commit +release-commit: + $(AM_V_GEN)cd $(srcdir) \ + && $(_build-aux)/do-release-commit-and-tag \ + -C $(abs_builddir) $(RELEASE) + +## ---------------- ## +## Updating files. ## +## ---------------- ## + +ftp-gnu =3D https://ftp.gnu.org/gnu +www-gnu =3D https://www.gnu.org + +upload_dest_dir_ ?=3D $(PACKAGE) +upload_command =3D \ + $(srcdir)/$(_build-aux)/gnupload $(GNUPLOADFLAGS) \ + --to $(gnu_rel_host):$(upload_dest_dir_) \ + $(rel-files) +emit_upload_commands: + @echo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + @echo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + @echo '$(upload_command)' + @echo '# send the ~/announce-$(my_distdir) e-mail' + @echo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + @echo =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.PHONY: upload +upload: + $(AM_V_GEN)$(upload_command) + +define emit-commit-log + printf '%s\n' 'maint: post-release administrivia' '' \ + '* NEWS: Add header line for next release.' \ + '* .prev-version: Record previous version.' \ + '* cfg.mk (old_NEWS_hash): Auto-update.' +endef + +.PHONY: no-submodule-changes +no-submodule-changes: + $(AM_V_GEN)if test -d $(srcdir)/.git \ + && git --version >/dev/null 2>&1; then \ + diff=3D$$(cd $(srcdir) && git submodule -q foreach \ + git diff-index --name-only HEAD) \ + || exit 1; \ + case $$diff in '') ;; \ + *) echo '$(ME): submodule files are locally modified:'; \ + echo "$$diff"; exit 1;; esac; \ + else \ + : ; \ + fi + +submodule-checks ?=3D no-submodule-changes public-submodule-commit + +# Ensure that each sub-module commit we're using is public. +# Without this, it is too easy to tag and release code that +# cannot be built from a fresh clone. +.PHONY: public-submodule-commit +public-submodule-commit: + $(AM_V_GEN)if test -d $(srcdir)/.git \ + && git --version >/dev/null 2>&1; then \ + cd $(srcdir) && \ + git submodule --quiet foreach \ + 'test "$$(git rev-parse "$$sha1")" \ + =3D "$$(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=3D" +# to disable this test. +gl_public_submodule_commit ?=3D public-submodule-commit +check: $(gl_public_submodule_commit) + +.PHONY: alpha beta stable release +ALL_RECURSIVE_TARGETS +=3D alpha beta stable +alpha beta stable: $(local-check) writable-files $(submodule-checks) + $(AM_V_GEN)test $@ =3D stable \ + && { echo $(VERSION) | $(GREP) -E '^[0-9]+(\.[0-9]+)+$$' \ + || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\ + || : + $(AM_V_at)$(MAKE) vc-diff-check + $(AM_V_at)$(MAKE) news-check + $(AM_V_at)$(MAKE) distcheck + $(AM_V_at)$(MAKE) dist + $(AM_V_at)$(MAKE) $(release-prep-hook) RELEASE_TYPE=3D$@ + $(AM_V_at)$(MAKE) -s emit_upload_commands RELEASE_TYPE=3D$@ + +release: + $(AM_V_GEN)$(MAKE) _version + $(AM_V_GEN)$(MAKE) $(release-type) + +# Override this in cfg.mk if you follow different procedures. +release-prep-hook ?=3D release-prep + +gl_noteworthy_news_ =3D * Noteworthy changes in release ?.? (????-??-??) [= ?] +.PHONY: release-prep +release-prep: + $(AM_V_GEN)$(MAKE) --no-print-directory -s announcement \ + > ~/announce-$(my_distdir) + $(AM_V_at)if test -d $(release_archive_dir); then \ + ln $(rel-files) $(release_archive_dir); \ + chmod a-w $(rel-files); \ + fi + $(AM_V_at)echo $(VERSION) > $(prev_version_file) + $(AM_V_at)$(MAKE) update-NEWS-hash + $(AM_V_at)perl -pi \ + -e '$$. =3D=3D 3 and print "$(gl_noteworthy_news_)\n\n\n"' \ + $(srcdir)/NEWS + $(AM_V_at)msg=3D$$($(emit-commit-log)) || exit 1; \ + cd $(srcdir) && $(VC) commit -m "$$msg" -a + +# Override this with e.g., -s $(srcdir)/some_other_name.texi +# if the default $(PACKAGE)-derived name doesn't apply. +gendocs_options_ ?=3D + +.PHONY: web-manual +web-manual: + $(AM_V_GEN)test -z "$(manual_title)" \ + && { echo define manual_title in cfg.mk 1>&2; exit 1; } || : + $(AM_V_at)cd '$(srcdir)/doc'; \ + $(SHELL) ../$(_build-aux)/gendocs.sh $(gendocs_options_) \ + -o '$(abs_builddir)/doc/manual' \ + --email $(PACKAGE_BUGREPORT) $(PACKAGE) \ + "$(PACKAGE_NAME) - $(manual_title)" + $(AM_V_at)echo " *** Upload the doc/manual directory to web-cvs." + +.PHONY: web-manual-update +web-manual-update: + $(AM_V_GEN)cd $(srcdir) \ + && $(_build-aux)/gnu-web-doc-update -C $(abs_builddir) + + +# Code Coverage + +init-coverage: + $(MAKE) $(AM_MAKEFLAGS) clean + lcov --directory . --zerocounters + +COVERAGE_CCOPTS ?=3D "-g --coverage" +COVERAGE_OUT ?=3D doc/coverage + +build-coverage: + $(MAKE) $(AM_MAKEFLAGS) CFLAGS=3D$(COVERAGE_CCOPTS) CXXFLAGS=3D$(COVERAGE= _CCOPTS) + $(MAKE) $(AM_MAKEFLAGS) CFLAGS=3D$(COVERAGE_CCOPTS) CXXFLAGS=3D$(COVERAGE= _CCOPTS) check + mkdir -p $(COVERAGE_OUT) + lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \ + --capture + +gen-coverage: + genhtml --output-directory $(COVERAGE_OUT) \ + $(COVERAGE_OUT)/$(PACKAGE).info \ + --highlight --frames --legend \ + --title "$(PACKAGE_NAME)" + +coverage: + $(MAKE) init-coverage + $(MAKE) build-coverage + $(MAKE) gen-coverage + +# Some projects carry local adjustments for gnulib modules via patches in +# a gnulib patch directory whose default name is gl/ (defined in bootstrap +# via local_gl_dir=3Dgl). Those patches become stale as the originals evo= lve +# in gnulib. Use this rule to refresh any stale patches. It applies each +# patch to the original in $(gnulib_dir) and uses the temporary result to +# generate a fuzz-free .diff file. If you customize the name of your local +# gnulib patch directory via bootstrap.conf, this rule detects that name. +# Run this from a non-VPATH (i.e., srcdir) build directory. +.PHONY: refresh-gnulib-patches +refresh-gnulib-patches: + gl=3Dgl; \ + if test -f bootstrap.conf; then \ + t=3D$$(perl -lne '/^\s*local_gl_dir=3D(\S+)/ and $$d=3D$$1;' \ + -e 'END{defined $$d and print $$d}' bootstrap.conf); \ + test -n "$$t" && gl=3D$$t; \ + fi; \ + for diff in $$(cd $$gl; git ls-files | $(GREP) '\.diff$$'); do \ + b=3D$$(printf %s "$$diff"|$(SED) 's/\.diff$$//'); \ + VERSION_CONTROL=3Dnone \ + patch "$(gnulib_dir)/$$b" "$$gl/$$diff" || exit 1; \ + ( cd $(gnulib_dir) || exit 1; \ + git diff "$$b" > "../$$gl/$$diff"; \ + git checkout $$b ) || exit 1; \ + done + +# Update gettext files. +PACKAGE ?=3D $(shell basename $(PWD)) +PO_DOMAIN ?=3D $(PACKAGE) +POURL =3D https://translationproject.org/latest/$(PO_DOMAIN)/ +PODIR ?=3D po +refresh-po: + rm -f $(PODIR)/*.po && \ + echo "$(ME): getting translations into po (please ignore the robots.txt E= RROR 404)..." && \ + wget --no-verbose --directory-prefix $(PODIR) --no-directories --recursiv= e --level 1 --accept .po --accept .po.1 $(POURL) && \ + echo 'en@boldquot' > $(PODIR)/LINGUAS && \ + echo 'en@quot' >> $(PODIR)/LINGUAS && \ + ls $(PODIR)/*.po | $(SED) 's/\.po//;s,$(PODIR)/,,' | \ + sort >> $(PODIR)/LINGUAS + + # Running indent once is not idempotent, but running it twice is. +INDENT_SOURCES ?=3D $(C_SOURCES) +.PHONY: indent +indent: + indent $(INDENT_SOURCES) + indent $(INDENT_SOURCES) + +# If you want to set UPDATE_COPYRIGHT_* environment variables, +# put the assignments in this variable. +update-copyright-env ?=3D + +# Run this rule once per year (usually early in January) +# to update all FSF copyright year lists in your project. +# If you have an additional project-specific rule, +# add it in cfg.mk along with a line 'update-copyright: prereq'. +# By default, exclude all variants of COPYING; you can also +# add exemptions (such as ChangeLog..* for rotated change logs) +# in the file .x-update-copyright. +.PHONY: update-copyright +update-copyright: + $(AM_V_GEN)$(GREP) -l -w Copyright \ + $$(export VC_LIST_EXCEPT_DEFAULT=3DCOPYING && $(VC_LIST_EXCEPT)) \ + | $(update-copyright-env) xargs $(srcdir)/$(_build-aux)/$@ + +# This tight_scope test is skipped with a warning if $(_gl_TS_headers) is = not +# overridden and $(_gl_TS_dir)/Makefile.am does not mention noinst_HEADERS. + +# NOTE: to override any _gl_TS_* default value, you must +# define the variable(s) using "export" in cfg.mk. +_gl_TS_dir ?=3D src + +ALL_RECURSIVE_TARGETS +=3D sc_tight_scope +sc_tight_scope: tight-scope.mk + @fail=3D0; \ + if ! $(GREP) '^ *export _gl_TS_headers *=3D' $(srcdir)/cfg.mk \ + > /dev/null \ + && ! $(GREP) -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \ + > /dev/null 2>&1; then \ + echo '$(ME): skipping $@'; \ + else \ + $(MAKE) -s -C $(_gl_TS_dir) \ + -f Makefile \ + -f $(abs_top_srcdir)/cfg.mk \ + -f $(abs_top_builddir)/$< \ + _gl_tight_scope \ + || fail=3D1; \ + fi; \ + rm -f $<; \ + exit $$fail + +tight-scope.mk: $(ME) + @rm -f $@ $@-t + @perl -ne '/^# TS-start/.../^# TS-end/ and print' $(srcdir)/$(ME) > $@-t + @chmod a=3Dr $@-t && mv $@-t $@ + +ifeq (a,b) +# TS-start + +# Most functions should have static scope. +# Any that don't must be marked with 'extern', but 'main' +# and 'usage' are exceptions: they're always extern, but +# do not need to be marked. Symbols matching '__.*' are +# reserved by the compiler, so are automatically excluded below. +_gl_TS_unmarked_extern_functions ?=3D main usage +_gl_TS_function_match ?=3D /^(?:$(_gl_TS_extern)) +.*?(\w+) *\(/ + +# If your project uses a macro like "XTERN", then put +# the following in cfg.mk to override this default: +# export _gl_TS_extern =3D extern|XTERN +_gl_TS_extern ?=3D extern + +# The second nm|grep checks for file-scope variables with 'extern' scope. +# Without gnulib's progname module, you might put program_name here. +# Symbols matching '__.*' are reserved by the compiler, +# so are automatically excluded below. +_gl_TS_unmarked_extern_vars ?=3D + +# NOTE: the _match variables are perl expressions -- not mere regular +# expressions -- so that you can extend them to match other patterns +# and easily extract matched variable names. +# For example, if your project declares some global variables via +# a macro like this: GLOBAL(type, var_name, initializer), then you +# can override this definition to automatically extract those names: +# export _gl_TS_var_match =3D \ +# /^(?:$(_gl_TS_extern)) .*?\**(\w+)(\[.*?\])?;/ || /\bGLOBAL\(.*?,\s*(.= *?),/ +_gl_TS_var_match ?=3D /^(?:$(_gl_TS_extern)) .*?(\w+)(\[.*?\])?;/ + +# The names of object files in (or relative to) $(_gl_TS_dir). +_gl_TS_obj_files ?=3D *.$(OBJEXT) + +# Files in which to search for the one-line style extern declarations. +# $(_gl_TS_dir)-relative. +_gl_TS_headers ?=3D $(noinst_HEADERS) +_gl_TS_other_headers ?=3D *.h + +.PHONY: _gl_tight_scope +_gl_tight_scope: $(bin_PROGRAMS) + sed_wrap=3D's/^/^_?/;s/$$/$$/'; \ + t=3Dexceptions-$$$$; \ + trap 's=3D$$?; rm -f $$t; exit $$s' 0; \ + for sig in 1 2 3 13 15; do \ + eval "trap 'v=3D`expr $$sig + 128`; (exit $$v); exit $$v' $$sig"; \ + done; \ + src=3D`for f in $(SOURCES); do \ + test -f $$f && d=3D || d=3D$(srcdir)/; echo $$d$$f; done`; \ + hdr=3D`for f in $(_gl_TS_headers); do \ + test -f $$f && d=3D || d=3D$(srcdir)/; echo $$d$$f; done`; \ + ( printf '%s\n' '__.*' $(_gl_TS_unmarked_extern_functions); \ + $(GREP) -h -A1 '^extern .*[^;]$$' $$src \ + | $(GREP) -vE '^(extern |--|#)' | $(SED) 's/ .*//; /^$$/d'; \ + perl -lne \ + '$(_gl_TS_function_match) and print $$1' $$hdr; \ + ) | sort -u | $(SED) "$$sed_wrap" > $$t; \ + nm -g $(_gl_TS_obj_files)|$(SED) -n 's/.* T //p'|$(GREP) -Ev -f $$t \ + && { echo the above functions should have static scope >&2; \ + exit 1; } || : ; \ + ( printf '%s\n' '__.*' main $(_gl_TS_unmarked_extern_vars); \ + perl -lne '$(_gl_TS_var_match) and print $$1' \ + $$hdr $(_gl_TS_other_headers) \ + ) | sort -u | $(SED) "$$sed_wrap" > $$t; \ + nm -g $(_gl_TS_obj_files) | $(SED) -n 's/.* [BCDGRS] //p' \ + | sort -u | $(GREP) -Ev -f $$t \ + && { echo the above variables should have static scope >&2; \ + exit 1; } || : +# TS-end +endif --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list