Eric Blake
2019-Jun-27 16:43 UTC
[Libguestfs] [libnbd PATCH] maint: Use $(NULL) for all Makefile.am macro lists
This borrows from a trick in libvirt - by defining $(NULL) to expand to an empty string, we can more consistently write multi-line macros where all useful lines terminate with \, making it easier to add/remove lines without worrying about whether \ needs to be touched up on neighboring lines. --- Looks big, but is fairly mechanical. I'm also doing a similar patch for nbdkit, where it would have prevented the typo fixed in commit 268e7816. Makefile.am | 6 ++-- common-rules.mk | 3 ++ docs/Makefile.am | 9 ++++-- examples/Makefile.am | 51 ++++++++++++++++++++---------- generator/Makefile.am | 6 ++-- include/Makefile.am | 3 +- interop/Makefile.am | 24 +++++++++----- lib/Makefile.am | 21 ++++++++---- ocaml/Makefile.am | 15 ++++++--- ocaml/examples/Makefile.am | 3 +- sh/Makefile.am | 3 +- tests/Makefile.am | 65 ++++++++++++++++++++++++-------------- 12 files changed, 139 insertions(+), 70 deletions(-) diff --git a/Makefile.am b/Makefile.am index d758378..6a0f4bd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,8 @@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = \ .dir-locals.el \ .gitignore \ - html/pod.css + html/pod.css \ + $(NULL) SUBDIRS = \ generator \ @@ -36,7 +37,8 @@ SUBDIRS = \ sh \ ocaml \ ocaml/examples \ - interop + interop \ + $(NULL) noinst_SCRIPTS = run diff --git a/common-rules.mk b/common-rules.mk index 498d221..eb8c92e 100644 --- a/common-rules.mk +++ b/common-rules.mk @@ -18,6 +18,9 @@ # common-rules.mk is included in every Makefile.am. # subdir-rules.mk is included only in subdirectories. +# Convenient list terminator +NULL + CLEANFILES = *~ $(generator_built): $(top_builddir)/generator/stamp-generator diff --git a/docs/Makefile.am b/docs/Makefile.am index f002541..234fff1 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -18,17 +18,20 @@ include $(top_srcdir)/subdir-rules.mk generator_built = \ - libnbd-api.pod + libnbd-api.pod \ + $(NULL) EXTRA_DIST = \ $(generator_built) \ - libnbd.pod + libnbd.pod \ + $(NULL) if HAVE_POD man_MANS = \ libnbd.3 \ - libnbd-api.3 + libnbd-api.3 \ + $(NULL) CLEANFILES += $(man_MANS) libnbd.3: libnbd.pod diff --git a/examples/Makefile.am b/examples/Makefile.am index b933873..f0d03f1 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -23,42 +23,59 @@ noinst_PROGRAMS = \ batched-read-write \ simple-fetch-first-sector \ simple-reads-and-writes \ - threaded-reads-and-writes + threaded-reads-and-writes \ + $(NULL) simple_fetch_first_sector_SOURCES = \ - simple-fetch-first-sector.c + simple-fetch-first-sector.c \ + $(NULL) simple_fetch_first_sector_CPPFLAGS = \ - -I$(top_srcdir)/include + -I$(top_srcdir)/include \ + $(NULL) simple_fetch_first_sector_CFLAGS = \ - $(WARNINGS_CFLAGS) + $(WARNINGS_CFLAGS) \ + $(NULL) simple_fetch_first_sector_LDADD = \ - $(top_builddir)/lib/libnbd.la + $(top_builddir)/lib/libnbd.la \ + $(NULL) simple_reads_and_writes_SOURCES = \ - simple-reads-and-writes.c + simple-reads-and-writes.c \ + $(NULL) simple_reads_and_writes_CPPFLAGS = \ - -I$(top_srcdir)/include + -I$(top_srcdir)/include \ + $(NULL) simple_reads_and_writes_CFLAGS = \ - $(WARNINGS_CFLAGS) + $(WARNINGS_CFLAGS) \ + $(NULL) simple_reads_and_writes_LDADD = \ - $(top_builddir)/lib/libnbd.la + $(top_builddir)/lib/libnbd.la \ + $(NULL) threaded_reads_and_writes_SOURCES = \ - threaded-reads-and-writes.c + threaded-reads-and-writes.c \ + $(NULL) threaded_reads_and_writes_CPPFLAGS = \ - -I$(top_srcdir)/include + -I$(top_srcdir)/include \ + $(NULL) threaded_reads_and_writes_CFLAGS = \ $(WARNINGS_CFLAGS) \ - $(PTHREAD_CFLAGS) + $(PTHREAD_CFLAGS) \ + $(NULL) threaded_reads_and_writes_LDADD = \ $(top_builddir)/lib/libnbd.la \ - $(PTHREAD_LIBS) + $(PTHREAD_LIBS) \ + $(NULL) batched_read_write_SOURCES = \ - batched-read-write.c + batched-read-write.c \ + $(NULL) batched_read_write_CPPFLAGS = \ - -I$(top_srcdir)/include + -I$(top_srcdir)/include \ + $(NULL) batched_read_write_CFLAGS = \ - $(WARNINGS_CFLAGS) + $(WARNINGS_CFLAGS) \ + $(NULL) batched_read_write_LDADD = \ - $(top_builddir)/lib/libnbd.la + $(top_builddir)/lib/libnbd.la \ + $(NULL) diff --git a/generator/Makefile.am b/generator/Makefile.am index 4f4e685..c20184a 100644 --- a/generator/Makefile.am +++ b/generator/Makefile.am @@ -35,11 +35,13 @@ states_code = \ states-oldstyle.c \ states-reply-simple.c \ states-reply-structured.c \ - states-reply.c + states-reply.c \ + $(NULL) EXTRA_DIST = \ generator \ - $(states_code) + $(states_code) \ + $(NULL) if HAVE_OCAML_TOPLEVEL diff --git a/include/Makefile.am b/include/Makefile.am index cbeb560..e786447 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -24,4 +24,5 @@ EXTRA_DIST = $(generator_built) BUILT_SOURCES = $(generator_built) include_HEADERS = \ - libnbd.h + libnbd.h \ + $(NULL) diff --git a/interop/Makefile.am b/interop/Makefile.am index cf36e34..1d2d187 100644 --- a/interop/Makefile.am +++ b/interop/Makefile.am @@ -19,7 +19,8 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ dirty-bitmap.sh \ - structured-read.sh + structured-read.sh \ + $(NULL) TESTS_ENVIRONMENT = LIBNBD_DEBUG=1 LOG_COMPILER = $(top_builddir)/run @@ -49,11 +50,13 @@ check_PROGRAMS += \ interop-qemu-nbd-tls-certs \ interop-qemu-nbd-tls-psk \ dirty-bitmap \ - structured-read + structured-read \ + $(NULL) TESTS += \ interop-qemu-nbd \ dirty-bitmap.sh \ - structured-read.sh + structured-read.sh \ + $(NULL) # tls tests assume the pre-existence of files created in ../tests/Makefile.am, # so we can only run them under the same conditions used there @@ -62,11 +65,13 @@ if HAVE_NBDKIT if HAVE_GNUTLS if HAVE_CERTTOOL TESTS += \ - interop-qemu-nbd-tls-certs + interop-qemu-nbd-tls-certs \ + $(NULL) endif if HAVE_PSKTOOL TESTS += \ - interop-qemu-nbd-tls-psk + interop-qemu-nbd-tls-psk \ + $(NULL) endif endif endif @@ -77,7 +82,8 @@ interop_qemu_nbd_CPPFLAGS = \ -DSERVE_OVER_TCP=1 \ -DSERVER=\"$(QEMU_NBD)\" \ -DSERVER_PARAMS='"-f", "raw", "-x", "/", "-p", port_str, tmpfile' \ - -DEXPORT_NAME='"/"' + -DEXPORT_NAME='"/"' \ + $(NULL) interop_qemu_nbd_CFLAGS = $(WARNINGS_CFLAGS) interop_qemu_nbd_LDADD = $(top_builddir)/lib/libnbd.la @@ -89,7 +95,8 @@ interop_qemu_nbd_tls_certs_CPPFLAGS = \ -DSERVER=\"$(QEMU_NBD)\" \ -DSERVER_PARAMS='"--object", "tls-creds-x509,id=tls0,endpoint=server,dir=$(abs_top_builddir)/tests/pki", "--tls-creds", "tls0", "-f", "raw", "-x", "/", "-p", port_str, tmpfile' \ -DEXPORT_NAME='"/"' \ - -DCERTS=1 + -DCERTS=1 \ + $(NULL) interop_qemu_nbd_tls_certs_CFLAGS = $(WARNINGS_CFLAGS) interop_qemu_nbd_tls_certs_LDADD = $(top_builddir)/lib/libnbd.la @@ -101,7 +108,8 @@ interop_qemu_nbd_tls_psk_CPPFLAGS = \ -DSERVER=\"$(QEMU_NBD)\" \ -DSERVER_PARAMS='"--object", "tls-creds-psk,id=tls0,endpoint=server,dir=$(abs_top_builddir)/tests", "--tls-creds", "tls0", "-f", "raw", "-x", "/", "-p", port_str, tmpfile' \ -DEXPORT_NAME='"/"' \ - -DPSK=1 + -DPSK=1 \ + $(NULL) interop_qemu_nbd_tls_psk_CFLAGS = $(WARNINGS_CFLAGS) interop_qemu_nbd_tls_psk_LDADD = $(top_builddir)/lib/libnbd.la diff --git a/lib/Makefile.am b/lib/Makefile.am index 72d2d0b..7939375 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -21,11 +21,13 @@ generator_built = \ api.c \ states.c \ states.h \ - unlocked.h + unlocked.h \ + $(NULL) EXTRA_DIST = \ $(generator_built) \ - libnbd.syms + libnbd.syms \ + $(NULL) lib_LTLIBRARIES = libnbd.la @@ -51,22 +53,27 @@ libnbd_la_SOURCES = \ states.c \ states.h \ unlocked.h \ - utils.c + utils.c \ + $(NULL) libnbd_la_CPPFLAGS = \ -I$(top_srcdir)/include \ - -Dsysconfdir=\"$(sysconfdir)\" + -Dsysconfdir=\"$(sysconfdir)\" \ + $(NULL) libnbd_la_CFLAGS = \ $(WARNINGS_CFLAGS) \ $(PTHREAD_CFLAGS) \ $(GNUTLS_CFLAGS) \ - $(LIBXML2_CFLAGS) + $(LIBXML2_CFLAGS) \ + $(NULL) libnbd_la_LIBADD = \ $(GNUTLS_LIBS) \ - $(LIBXML2_LIBS) + $(LIBXML2_LIBS) \ + $(NULL) libnbd_la_LDFLAGS = \ $(PTHREAD_LIBS) \ -Wl,--version-script=$(srcdir)/libnbd.syms \ - -version-info 0:0:0 + -version-info 0:0:0 \ + $(NULL) # pkg-config / pkgconf diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 0d876bb..bae9e58 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -20,10 +20,12 @@ include $(top_srcdir)/subdir-rules.mk generator_built = \ NBD.mli \ NBD.ml \ - nbd-c.c + nbd-c.c \ + $(NULL) EXTRA_DIST = \ - $(generator_built) + $(generator_built) \ + $(NULL) CLEANFILES += *.annot *.cmi *.cmo *.cmx *.o *.a *.so @@ -71,18 +73,21 @@ endif libnbdocaml_a_CPPFLAGS = \ -I$(top_builddir) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml \ -I$(top_srcdir)/include \ - -DCAML_NAME_SPACE + -DCAML_NAME_SPACE \ + $(NULL) libnbdocaml_a_CFLAGS = \ $(WARNINGS_CFLAGS) \ - -fPIC + -fPIC \ + $(NULL) libnbdocaml_a_SOURCES = \ nbd-c.c \ nbd-c.h \ buffer.c \ handle.c \ - helpers.c + helpers.c \ + $(NULL) %.bc: %.cmo mlnbd.cma $(top_builddir)/libtool -dlopen $(top_builddir)/lib/.libs/libnbd.la --mode=execute \ diff --git a/ocaml/examples/Makefile.am b/ocaml/examples/Makefile.am index 6488f62..7867e14 100644 --- a/ocaml/examples/Makefile.am +++ b/ocaml/examples/Makefile.am @@ -19,7 +19,8 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ LICENSE-FOR-EXAMPLES \ - extents.ml + extents.ml \ + $(NULL) CLEANFILES += *.annot *.cmi *.cmo *.cmx *.o *.a *.so *.bc *.opt diff --git a/sh/Makefile.am b/sh/Makefile.am index 3a30ccc..505f751 100644 --- a/sh/Makefile.am +++ b/sh/Makefile.am @@ -20,7 +20,8 @@ include $(top_srcdir)/subdir-rules.mk EXTRA_DIST = \ nbdsh.pod \ examples/LICENSE-FOR-EXAMPLES \ - examples/hexdump.sh + examples/hexdump.sh \ + $(NULL) if HAVE_PYTHON diff --git a/tests/Makefile.am b/tests/Makefile.am index 2a0acf0..149f890 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -23,7 +23,8 @@ CLEANFILES += \ connect-unix.sock \ connect-uri-tcp.pid \ connect-uri-unix.pid \ - connect-uri-unix.sock + connect-uri-unix.sock \ + $(NULL) EXTRA_DIST = \ aio-parallel.sh \ @@ -35,7 +36,8 @@ EXTRA_DIST = \ make-pki.sh \ meta-base-allocation.sh \ synch-parallel.sh \ - synch-parallel-tls.sh + synch-parallel-tls.sh \ + $(NULL) if HAVE_NBDKIT @@ -66,9 +68,10 @@ check_PROGRAMS = \ aio-parallel \ aio-parallel-load \ synch-parallel \ - meta-base-allocation -# can-cache-flag -# can-not-cache-flag + meta-base-allocation \ +# can-cache-flag \ +# can-not-cache-flag \ + $(NULL) # Make sure that $srcdir is available to tests. # Enable debug in all tests. @@ -101,9 +104,10 @@ TESTS = \ aio-parallel.sh \ aio-parallel-load.sh \ synch-parallel.sh \ - meta-base-allocation -# can-cache-flag -# can-not-cache-flag + meta-base-allocation \ +# can-cache-flag \ +# can-not-cache-flag \ + $(NULL) errors_SOURCES = errors.c errors_CPPFLAGS = -I$(top_srcdir)/include @@ -132,55 +136,64 @@ read_write_flag_LDADD = $(top_builddir)/lib/libnbd.la can_flush_flag_SOURCES = eflags.c can_flush_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=can_flush + -I$(top_srcdir)/include -Dflag=can_flush \ + $(NULL) can_flush_flag_CFLAGS = $(WARNINGS_CFLAGS) can_flush_flag_LDADD = $(top_builddir)/lib/libnbd.la can_not_flush_flag_SOURCES = eflags.c can_not_flush_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=can_flush -Dvalue=false + -I$(top_srcdir)/include -Dflag=can_flush -Dvalue=false \ + $(NULL) can_not_flush_flag_CFLAGS = $(WARNINGS_CFLAGS) can_not_flush_flag_LDADD = $(top_builddir)/lib/libnbd.la can_fua_flag_SOURCES = eflags.c can_fua_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=can_fua -Dvalue=native + -I$(top_srcdir)/include -Dflag=can_fua -Dvalue=native \ + $(NULL) can_fua_flag_CFLAGS = $(WARNINGS_CFLAGS) can_fua_flag_LDADD = $(top_builddir)/lib/libnbd.la can_not_fua_flag_SOURCES = eflags.c can_not_fua_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=can_fua -Dvalue=none + -I$(top_srcdir)/include -Dflag=can_fua -Dvalue=none \ + $(NULL) can_not_fua_flag_CFLAGS = $(WARNINGS_CFLAGS) can_not_fua_flag_LDADD = $(top_builddir)/lib/libnbd.la is_rotational_flag_SOURCES = eflags.c is_rotational_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=is_rotational + -I$(top_srcdir)/include -Dflag=is_rotational \ + $(NULL) is_rotational_flag_CFLAGS = $(WARNINGS_CFLAGS) is_rotational_flag_LDADD = $(top_builddir)/lib/libnbd.la is_not_rotational_flag_SOURCES = eflags.c is_not_rotational_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=is_rotational -Dvalue=false + -I$(top_srcdir)/include -Dflag=is_rotational -Dvalue=false \ + $(NULL) is_not_rotational_flag_CFLAGS = $(WARNINGS_CFLAGS) is_not_rotational_flag_LDADD = $(top_builddir)/lib/libnbd.la can_trim_flag_SOURCES = eflags.c can_trim_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=can_trim + -I$(top_srcdir)/include -Dflag=can_trim \ + $(NULL) can_trim_flag_CFLAGS = $(WARNINGS_CFLAGS) can_trim_flag_LDADD = $(top_builddir)/lib/libnbd.la can_not_trim_flag_SOURCES = eflags.c can_not_trim_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=can_trim -Dvalue=false + -I$(top_srcdir)/include -Dflag=can_trim -Dvalue=false \ + $(NULL) can_not_trim_flag_CFLAGS = $(WARNINGS_CFLAGS) can_not_trim_flag_LDADD = $(top_builddir)/lib/libnbd.la can_zero_flag_SOURCES = eflags.c can_zero_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=can_zero + -I$(top_srcdir)/include -Dflag=can_zero \ + $(NULL) can_zero_flag_CFLAGS = $(WARNINGS_CFLAGS) can_zero_flag_LDADD = $(top_builddir)/lib/libnbd.la # Note: can't test not-zero case because nbdkit emulates zero if the @@ -188,26 +201,30 @@ can_zero_flag_LDADD = $(top_builddir)/lib/libnbd.la can_multi_conn_flag_SOURCES = eflags.c can_multi_conn_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=can_multi_conn + -I$(top_srcdir)/include -Dflag=can_multi_conn \ + $(NULL) can_multi_conn_flag_CFLAGS = $(WARNINGS_CFLAGS) can_multi_conn_flag_LDADD = $(top_builddir)/lib/libnbd.la can_not_multi_conn_flag_SOURCES = eflags.c can_not_multi_conn_flag_CPPFLAGS = \ - -I$(top_srcdir)/include -Dflag=can_multi_conn -Dvalue=false + -I$(top_srcdir)/include -Dflag=can_multi_conn -Dvalue=false \ + $(NULL) can_not_multi_conn_flag_CFLAGS = $(WARNINGS_CFLAGS) can_not_multi_conn_flag_LDADD = $(top_builddir)/lib/libnbd.la # Waiting for nbdkit to add support for can_cache. #can_cache_flag_SOURCES = eflags.c #can_cache_flag_CPPFLAGS = \ -# -I$(top_srcdir)/include -Dflag=can_cache -Dvalue=native +# -I$(top_srcdir)/include -Dflag=can_cache -Dvalue=native \ +# $(NULL) #can_cache_flag_CFLAGS = $(WARNINGS_CFLAGS) #can_cache_flag_LDADD = $(top_builddir)/lib/libnbd.la # #can_not_cache_flag_SOURCES = eflags.c #can_not_cache_flag_CPPFLAGS = \ -# -I$(top_srcdir)/include -Dflag=can_cache -Dvalue=none +# -I$(top_srcdir)/include -Dflag=can_cache -Dvalue=none \ +# $(NULL) #can_not_cache_flag_CFLAGS = $(WARNINGS_CFLAGS) #can_not_cache_flag_LDADD = $(top_builddir)/lib/libnbd.la @@ -283,12 +300,14 @@ check_PROGRAMS += \ connect-tls-psk \ aio-parallel-tls \ aio-parallel-load-tls \ - synch-parallel-tls + synch-parallel-tls \ + $(NULL) TESTS += \ connect-tls-psk \ aio-parallel-tls.sh \ aio-parallel-load-tls.sh \ - synch-parallel-tls.sh + synch-parallel-tls.sh \ + $(NULL) check_DATA += keys.psk connect_tls_psk_SOURCES = connect-tls.c -- 2.20.1
Richard W.M. Jones
2019-Jun-27 19:48 UTC
Re: [Libguestfs] [libnbd PATCH] maint: Use $(NULL) for all Makefile.am macro lists
ACK this one too Thanks :-) Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Possibly Parallel Threads
- [PATCH libnbd 4/5] interop: Add -DTLS_MODE to the test.
- [libnbd PATCH 1/1] api: Add support for FAST_ZERO flag
- [PATCH libnbd 5/5] interop: Add tests of nbdkit + LIBNBD_TLS_ALLOW.
- [libnbd PATCH] api: Add way to avoid structured replies
- [PATCH libnbd v2 2/2] api: Implement local command with systemd socket activation.