no recursive make
Subsystems (3)
v2 cover no recursive make
This is a RESEND of v1. Only minor adjustments to the commit message and rebasing.
[Quote commit message from first patch]
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.
<<<<
Thomas Haller (7):
gitignore: ignore ".dirstamp" files
build: no recursive-make for "include/**/Makefile.am"
build: no recursive make for "py/Makefile.am"
build: no recursive make for "files/**/Makefile.am"
build: no recursive make for "src/Makefile.am"
build: no recursive make for "examples/Makefile.am"
build: no recursive make for "doc/Makefile.am"
.gitignore | 1 + Make_global.am | 21 -- Makefile.am | 415 ++++++++++++++++++++- 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 | 43 --- 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 | 123 ------ 20 files changed, 407 insertions(+), 300 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
Signature · 1 line
2.41.0
PATCH v2 1/7 gitignore: ignore ".dirstamp" files
Those will be generated by automake, once the recursive Makefiles are gone.
--- .gitignore | 1 + 1 file changed, 1 insertion(+)
.gitignore +1 -0
@@ -1,5 +1,6 @@ # Generated by autoconf/configure/automake *.m4 +.dirstamp Makefile Makefile.in stamp-h1
Signature · 1 line
2.41.0
PATCH v2 2/7 build: no recursive-make for "include/**/Makefile.am"
In reply to Thomas HallerSwitch 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.
--- Makefile.am | 75 +++++++++++++++++++++- configure.ac | 8 --- include/Makefile.am | 43 ------------- 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 - 10 files changed, 72 insertions(+), 81 deletions(-) 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
Makefile.am +72 -3
@@ -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\
configure.ac +0 -8
@@ -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 \
include/Makefile.am deleted +0 -43
43 lines not on this page · raw message
include/linux/Makefile.am deleted +0 -12
@@ -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
include/linux/netfilter/Makefile.am deleted +0 -10
@@ -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
include/linux/netfilter_arp/Makefile.am deleted +0 -1
@@ -1 +0,0 @@ -noinst_HEADERS = arp_tables.h
include/linux/netfilter_bridge/Makefile.am deleted +0 -1
@@ -1 +0,0 @@ -noinst_HEADERS = ebtables.h
include/linux/netfilter_ipv4/Makefile.am deleted +0 -1
@@ -1 +0,0 @@ -noinst_HEADERS = ip_tables.h
include/linux/netfilter_ipv6/Makefile.am deleted +0 -1
@@ -1 +0,0 @@ -noinst_HEADERS = ip6_tables.h
include/nftables/Makefile.am deleted +0 -1
@@ -1 +0,0 @@ -pkginclude_HEADERS = libnftables.h
Signature · 1 line
2.41.0
PATCH v2 3/7 build: no recursive make for "py/Makefile.am"
In reply to Thomas HallerMerge the Makefile.am under "py/" into the toplevel Makefile.am. This is a step in the effort of dropping recursive make.
--- Makefile.am | 20 ++++++++++++++++---- configure.ac | 1 - py/Makefile.am | 1 - 3 files changed, 16 insertions(+), 6 deletions(-) delete mode 100644 py/Makefile.am
Makefile.am +16 -4
@@ -1,5 +1,7 @@ ACLOCAL_AMFLAGS = -I m4 +EXTRA_DIST = + pkginclude_HEADERS = \ include/nftables/libnftables.h \ $(NULL)
@@ -73,11 +75,21 @@ noinst_HEADERS = \ SUBDIRS = src \ files \ doc \ - examples\ - py + examples + +EXTRA_DIST += \ + py/pyproject.toml \ + py/setup.cfg \ + py/setup.py \ + py/src/__init__.py \ + py/src/nftables.py \ + py/src/schema.json \ + $(NULL) -EXTRA_DIST = tests \ - files +EXTRA_DIST += \ + files \ + tests \ + $(NULL) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libnftables.pc
configure.ac +0 -1
@@ -123,7 +123,6 @@ AC_CONFIG_FILES([ \ files/nftables/Makefile \ files/osf/Makefile \ doc/Makefile \ - py/Makefile \ examples/Makefile \ ]) AC_OUTPUT
py/Makefile.am deleted +0 -1
@@ -1 +0,0 @@ -EXTRA_DIST = pyproject.toml setup.cfg setup.py src
Signature · 1 line
2.41.0
PATCH v2 4/7 build: no recursive make for "files/**/Makefile.am"
In reply to Thomas HallerMerge the Makefile.am under "files/" into the toplevel Makefile.am. This is a step in the effort of dropping recursive make.
--- Makefile.am | 43 +++++++++++++++++++++++++++++++++++++- configure.ac | 4 ---- files/Makefile.am | 3 --- files/examples/Makefile.am | 5 ----- files/nftables/Makefile.am | 14 ------------- files/osf/Makefile.am | 2 -- 6 files changed, 42 insertions(+), 29 deletions(-) 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
Makefile.am +42 -1
@@ -2,6 +2,8 @@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = +############################################################################### + pkginclude_HEADERS = \ include/nftables/libnftables.h \ $(NULL)
@@ -72,11 +74,48 @@ noinst_HEADERS = \ \ $(NULL) +############################################################################### + SUBDIRS = src \ - files \ doc \ examples +############################################################################### + +dist_pkgdata_DATA = \ + files/nftables/all-in-one.nft \ + files/nftables/arp-filter.nft \ + files/nftables/bridge-filter.nft \ + files/nftables/inet-filter.nft \ + files/nftables/inet-nat.nft \ + files/nftables/ipv4-filter.nft \ + files/nftables/ipv4-mangle.nft \ + files/nftables/ipv4-nat.nft \ + files/nftables/ipv4-raw.nft \ + files/nftables/ipv6-filter.nft \ + files/nftables/ipv6-mangle.nft \ + files/nftables/ipv6-nat.nft \ + files/nftables/ipv6-raw.nft \ + files/nftables/netdev-ingress.nft \ + $(NULL) + +pkgdocdir = ${docdir}/examples + +dist_pkgdoc_SCRIPTS = \ + files/examples/ct_helpers.nft \ + files/examples/load_balancing.nft \ + files/examples/secmark.nft \ + files/examples/sets_and_maps.nft \ + $(NULL) + +pkgsysconfdir = ${sysconfdir}/nftables/osf + +dist_pkgsysconf_DATA = \ + files/osf/pf.os \ + $(NULL) + +############################################################################### + EXTRA_DIST += \ py/pyproject.toml \ py/setup.cfg \
@@ -86,6 +125,8 @@ EXTRA_DIST += \ py/src/schema.json \ $(NULL) +############################################################################### + EXTRA_DIST += \ files \ tests \
configure.ac +0 -4
@@ -118,10 +118,6 @@ AC_CONFIG_FILES([ \ Makefile \ libnftables.pc \ src/Makefile \ - files/Makefile \ - files/examples/Makefile \ - files/nftables/Makefile \ - files/osf/Makefile \ doc/Makefile \ examples/Makefile \ ])
files/Makefile.am deleted +0 -3
@@ -1,3 +0,0 @@ -SUBDIRS = nftables \ - examples \ - osf
files/examples/Makefile.am deleted +0 -5
@@ -1,5 +0,0 @@ -pkgdocdir = ${docdir}/examples -dist_pkgdoc_SCRIPTS = ct_helpers.nft \ - load_balancing.nft \ - secmark.nft \ - sets_and_maps.nft
files/nftables/Makefile.am deleted +0 -14
@@ -1,14 +0,0 @@ -dist_pkgdata_DATA = all-in-one.nft \ - arp-filter.nft \ - bridge-filter.nft \ - inet-filter.nft \ - inet-nat.nft \ - ipv4-filter.nft \ - ipv4-mangle.nft \ - ipv4-nat.nft \ - ipv4-raw.nft \ - ipv6-filter.nft \ - ipv6-mangle.nft \ - ipv6-nat.nft \ - ipv6-raw.nft \ - netdev-ingress.nft
files/osf/Makefile.am deleted +0 -2
@@ -1,2 +0,0 @@ -pkgsysconfdir = ${sysconfdir}/nftables/osf -dist_pkgsysconf_DATA = pf.os
Signature · 1 line
2.41.0
Pablo Neira Ayuso
maintainerRe: [PATCH nft v2 4/7] build: no recursive make for "files/**/Makefile.am"
Makefile.am ACLOCAL_AMFLAGS = -I m4 · line 5
Quoted 9 lines · Thomas Haller
Makefile.am +1
-0@@ -2,6 +2,8 @@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = +###############################################################################
This marker shows that this Makefile.am is really getting too big.
Can we find a middle point?
I understand that a single Makefile for something as little as examples/Makefile.am is probably too much.
No revert please, something incremental, otherwise this looks like iptables' Makefile.
Thanks.
Pablo Neira Ayuso
maintainerRe: [PATCH nft v2 4/7] build: no recursive make for "files/**/Makefile.am"
Quoted 13 lines · Pablo Neira Ayuso
Makefile.am ACLOCAL_AMFLAGS = -I m4 · line 5
Quoted 9 lines · Thomas Haller
Makefile.am +1
-0@@ -2,6 +2,8 @@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = +###############################################################################This marker shows that this Makefile.am is really getting too big.
Quoted 7 lines
Can we find a middle point?
I understand that a single
Makefilefor something as little as examples/Makefile.am is probably too much.No revert please, something incremental, otherwise this looks like iptables'
Makefile.
Correction: Actually iptables' Makefiles show a better balance in how things are split accross Makefiles, with some possibilities to consolidate things but it looks much better these days.
Re: [PATCH nft v2 4/7] build: no recursive make for "files/**/Makefile.am"
Quoted 20 lines · Pablo Neira Ayuso
Quoted 19 lines · Pablo Neira Ayuso
Quoted 10 lines · Thomas Haller
Makefile.am +0
-0@@ -2,6 +2,8 @@ ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST =
+################################################################
###############This marker shows that this Makefile.am is really getting too big.
Can we find a middle point?
I understand that a single
Makefilefor something as little as examples/Makefile.am is probably too much.
Quoted 7 lines
Quoted 2 lines
No revert please, something incremental, otherwise this looks like iptables'
Makefile.Correction: Actually iptables' Makefiles show a better balance in how things are split accross Makefiles, with some possibilities to consolidate things but it looks much better these days.
Basically, what I said in the commit message of [1]. Do you disagree with anything specifically (or all of it?).
[1] https://git.netfilter.org/nftables/commit/?id=686d987706bf643f2fa75c1993a5720ad55e6df1
It's a matter of opinion entirely, but I disagree that the iptables' Makefiles are a positive example.
---
The ### line is only a visual aid. wc -l seems the better indication for when the file gets too big. A too big file, can be an indication that it's hard to maintain. After all, it's about maintainability, being understandable and correctness. But is it now really harder to understand, and would splitting it into multiple files make it better?
- see how you would add a new .c/.h file. Can you find it easily with the large Makefile?
- see how libnftables.la is build. Can you find it?
- see who uses libnftables.la. Can you find it?
- which dependencies has libnftables.la? Which CFLAGS?
Don't try to understand the file at once. Look what you want to do or look at a single aspect you'd like to understand, and how hard that is now (I claim, it became simpler!).
I mean, previously you could read "examples/Makefile.am" at once. But when you type make -C examples then the dependencies were wrong and parallel build doesn't work (across directories). Look how it's now. Can you find how examples are build in the large Makefile.am?
It's all in one file, open in your editor and easy to jump around.
--
Another example: "src/expression.c" is 5k+. See how most include/*.h include each other, meaning that most source files end up with all headers included. Overall, the cohesion/coupling of the code doesn't seem great. Maybe it needs to be that way and couldn't be better. The point is: 5k+ LOC may be a problem, but it's not as simple as "just split it" or "just move functions ~arbitrarily~ into more files". I say "arbitrarily" unless you find independent pieces that can be meaningfully split.
Likewise, Makefile.am contains the build configuration of the project. It's strongly coupled and to some degree, you need to see it as a whole. At least, make needs to see it as a whole, which SUBDIRS= does not. This will be more relevant, when actually adding unit tests and integrating tests into make check.
The lack of not integrating tests in make (and not having unit tests) is IMO bad and should be addressed. I claim, with one make file, that will fit beautifully together (maintainable). The unit tests will be in another directories, which requires correct dependencies between tests/unit/ and src/. With recursive make (SUBDIRS=) it's only "everything under src/ must build first", which hampers parallel make and does not express dependencies correctly.
Branch [2] shows how this would look with unit tests.
[2] https://gitlab.freedesktop.org/thaller/nftables/-/commits/th/no-recursive-make
Thomas
Pablo Neira Ayuso
maintainerRe: [PATCH nft v2 4/7] build: no recursive make for "files/**/Makefile.am"
Quoted 34 lines · Thomas Haller
Quoted 20 lines · Pablo Neira Ayuso
Quoted 19 lines · Pablo Neira Ayuso
Quoted 10 lines · Thomas Haller
Makefile.am +0
-0@@ -2,6 +2,8 @@ ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST =
+################################################################
###############This marker shows that this Makefile.am is really getting too big.
Can we find a middle point?
I understand that a single
Makefilefor something as little as examples/Makefile.am is probably too much.Quoted 7 lines
Quoted 2 lines
No revert please, something incremental, otherwise this looks like iptables'
Makefile.Correction: Actually iptables' Makefiles show a better balance in how things are split accross Makefiles, with some possibilities to consolidate things but it looks much better these days.
Basically, what I said in the commit message of [1]. Do you disagree with anything specifically (or all of it?).
[1] https://git.netfilter.org/nftables/commit/?id=686d987706bf643f2fa75c1993a5720ad55e6df1
Quoted 7 lines
It's a matter of opinion entirely, but I disagree that the iptables' Makefiles are a positive example.
---
The ### line is only a visual aid.
Yes, because it is too large and you needed this visual aid.
Quoted 6 lines
wc -lseems the better indication for when the file gets too big. A too big file, can be an indication that it's hard to maintain. After all, it's about maintainability, being understandable and correctness. But is it now really harder to understand, and would splitting it into multiple files make it better?
Quoted 8 lines
- see how you would add a new .c/.h file. Can you find it easily with the large
Makefile?- see how libnftables.la is build. Can you find it?
- see who uses libnftables.la. Can you find it?
- which dependencies has libnftables.la? Which CFLAGS?
We __rarely__ need to look at all these things at once.
I do not even remember when it was last time I needed to look into these Makefiles, well now after this churning^H^H^H^H^H^H^H update :-)
Quoted 10 lines
Don't try to understand the file at once. Look what you want to do or look at a single aspect you'd like to understand, and how hard that is now (I claim, it became simpler!).
I mean, previously you could read "examples/Makefile.am" at once. But when you type
make -C examplesthen the dependencies were wrong and parallel build doesn't work (across directories). Look how it's now. Can you find how examples are build in the large Makefile.am?It's all in one file, open in your editor and easy to jump around.
Yes, it is as long as this email :-)
Quoted 10 lines
--
Another example: "
src/expression.c" is 5k+. See how mostinclude/*.hinclude each other, meaning that most source files end up with all headers included. Overall, the cohesion/coupling of the code doesn't seem great. Maybe it needs to be that way and couldn't be better. The point is: 5k+ LOC may be a problem, but it's not as simple as "just split it" or "just move functions ~arbitrarily~ into more files". I say "arbitrarily" unless you find independent pieces that can be meaningfully split.
No, some .c files are really asking for split, and I have patches to start doing so.
Quoted 5 lines
Likewise, Makefile.am contains the build configuration of the project. It's strongly coupled and to some degree, you need to see it as a whole. At least,
makeneeds to see it as a whole, which SUBDIRS= does not. This will be more relevant, when actually adding unit tests and integrating tests intomake check.
Yes, it is great, really.
But this is completely inconsistent with what we have in other existing Netfilter trees.
Quoted 7 lines
The lack of not integrating tests in
make(and not having unit tests) is IMO bad and should be addressed. I claim, with one make file, that will fit beautifully together (maintainable). The unit tests will be in another directories, which requires correct dependencies between tests/unit/ and src/. With recursive make (SUBDIRS=) it's only "everything under src/ must build first", which hampers parallel make and does not express dependencies correctly.
No please, do not follow that path.
I have to run make distcheck to create tarballs, and I do not have to wait to run all tests to do so.
Please do not couple tests with make process.
Re: [PATCH nft v2 4/7] build: no recursive make for "files/**/Makefile.am"
Quoted 89 lines · Pablo Neira Ayuso
Quoted 41 lines · Thomas Haller
Quoted 23 lines · Pablo Neira Ayuso
Quoted 21 lines · Pablo Neira Ayuso
Quoted 11 lines · Thomas Haller
Makefile.am +0
-0@@ -2,6 +2,8 @@ ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST =
+############################################################
####
###############This marker shows that this Makefile.am is really getting too big.
Can we find a middle point?
I understand that a single
Makefilefor something as little as examples/Makefile.am is probably too much.Quoted 9 lines
Quoted 3 lines
No revert please, something incremental, otherwise this looks like
iptables'Makefile.Correction: Actually iptables' Makefiles show a better balance in how
things are split accross Makefiles, with some possibilities to consolidate things but it looks much better these days.Basically, what I said in the commit message of [1]. Do you disagree
with anything specifically (or all of it?).[1]
https://git.netfilter.org/nftables/commit/?id=686d987706bf643f2fa75c1993a5720ad55e6df1Quoted 8 lines
It's a matter of opinion entirely, but I disagree that the iptables'
Makefiles are a positive example.---
The ### line is only a visual aid.
Yes, because it is too large and you needed this visual aid.
Quoted 10 lines
wc -lseems the better indication for when the file gets too big. A too big file, can be an indication that it's hard to maintain. After all, it's about maintainability, being understandable and correctness. But is it now really harder to understand, and would splitting it into multiple files make it better?- see how you would add a new .c/.h file. Can you find it easily with
the largeMakefile?Quoted 5 lines
- see how libnftables.la is build. Can you find it?
- see who uses libnftables.la. Can you find it?
- which dependencies has libnftables.la? Which CFLAGS?
We
__rarely__need to look at all these things at once.I do not even remember when it was last time I needed to look into these Makefiles, well now after this churning^H^H^H^H^H^H^H update :- )
Quoted 14 lines
Don't try to understand the file at once. Look what you want to do or
look at a single aspect you'd like to understand, and how hard that is
now (I claim, it became simpler!).I mean, previously you could read "examples/Makefile.am" at once. But
when you typemake -C examplesthen the dependencies were wrong and
parallel build doesn't work (across directories). Look how it's now.
Can you find how examples are build in the large Makefile.am?
Quoted 3 lines
Quoted 1 line
It's all in one file, open in your editor and easy to jump around.
Yes, it is as long as this email :-)
Sorry about that. I figured, when the long commit message didn't convince you, a long mail should :)
Quoted 16 lines
Quoted 15 lines
--
Another example: "
src/expression.c" is 5k+. See how mostinclude/*.h
include each other, meaning that most source files end up with all headers included. Overall, the cohesion/coupling of the code doesn't
seem great. Maybe it needs to be that way and couldn't be better. The
point is: 5k+ LOC may be a problem, but it's not as simple as "just split it" or "just move functions ~arbitrarily~ into more files". I say
"arbitrarily" unless you find independent pieces that can be meaningfully split.
Quoted 2 lines
No, some .c files are really asking for split, and I have patches to start doing so.
Cool.
Quoted 10 lines
Quoted 9 lines
Likewise, Makefile.am contains the build configuration of the project.
It's strongly coupled and to some degree, you need to see it as a whole. At least,makeneeds to see it as a whole, which SUBDIRS= does
not. This will be more relevant, when actually adding unit tests and
integrating tests intomake check.
Quoted 5 lines
Yes, it is great, really.
But this is completely inconsistent with what we have in other existing
Netfilter trees.
That would also be fixable, by adjusting those trees (I'd volunteer).
The question is what's better, and not what the projects copy-pasted since 1995 do.
Quoted 13 lines
Quoted 12 lines
The lack of not integrating tests in
make(and not having unit tests)
is IMO bad and should be addressed. I claim, with one make file, that
will fit beautifully together (maintainable). The unit tests will be in
another directories, which requires correct dependencies between tests/unit/ and src/. With recursive make (SUBDIRS=) it's only "everything under src/ must build first", which hampers parallel make
and does not express dependencies correctly.
Quoted 7 lines
No please, do not follow that path.
I have to run
make distcheckto create tarballs, and I do not have to wait to run all tests to do so.Please do not couple tests with make process.
On the branch, those tests work and it's convenient to run them and reasonably fast! make -j distcheck takes 59 seconds on my machine.
When doing a release, one(!) minute should be invested to run all tests again. And when tests fail, that should block the release.
On the other hand, the tests could be easily excluded during make distcheck. So that's not really an argument. But not running tests is IMO not favorable.
Anyway. Please play around with what's on current master. I still hope you come to like it.
Thomas
Re: [PATCH nft v2 4/7] build: no recursive make for "files/**/Makefile.am"
Keep in mind for the concerns wrt large Makefiles, you can do 'include' with automake too which keeps things flat in terms of what automake generates and what make ultimately runs.
Pablo Neira Ayuso
maintainerRe: [PATCH nft v2 4/7] build: no recursive make for "files/**/Makefile.am"
Quoted 3 lines · Sam James
Keep in mind for the concerns wrt large Makefiles, you can do 'include' with automake too which keeps things flat in terms of what automake generates and what make ultimately runs.
That would be good to restore if it helps restore modularity to some extend.
A few notes:
- Python support also depends on one option.
- There is nftables/tests/build/run-tests.sh to test for all configurare options, I am not sure if Thomas run this test.
Pablo Neira Ayuso
maintainerRe: [PATCH nft v2 4/7] build: no recursive make for "files/**/Makefile.am"
In reply to Thomas HallerQuoted 1 line · Thomas Haller
On Thu, 2023-11-02 at 17:05 +0100, Pablo Neira Ayuso wrote:
[...]
Quoted 7 lines
Quoted 2 lines
But this is completely inconsistent with what we have in other existing Netfilter trees.
That would also be fixable, by adjusting those trees (I'd volunteer).
The question is what's better, and not what the projects copy-pasted since 1995 do.
I don't think it is worth the update, maybe some simplification to remove silly things such as Makefile.am with one singleton line, but there are better things to look at IMO.
[...]
Quoted 4 lines
Quoted 1 line
Please do not couple tests with make process.
On the branch, those tests work and it's convenient to run them and reasonably fast!
make -j distchecktakes 59 seconds on my machine.
CI is what is missing, a single run is proving not giving much in return these days after your improvements.
The recent bugs that were uncovered have been spotted by running this is a loop, and also exercising standalone 30s-stress from Florian for many hours.
A few minutes does not harm (I can check how long it takes on my AMD Epyc box that I use for testing), but CI might provide more reliable information on what is going on.
Thanks.
PATCH v2 5/7 build: no recursive make for "src/Makefile.am"
In reply to Thomas HallerMerge the Makefile.am under "src/" into the toplevel Makefile.am. This is a step in the effort of dropping recursive make.
--- Make_global.am | 21 ----- Makefile.am | 214 +++++++++++++++++++++++++++++++++++++++++++++++- configure.ac | 1 - src/Makefile.am | 123 ---------------------------- 4 files changed, 213 insertions(+), 146 deletions(-) delete mode 100644 Make_global.am delete mode 100644 src/Makefile.am
Make_global.am deleted +0 -21
@@ -1,21 +0,0 @@ -# This is _NOT_ the library release version, it's an API version. -# Extracted from Chapter 6 "Library interface versions" of the libtool docs. -# -# <snippet> -# Here are a set of rules to help you update your library version information: -# -# 1. Start with version information of `0:0:0' for each libtool library. -# 2. Update the version information only immediately before a public release -# of your software. More frequent updates are unnecessary, and only guarantee -# that the current interface number gets larger faster. -# 3. If the library source code has changed at all since the last update, -# then increment revision (`c:r:a' becomes `c:r+1:a'). -# 4. If any interfaces have been added, removed, or changed since the last -# update, increment current, and set revision to 0. -# 5. If any interfaces have been added since the last public release, then -# increment age. -# 6. If any interfaces have been removed since the last public release, then -# set age to 0. -# </snippet> -# -libnftables_LIBVERSION=2:0:1
Makefile.am +213 -1
226 lines not on this page · raw message
configure.ac +0 -1
@@ -117,7 +117,6 @@ AC_CHECK_DECLS([getprotobyname_r, getprotobynumber_r, getservbyport_r], [], [], AC_CONFIG_FILES([ \ Makefile \ libnftables.pc \ - src/Makefile \ doc/Makefile \ examples/Makefile \ ])
src/Makefile.am deleted +0 -123
123 lines not on this page · raw message
Signature · 1 line
2.41.0
PATCH v2 6/7 build: no recursive make for "examples/Makefile.am"
In reply to Thomas HallerMerge the Makefile.am under "examples/" into the toplevel Makefile.am. This is a step in the effort of dropping recursive make.
--- Makefile.am | 19 ++++++++++++++++--- configure.ac | 1 - examples/Makefile.am | 6 ------ 3 files changed, 16 insertions(+), 10 deletions(-) delete mode 100644 examples/Makefile.am
Makefile.am +16 -3
@@ -26,9 +26,11 @@ ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = BUILT_SOURCES = +LDADD = lib_LTLIBRARIES = noinst_LTLIBRARIES = sbin_PROGRAMS = +check_PROGRAMS = ###############################################################################
@@ -288,9 +290,20 @@ src_nft_LDADD = src/libnftables.la ############################################################################### -SUBDIRS = \ - doc \ - examples +SUBDIRS = doc + +############################################################################### + + +check_PROGRAMS += examples/nft-buffer + +examples_nft_buffer_AM_CPPFLAGS = -I$(srcdir)/include +examples_nft_buffer_LDADD = src/libnftables.la + +check_PROGRAMS += examples/nft-json-file + +examples_nft_json_file_AM_CPPFLAGS = -I$(srcdir)/include +examples_nft_json_file_LDADD = src/libnftables.la ###############################################################################
configure.ac +0 -1
@@ -118,7 +118,6 @@ AC_CONFIG_FILES([ \ Makefile \ libnftables.pc \ doc/Makefile \ - examples/Makefile \ ]) AC_OUTPUT
examples/Makefile.am deleted +0 -6
@@ -1,6 +0,0 @@ -check_PROGRAMS = nft-buffer \ - nft-json-file - -AM_CPPFLAGS = -I$(top_srcdir)/include - -LDADD = $(top_builddir)/src/libnftables.la
Signature · 1 line
2.41.0
PATCH v2 7/7 build: no recursive make for "doc/Makefile.am"
In reply to Thomas HallerMerge the Makefile.am under "doc/" into the toplevel Makefile.am. This is a step in the effort of dropping recursive make.
--- Makefile.am | 60 ++++++++++++++++++++++++++++++++++++++++++++----- configure.ac | 1 - doc/Makefile.am | 30 ------------------------- 3 files changed, 55 insertions(+), 36 deletions(-) delete mode 100644 doc/Makefile.am
Makefile.am +55 -5
@@ -31,6 +31,8 @@ lib_LTLIBRARIES = noinst_LTLIBRARIES = sbin_PROGRAMS = check_PROGRAMS = +dist_man_MANS = +CLEANFILES = ###############################################################################
@@ -290,11 +292,6 @@ src_nft_LDADD = src/libnftables.la ############################################################################### -SUBDIRS = doc - -############################################################################### - - check_PROGRAMS += examples/nft-buffer examples_nft_buffer_AM_CPPFLAGS = -I$(srcdir)/include
@@ -307,6 +304,59 @@ examples_nft_json_file_LDADD = src/libnftables.la ############################################################################### +if BUILD_MAN + +dist_man_MANS += \ + doc/nft.8 \ + doc/libnftables-json.5 \ + doc/libnftables.3 \ + $(NULL) + +A2X_OPTS_MANPAGE = \ + -L \ + --doctype manpage \ + --format manpage \ + -D "${builddir}/doc" \ + $(NULL) + +ASCIIDOC_MAIN = doc/nft.txt + +ASCIIDOC_INCLUDES = \ + doc/data-types.txt \ + doc/payload-expression.txt \ + doc/primary-expression.txt \ + doc/stateful-objects.txt \ + doc/statements.txt \ + $(NULL) + +ASCIIDOCS = \ + $(ASCIIDOC_MAIN) \ + $(ASCIIDOC_INCLUDES) \ + $(NULL) + +EXTRA_DIST += \ + $(ASCIIDOCS) \ + doc/libnftables-json.adoc \ + doc/libnftables.adoc \ + $(NULL) + +CLEANFILES += doc/*~ + +doc/nft.8: $(ASCIIDOCS) + $(AM_V_GEN)$(A2X) $(A2X_OPTS_MANPAGE) $< + +.adoc.3: + $(AM_V_GEN)$(A2X) $(A2X_OPTS_MANPAGE) $< + +.adoc.5: + $(AM_V_GEN)$(A2X) $(A2X_OPTS_MANPAGE) $< + +MAINTAINERCLEANFILES = ${dist_man_MANS} + +endif + +############################################################################### + dist_pkgdata_DATA = \ files/nftables/all-in-one.nft \ files/nftables/arp-filter.nft \
configure.ac +0 -1
@@ -117,7 +117,6 @@ AC_CHECK_DECLS([getprotobyname_r, getprotobynumber_r, getservbyport_r], [], [], AC_CONFIG_FILES([ \ Makefile \ libnftables.pc \ - doc/Makefile \ ]) AC_OUTPUT
doc/Makefile.am deleted +0 -30
@@ -1,30 +0,0 @@ -if BUILD_MAN -dist_man_MANS = nft.8 libnftables-json.5 libnftables.3 - -A2X_OPTS_MANPAGE = -L --doctype manpage --format manpage -D ${builddir} - -ASCIIDOC_MAIN = nft.txt -ASCIIDOC_INCLUDES = \ - data-types.txt \ - payload-expression.txt \ - primary-expression.txt \ - stateful-objects.txt \ - statements.txt -ASCIIDOCS = ${ASCIIDOC_MAIN} ${ASCIIDOC_INCLUDES} - -EXTRA_DIST = ${ASCIIDOCS} libnftables-json.adoc libnftables.adoc - -CLEANFILES = \ - *~ - -nft.8: ${ASCIIDOCS} - ${AM_V_GEN}${A2X} ${A2X_OPTS_MANPAGE} $< - -.adoc.3: - ${AM_V_GEN}${A2X} ${A2X_OPTS_MANPAGE} $< - -.adoc.5: - ${AM_V_GEN}${A2X} ${A2X_OPTS_MANPAGE} $< - -MAINTAINERCLEANFILES = ${dist_man_MANS} -endif
Signature · 1 line
2.41.0
Florian Westphal
maintainerQuoted 2 lines · Thomas Haller
This is a RESEND of v1. Only minor adjustments to the commit message and rebasing.
All applied, thanks Thomas.