From: Thomas Haller <thaller@redhat.com>
To: NetFilter <netfilter-devel@vger.kernel.org>
Cc: Thomas Haller <thaller@redhat.com>
Subject: [PATCH nft 0/6] no recursive make
Date: Fri, 25 Aug 2023 13:27:32 +0200 [thread overview]
Message-ID: <20230825113042.2607496-1-thaller@redhat.com> (raw)
Switch from recursive make to a single toplevel Makefile.
[Quote commit message from first commit]
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
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. There is a certain complexity to the build
setup, that complexity is not automatically reduced by splitting it into
more files. On the contrary it helps to have it all at once place,
provided that it's still 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 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 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.
Thomas Haller (6):
build: drop recursive make for "include/**/Makefile.am"
build: drop recursive make for "py/Makefile.am"
build: drop recursive make for "files/**/Makefile.am"
build: drop recursive make for "src/Makefile.am"
build: drop recursive make for "examples/Makefile.am"
build: drop recursive make for "doc/Makefile.am"
Make_global.am | 21 --
Makefile.am | 408 ++++++++++++++++++++-
configure.ac | 16 -
doc/Makefile.am | 30 --
examples/Makefile.am | 6 -
files/Makefile.am | 3 -
files/examples/Makefile.am | 5 -
files/nftables/Makefile.am | 14 -
files/osf/Makefile.am | 2 -
include/Makefile.am | 42 ---
include/linux/Makefile.am | 12 -
include/linux/netfilter/Makefile.am | 10 -
include/linux/netfilter_arp/Makefile.am | 1 -
include/linux/netfilter_bridge/Makefile.am | 1 -
include/linux/netfilter_ipv4/Makefile.am | 1 -
include/linux/netfilter_ipv6/Makefile.am | 1 -
include/nftables/Makefile.am | 1 -
py/Makefile.am | 1 -
src/Makefile.am | 122 ------
19 files changed, 399 insertions(+), 298 deletions(-)
delete mode 100644 Make_global.am
delete mode 100644 doc/Makefile.am
delete mode 100644 examples/Makefile.am
delete mode 100644 files/Makefile.am
delete mode 100644 files/examples/Makefile.am
delete mode 100644 files/nftables/Makefile.am
delete mode 100644 files/osf/Makefile.am
delete mode 100644 include/Makefile.am
delete mode 100644 include/linux/Makefile.am
delete mode 100644 include/linux/netfilter/Makefile.am
delete mode 100644 include/linux/netfilter_arp/Makefile.am
delete mode 100644 include/linux/netfilter_bridge/Makefile.am
delete mode 100644 include/linux/netfilter_ipv4/Makefile.am
delete mode 100644 include/linux/netfilter_ipv6/Makefile.am
delete mode 100644 include/nftables/Makefile.am
delete mode 100644 py/Makefile.am
delete mode 100644 src/Makefile.am
--
2.41.0
next reply other threads:[~2023-08-25 11:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-25 11:27 Thomas Haller [this message]
2023-08-25 11:27 ` [PATCH nft 1/6] build: drop recursive make for "include/**/Makefile.am" Thomas Haller
2023-08-25 11:27 ` [PATCH nft 2/6] build: drop recursive make for "py/Makefile.am" Thomas Haller
2023-08-25 11:27 ` [PATCH nft 3/6] build: drop recursive make for "files/**/Makefile.am" Thomas Haller
2023-08-25 11:27 ` [PATCH nft 4/6] build: drop recursive make for "src/Makefile.am" Thomas Haller
2023-08-25 11:27 ` [PATCH nft 5/6] build: drop recursive make for "examples/Makefile.am" Thomas Haller
2023-09-08 11:09 ` Phil Sutter
2023-09-08 11:50 ` Thomas Haller
2023-08-25 11:27 ` [PATCH nft 6/6] build: drop recursive make for "doc/Makefile.am" Thomas Haller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230825113042.2607496-1-thaller@redhat.com \
--to=thaller@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).