[libvirt] [PATCH v2 2/5] build: move syntax-check code into build-aux directory

Daniel P. Berrangé berrange at redhat.com
Tue Oct 8 15:48:41 UTC 2019


The syntax-check rules are the one bit of make usage that will
stay around for a while after the meson conversion. Move them
into the build-aux directory in preparation for refactoring
to make them independent from automake.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 GNUmakefile                    | 23 ++++++-----------
 Makefile.am                    |  4 +--
 cfg.mk => build-aux/cfg.mk     | 45 ++++++++++++++++++++--------------
 maint.mk => build-aux/maint.mk | 18 ++++++--------
 4 files changed, 44 insertions(+), 46 deletions(-)
 rename cfg.mk => build-aux/cfg.mk (96%)
 rename maint.mk => build-aux/maint.mk (99%)

diff --git a/GNUmakefile b/GNUmakefile
index da25113fc3..728f4a9ae8 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -20,6 +20,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
+_build-aux ?= build-aux
+_autoreconf ?= autoreconf -v
+
 # If the user runs GNU make but has not yet run ./configure,
 # give them a diagnostic.
 _gl-Makefile := $(wildcard [M]akefile)
@@ -32,15 +35,8 @@ export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
 ALL_RECURSIVE_TARGETS =
 
 include Makefile
-
-# Some projects override e.g., _autoreconf here.
--include $(srcdir)/cfg.mk
-
-# Allow cfg.mk to override these.
-_build-aux ?= build-aux
-_autoreconf ?= autoreconf -v
-
-include $(srcdir)/maint.mk
+include $(srcdir)/$(_build-aux)/cfg.mk
+include $(srcdir)/$(_build-aux)/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.
@@ -90,13 +86,8 @@ else
 srcdir = .
 
 # The package can override .DEFAULT_GOAL to run actions like autoreconf.
--include ./cfg.mk
-
-# Allow cfg.mk to override these.
-_build-aux ?= build-aux
-_autoreconf ?= autoreconf -v
-
-include ./maint.mk
+include $(srcdir)/$(_build-aux)/cfg.mk
+include $(srcdir)/$(_build-aux)/maint.mk
 
 ifeq ($(.DEFAULT_GOAL),abort-due-to-no-makefile)
 $(MAKECMDGOALS): abort-due-to-no-makefile
diff --git a/Makefile.am b/Makefile.am
index c91e7c55a5..a569a4260a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,15 +41,15 @@ EXTRA_DIST = \
   libvirt-admin.pc.in \
   Makefile.nonreentrant \
   autogen.sh \
-  cfg.mk \
   GNUmakefile \
-  maint.mk \
   run.in \
   README.md \
   AUTHORS.in \
   build-aux/augeas-gentest.pl \
+  build-aux/cfg.mk \
   build-aux/check-spacing.pl \
   build-aux/header-ifdef.pl \
+  build-aux/maint.mk \
   build-aux/minimize-po.pl \
   build-aux/mock-noinline.pl \
   build-aux/prohibit-duplicate-header.pl \
diff --git a/cfg.mk b/build-aux/cfg.mk
similarity index 96%
rename from cfg.mk
rename to build-aux/cfg.mk
index 2224d4da25..31c0d68a81 100644
--- a/cfg.mk
+++ b/build-aux/cfg.mk
@@ -1206,13 +1206,13 @@ exclude_file_name_regexp--sc_bindtextdomain = .*
 exclude_file_name_regexp--sc_gettext_init = ^((tests|examples)/|tools/virt-login-shell.c)
 
 exclude_file_name_regexp--sc_copyright_format = \
-	^cfg\.mk$$
+	^build-aux/cfg\.mk$$
 
 exclude_file_name_regexp--sc_copyright_usage = \
-  ^(COPYING(|\.LESSER))|maint\.mk$$
+  ^COPYING(|\.LESSER)|build-aux/maint.mk$$
 
 exclude_file_name_regexp--sc_flags_usage = \
-  ^(cfg\.mk|docs/|src/util/virnetdevtap\.c$$|tests/((vir(cgroup|pci|test|usb)|nss|qemuxml2argv|qemusecurity)mock|virfilewrapper)\.c$$)
+  ^(build-aux/cfg\.mk|docs/|src/util/virnetdevtap\.c$$|tests/((vir(cgroup|pci|test|usb)|nss|qemuxml2argv|qemusecurity)mock|virfilewrapper)\.c$$)
 
 exclude_file_name_regexp--sc_libvirt_unmarked_diagnostics = \
   ^(src/rpc/gendispatch\.pl$$|tests/)
