]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
build: no recursive-make for "include/**/Makefile.am"
authorThomas Haller <thaller@redhat.com>
Thu, 19 Oct 2023 13:00:01 +0000 (15:00 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 2 Nov 2023 10:48:30 +0000 (11:48 +0100)
Switch from recursive-make to a single top-level Makefile. This is the
first step, the following patches will continue this.

Unlike meson's subdir() or C's #include, automake's SUBDIRS= does not
include a Makefile. Instead, it calls `make -C $dir`.

  https://www.gnu.org/software/make/manual/html_node/Recursion.html
  https://www.gnu.org/software/automake/manual/html_node/Subdirectories.html

See also, "Recursive Make Considered Harmful".

  https://accu.org/journals/overload/14/71/miller_2004/

This has several problems, which we an avoid with a single Makefile:

- recursive-make is harder to maintain and understand as a whole.
  Recursive-make makes sense, when there are truly independent
  sub-projects. Which is not the case here. The project needs to be
  considered as a whole and not one directory at a time. When
  we add unit tests (which we should), those would reside in separate
  directories but have dependencies between directories. With a single
  Makefile, we see all at once. The build setup has an inherent complexity,
  and that complexity is not necessarily reduced by splitting it into more files.
  On the contrary it helps to have it all in once place, provided that it's
  sensibly structured, named and organized.

- typing `make` prints irrelevant "Entering directory" messages. So much
  so, that at the end of the build, the terminal is filled with such
  messages and we have to scroll to see what even happened.

- with recursive-make, during build we see:

    make[3]: Entering directory '.../nftables/src'
      CC       meta.lo
    meta.c:13:2: error: #warning hello test [-Werror=cpp]
       13 | #warning hello test
          |  ^~~~~~~

  With a single Makefile we get

      CC       src/meta.lo
    src/meta.c:13:2: error: #warning hello test [-Werror=cpp]
       13 | #warning hello test
          |  ^~~~~~~

  This shows the full filename -- assuming that the developer works from
  the top level directory. The full name is useful, for example to
  copy+paste into the terminal.

- single Makefile is also faster:

    $ make && perf stat -r 200 -B make -j

  I measure 35msec vs. 80msec.

- recursive-make limits parallel make. You have to craft the SUBDIRS= in
  the correct order. The dependencies between directories are limited,
  as make only sees "LDADD = $(top_builddir)/src/libnftables.la" and
  not the deeper dependencies for the library.

- I presume, some people like recursive-make because of `make -C $subdir`
  to only rebuild one directory. Rebuilding the entire tree is already very
  fast, so this feature seems not relevant. Also, as dependency handling
  is limited, we might wrongly not rebuild a target. For example,

        make check
        touch src/meta.c
        make -C examples check

  does not rebuild "examples/nft-json-file".
  What we now can do with single Makefile (and better than before), is
  `make examples/nft-json-file`, which works as desired and rebuilds all
  dependencies.

Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Makefile.am
configure.ac
include/Makefile.am [deleted file]
include/linux/Makefile.am [deleted file]
include/linux/netfilter/Makefile.am [deleted file]
include/linux/netfilter_arp/Makefile.am [deleted file]
include/linux/netfilter_bridge/Makefile.am [deleted file]
include/linux/netfilter_ipv4/Makefile.am [deleted file]
include/linux/netfilter_ipv6/Makefile.am [deleted file]
include/nftables/Makefile.am [deleted file]

index 84c3c366b86a91d96a8201f2212b6aa95ab9590d..bfc64ebbed710c7955ccfdb6f26c10357c362d8f 100644 (file)
@@ -1,7 +1,76 @@
-ACLOCAL_AMFLAGS        = -I m4
+ACLOCAL_AMFLAGS = -I m4
 
-SUBDIRS =      src     \
-               include \
+pkginclude_HEADERS = \
+       include/nftables/libnftables.h \
+       $(NULL)
+
+noinst_HEADERS = \
+       \
+       include/linux/netfilter.h \
+       include/linux/netfilter/nf_conntrack_common.h \
+       include/linux/netfilter/nf_conntrack_tuple_common.h \
+       include/linux/netfilter/nf_log.h \
+       include/linux/netfilter/nf_nat.h \
+       include/linux/netfilter/nf_synproxy.h \
+       include/linux/netfilter/nf_tables.h \
+       include/linux/netfilter/nf_tables_compat.h \
+       include/linux/netfilter/nfnetlink.h \
+       include/linux/netfilter/nfnetlink_hook.h \
+       include/linux/netfilter/nfnetlink_osf.h \
+       include/linux/netfilter_arp.h \
+       include/linux/netfilter_arp/arp_tables.h \
+       include/linux/netfilter_bridge.h \
+       include/linux/netfilter_bridge/ebtables.h \
+       include/linux/netfilter_decnet.h \
+       include/linux/netfilter_ipv4.h \
+       include/linux/netfilter_ipv4/ip_tables.h \
+       include/linux/netfilter_ipv6.h \
+       include/linux/netfilter_ipv6/ip6_tables.h \
+       \
+       include/cache.h \
+       include/cli.h \
+       include/cmd.h \
+       include/ct.h \
+       include/datatype.h \
+       include/dccpopt.h \
+       include/erec.h \
+       include/expression.h \
+       include/exthdr.h \
+       include/fib.h \
+       include/gmputil.h \
+       include/hash.h \
+       include/headers.h \
+       include/iface.h \
+       include/intervals.h \
+       include/ipopt.h \
+       include/json.h \
+       include/list.h \
+       include/meta.h \
+       include/mini-gmp.h \
+       include/misspell.h \
+       include/mnl.h \
+       include/netlink.h \
+       include/nft.h \
+       include/nftables.h \
+       include/numgen.h \
+       include/osf.h \
+       include/owner.h \
+       include/parser.h \
+       include/payload.h \
+       include/proto.h \
+       include/rt.h \
+       include/rule.h \
+       include/sctp_chunk.h \
+       include/socket.h \
+       include/statement.h \
+       include/tcpopt.h \
+       include/utils.h \
+       include/xfrm.h \
+       include/xt.h \
+       \
+       $(NULL)
+
+SUBDIRS =      src     \
                files   \
                doc     \
                examples\
index 7bd33bdcc2cf371c0b31fc3b05055e6add83ef41..67ca50fddf67a5ecfb025bf24e2d376b6d0b4c6c 100644 (file)
@@ -118,14 +118,6 @@ AC_CONFIG_FILES([                                  \
                Makefile                                \
                libnftables.pc                          \
                src/Makefile                            \
-               include/Makefile                        \
-               include/nftables/Makefile               \
-               include/linux/Makefile                  \
-               include/linux/netfilter/Makefile        \
-               include/linux/netfilter_arp/Makefile    \
-               include/linux/netfilter_bridge/Makefile \
-               include/linux/netfilter_ipv4/Makefile   \
-               include/linux/netfilter_ipv6/Makefile   \
                files/Makefile                          \
                files/examples/Makefile                 \
                files/nftables/Makefile                 \
diff --git a/include/Makefile.am b/include/Makefile.am
deleted file mode 100644 (file)
index 162807b..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-SUBDIRS =              linux           \
-                       nftables
-
-noinst_HEADERS =       cli.h           \
-                       cache.h         \
-                       cmd.h           \
-                       datatype.h      \
-                       dccpopt.h       \
-                       nft.h   \
-                       expression.h    \
-                       fib.h           \
-                       hash.h          \
-                       intervals.h     \
-                       ipopt.h         \
-                       json.h          \
-                       mini-gmp.h      \
-                       gmputil.h       \
-                       iface.h         \
-                       mnl.h           \
-                       nftables.h      \
-                       payload.h       \
-                       tcpopt.h        \
-                       statement.h     \
-                       ct.h            \
-                       erec.h          \
-                       exthdr.h        \
-                       headers.h       \
-                       list.h          \
-                       meta.h          \
-                       misspell.h      \
-                       numgen.h        \
-                       netlink.h       \
-                       osf.h           \
-                       owner.h         \
-                       parser.h        \
-                       proto.h         \
-                       sctp_chunk.h    \
-                       socket.h        \
-                       rule.h          \
-                       rt.h            \
-                       utils.h         \
-                       xfrm.h          \
-                       xt.h
diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am
deleted file mode 100644 (file)
index eb9fc4e..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-SUBDIRS =              netfilter               \
-                       netfilter_arp           \
-                       netfilter_bridge        \
-                       netfilter_ipv4          \
-                       netfilter_ipv6
-
-noinst_HEADERS =       netfilter_arp.h         \
-                       netfilter_bridge.h      \
-                       netfilter_decnet.h      \
-                       netfilter.h             \
-                       netfilter_ipv4.h        \
-                       netfilter_ipv6.h
diff --git a/include/linux/netfilter/Makefile.am b/include/linux/netfilter/Makefile.am
deleted file mode 100644 (file)
index 22f66a7..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-noinst_HEADERS =       nf_conntrack_common.h           \
-                       nf_conntrack_tuple_common.h     \
-                       nf_log.h                        \
-                       nf_nat.h                        \
-                       nf_tables.h                     \
-                       nf_tables_compat.h              \
-                       nf_synproxy.h                   \
-                       nfnetlink_osf.h                 \
-                       nfnetlink_hook.h                \
-                       nfnetlink.h
diff --git a/include/linux/netfilter_arp/Makefile.am b/include/linux/netfilter_arp/Makefile.am
deleted file mode 100644 (file)
index 0a16c1a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-noinst_HEADERS =       arp_tables.h
diff --git a/include/linux/netfilter_bridge/Makefile.am b/include/linux/netfilter_bridge/Makefile.am
deleted file mode 100644 (file)
index d2e8b38..0000000
+++ /dev/null
@@ -1 +0,0 @@
-noinst_HEADERS =       ebtables.h
diff --git a/include/linux/netfilter_ipv4/Makefile.am b/include/linux/netfilter_ipv4/Makefile.am
deleted file mode 100644 (file)
index fec4253..0000000
+++ /dev/null
@@ -1 +0,0 @@
-noinst_HEADERS =       ip_tables.h
diff --git a/include/linux/netfilter_ipv6/Makefile.am b/include/linux/netfilter_ipv6/Makefile.am
deleted file mode 100644 (file)
index bec6c3f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-noinst_HEADERS =       ip6_tables.h
diff --git a/include/nftables/Makefile.am b/include/nftables/Makefile.am
deleted file mode 100644 (file)
index 5cfb0c6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-pkginclude_HEADERS = libnftables.h