@@ -1220,16 +1220,22 @@ exclude_file_name_regexp--sc_libvirt_unmarked_diagnostics = \
 exclude_file_name_regexp--sc_po_check = ^(docs/|src/rpc/gendispatch\.pl$$)
 
 exclude_file_name_regexp--sc_prohibit_VIR_ERR_NO_MEMORY = \
-  ^(cfg\.mk|include/libvirt/virterror\.h|src/remote/remote_daemon_dispatch\.c|src/util/virerror\.c|docs/internals/oomtesting\.html\.in)$$
+  ^(build-aux/cfg\.mk|include/libvirt/virterror\.h|src/remote/remote_daemon_dispatch\.c|src/util/virerror\.c|docs/internals/oomtesting\.html\.in)$$
+
+exclude_file_name_regexp--sc_makefile_TAB_only_indentation = \
+  ^build-aux/maint\.mk$$
+
+exclude_file_name_regexp--sc_makefile_at_at_check = \
+  ^build-aux/maint\.mk$$
 
 exclude_file_name_regexp--sc_prohibit_PATH_MAX = \
-	^cfg\.mk$$
+	^build-aux/(cfg|maint)\.mk$$
 
 exclude_file_name_regexp--sc_prohibit_access_xok = \
-	^(cfg\.mk|src/util/virutil\.c)$$
+	^(build-aux/cfg\.mk|src/util/virutil\.c)$$
 
 exclude_file_name_regexp--sc_prohibit_asprintf = \
-  ^(cfg\.mk|bootstrap.conf$$|examples/|src/util/virstring\.[ch]$$|tests/vircgroupmock\.c|tools/virt-login-shell\.c|tools/nss/libvirt_nss\.c$$)
+  ^(build-aux/cfg\.mk|bootstrap.conf$$|examples/|src/util/virstring\.[ch]$$|tests/vircgroupmock\.c|tools/virt-login-shell\.c|tools/nss/libvirt_nss\.c$$)
 
 exclude_file_name_regexp--sc_prohibit_strdup = \
   ^(docs/|examples/|src/util/virstring\.c|tests/vir(netserverclient|cgroup)mock.c|tests/commandhelper\.c|tools/nss/libvirt_nss_(leases|macs)\.c$$)
@@ -1259,13 +1265,13 @@ exclude_file_name_regexp--sc_prohibit_nonreentrant = \
   ^((po|tests|examples)/|docs/.*(py|js|html\.in)|run.in$$|tools/wireshark/util/genxdrstub\.pl|tools/virt-login-shell\.c$$)
 
 exclude_file_name_regexp--sc_prohibit_select = \
-	^cfg\.mk$$
+	^build-aux/cfg\.mk$$
 
 exclude_file_name_regexp--sc_prohibit_canonicalize_file_name = \
-  ^(cfg\.mk|tests/virfilemock\.c)$$
+  ^(build-aux/cfg\.mk|tests/virfilemock\.c)$$
 
 exclude_file_name_regexp--sc_prohibit_raw_allocation = \
-  ^(docs/hacking\.html\.in|src/util/viralloc\.[ch]|examples/.*|tests/(securityselinuxhelper|(vircgroup|nss)mock|commandhelper)\.c|tools/wireshark/src/packet-libvirt\.c|tools/nss/libvirt_nss(_leases|_macs)?\.c)$$
+  ^(docs/hacking\.html\.in|src/util/viralloc\.[ch]|examples/.*|tests/(securityselinuxhelper|(vircgroup|nss)mock|commandhelper)\.c|tools/wireshark/src/packet-libvirt\.c|tools/nss/libvirt_nss(_leases|_macs)?\.c|build-aux/useless-if-before-free)$$
 
 exclude_file_name_regexp--sc_prohibit_readlink = \
   ^src/(util/virutil|lxc/lxc_container)\.c$$
@@ -1273,7 +1279,7 @@ exclude_file_name_regexp--sc_prohibit_readlink = \
 exclude_file_name_regexp--sc_prohibit_setuid = ^src/util/virutil\.c|tools/virt-login-shell\.c$$
 
 exclude_file_name_regexp--sc_prohibit_sprintf = \
-  ^(cfg\.mk|docs/hacking\.html\.in|.*\.stp|.*\.pl)$$
+  ^(build-aux/cfg\.mk|docs/hacking\.html\.in|.*\.stp|.*\.pl)$$
 
 exclude_file_name_regexp--sc_prohibit_strncpy = ^src/util/virstring\.c$$
 
@@ -1283,7 +1289,7 @@ exclude_file_name_regexp--sc_prohibit_xmlGetProp = ^src/util/virxml\.c$$
 
 exclude_file_name_regexp--sc_prohibit_xmlURI = ^src/util/viruri\.c$$
 
-exclude_file_name_regexp--sc_prohibit_return_as_function = \.py$$
+exclude_file_name_regexp--sc_prohibit_return_as_function = \.py|build-aux/useless-if-before-free$$
 
 exclude_file_name_regexp--sc_require_config_h = \
 	^(examples/|tools/virsh-edit\.c$$|tests/virmockstathelpers.c)
@@ -1297,7 +1303,7 @@ exclude_file_name_regexp--sc_trailing_blank = \
 exclude_file_name_regexp--sc_unmarked_diagnostics = \
   ^(docs/apibuild.py|tests/virt-aa-helper-test|docs/js/.*\.js)$$
 
-exclude_file_name_regexp--sc_size_of_brackets = cfg.mk
+exclude_file_name_regexp--sc_size_of_brackets = build-aux/cfg\.mk
 
 exclude_file_name_regexp--sc_correct_id_types = \
   (^src/locking/lock_protocol.x$$)
@@ -1311,7 +1317,7 @@ exclude_file_name_regexp--sc_prohibit_include_public_headers_brackets = \
   ^(tools/|examples/|include/libvirt/(virterror|libvirt(-(admin|qemu|lxc))?)\.h$$)
 
 exclude_file_name_regexp--sc_prohibit_int_ijk = \
-  ^(src/remote_protocol-structs|src/remote/remote_protocol\.x|cfg\.mk|include/libvirt/libvirt.+|src/admin_protocol-structs|src/admin/admin_protocol\.x)$$
+  ^(src/remote_protocol-structs|src/remote/remote_protocol\.x|build-aux/cfg\.mk|include/libvirt/libvirt.+|src/admin_protocol-structs|src/admin/admin_protocol\.x)$$
 
 exclude_file_name_regexp--sc_prohibit_unsigned_pid = \
   ^(include/libvirt/.*\.h|src/(qemu/qemu_driver\.c|driver-hypervisor\.h|libvirt(-[a-z]*)?\.c|.*\.x|util/vir(polkit|systemd)\.c)|tests/virpolkittest\.c|tools/virsh-domain\.c)$$
@@ -1329,16 +1335,16 @@ exclude_file_name_regexp--sc_prohibit_useless_translation = \
   ^tests/virpolkittest.c
 
 exclude_file_name_regexp--sc_prohibit_devname = \
-  ^(tools/virsh.pod|cfg.mk|docs/.*)$$
+  ^(tools/virsh.pod|build-aux/cfg\.mk|docs/.*)$$
 
 exclude_file_name_regexp--sc_prohibit_virXXXFree = \
-  ^(docs/|tests/|examples/|tools/|cfg.mk|src/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage|stream|secret|nwfilter|interface|domain-snapshot).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream|secret|nwfilter|interface|domain-snapshot).c$$)
+  ^(docs/|tests/|examples/|tools/|build-aux/cfg\.mk|src/test/test_driver.c|src/libvirt_public.syms|include/libvirt/libvirt-(domain|network|nodedev|storage|stream|secret|nwfilter|interface|domain-snapshot).h|src/libvirt-(domain|qemu|network|nodedev|storage|stream|secret|nwfilter|interface|domain-snapshot).c$$)
 
 exclude_file_name_regexp--sc_prohibit_sysconf_pagesize = \
-  ^(cfg\.mk|src/util/virutil\.c)$$
+  ^(build-aux/cfg\.mk|src/util/virutil\.c)$$
 
 exclude_file_name_regexp--sc_prohibit_pthread_create = \
-  ^(cfg\.mk|src/util/virthread\.c|tests/.*)$$
+  ^(build-aux/cfg\.mk|src/util/virthread\.c|tests/.*)$$
 
 exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
   ^tests/virtestmock.c$$
@@ -1354,3 +1360,6 @@ exclude_file_name_regexp--sc_prohibit_dirent_d_type = \
 
 exclude_file_name_regexp--sc_prohibit_strcmp = \
   ^(tools/nss/libvirt_nss.*\.c|tools/virt-login-shell\.c)
+
+exclude_file_name_regexp--sc_prohibit_backslash_alignment = \
+  ^build-aux/maint\.mk$$
diff --git a/maint.mk b/build-aux/maint.mk
similarity index 99%
rename from maint.mk
rename to build-aux/maint.mk
index 16e936022c..e570e45462 100644
--- a/maint.mk
+++ b/build-aux/maint.mk
@@ -19,7 +19,7 @@
 
 # This is reported not to work with make-3.79.1
 # ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
-ME := maint.mk
+ME := $(_build-aux)/maint.mk
 
 # These variables ought to be defined through the configure.ac section
 # of the module description. But some packages import this file directly,
@@ -159,8 +159,7 @@ export LC_ALL = C
 ## Sanity checks.  ##
 ## --------------- ##
 
-ifneq ($(_gl-Makefile),)
-_cfg_mk := $(wildcard $(srcdir)/cfg.mk)
+_cfg_mk := $(wildcard $(srcdir)/$(_build-aux)/cfg.mk)
 
 # Collect the names of rules starting with 'sc_'.
 syntax-check-rules := $(sort $(shell $(SED) -n \
@@ -201,7 +200,6 @@ local-check :=								\
     $(filter-out $(local-checks-to-skip), $(local-checks-available)))
 
 syntax-check: $(local-check)
-endif
 
 # _sc_search_regexp
 #
@@ -906,7 +904,7 @@ 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);; *) \
+	  case $$(echo all: | $(GREP) -l -f - $(abs_top_builddir)/Makefile) in $(abs_top_builddir)/Makefile);; *) \
 	    echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;;	\
 	  esac;								\
 	  regex=$$($(def_sym_regex)); export regex;			\
@@ -1429,7 +1427,7 @@ announcement: NEWS ChangeLog $(rel-files)
 release-commit:
 	$(AM_V_GEN)cd $(srcdir)				\
 	  && $(_build-aux)/do-release-commit-and-tag	\
-	       -C $(abs_builddir) $(RELEASE)
+	       -C $(abs_top_builddir) $(RELEASE)
 
 ## ---------------- ##
 ## Updating files.  ##
@@ -1551,7 +1549,7 @@ web-manual:
 	  && { 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' \
+	     -o '$(abs_top_builddir)/doc/manual' \
 	     --email $(PACKAGE_BUGREPORT) $(PACKAGE) \
 	    "$(PACKAGE_NAME) - $(manual_title)"
 	$(AM_V_at)echo " *** Upload the doc/manual directory to web-cvs."
@@ -1559,7 +1557,7 @@ web-manual:
 .PHONY: web-manual-update
 web-manual-update:
 	$(AM_V_GEN)cd $(srcdir) \
-	  && $(_build-aux)/gnu-web-doc-update -C $(abs_builddir)
+	  && $(_build-aux)/gnu-web-doc-update -C $(abs_top_builddir)
 
 
 # Code Coverage
@@ -1662,7 +1660,7 @@ _gl_TS_dir ?= src
 ALL_RECURSIVE_TARGETS += sc_tight_scope
 sc_tight_scope: tight-scope.mk
 	@fail=0;							\
-	if ! $(GREP) '^ *export _gl_TS_headers *=' $(srcdir)/cfg.mk	\
+	if ! $(GREP) '^ *export _gl_TS_headers *=' $(_build-aux)/cfg.mk	\
 		> /dev/null						\
 	   && ! $(GREP) -w noinst_HEADERS $(srcdir)/$(_gl_TS_dir)/Makefile.am \
 		> /dev/null 2>&1; then					\
@@ -1670,7 +1668,7 @@ sc_tight_scope: tight-scope.mk
 	else								\
 	    $(MAKE) -s -C $(_gl_TS_dir)					\
 		-f Makefile						\
-		-f $(abs_top_srcdir)/cfg.mk				\
+		-f $(_build-aux)/cfg.mk				\
 		-f $(abs_top_builddir)/$<				\
 	      _gl_tight_scope						\
 		|| fail=1;						\
-- 
2.21.0




More information about the libvir-list mailing list