All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft v2 0/7] no recursive make
@ 2023-10-19 12:59 Thomas Haller
  2023-10-19 13:00 ` [PATCH nft v2 1/7] gitignore: ignore ".dirstamp" files Thomas Haller
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Thomas Haller @ 2023-10-19 12:59 UTC (permalink / raw)
  To: NetFilter; +Cc: Thomas Haller

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

-- 
2.41.0


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-11-03 12:21 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-19 12:59 [PATCH nft v2 0/7] no recursive make Thomas Haller
2023-10-19 13:00 ` [PATCH nft v2 1/7] gitignore: ignore ".dirstamp" files Thomas Haller
2023-10-19 13:00 ` [PATCH nft v2 2/7] build: no recursive-make for "include/**/Makefile.am" Thomas Haller
2023-10-19 13:00 ` [PATCH nft v2 3/7] build: no recursive make for "py/Makefile.am" Thomas Haller
2023-10-19 13:00 ` [PATCH nft v2 4/7] build: no recursive make for "files/**/Makefile.am" Thomas Haller
2023-11-02 11:14   ` Pablo Neira Ayuso
2023-11-02 11:30     ` Pablo Neira Ayuso
2023-11-02 14:03       ` Thomas Haller
2023-11-02 16:05         ` Pablo Neira Ayuso
2023-11-02 16:53           ` Thomas Haller
2023-11-03 11:37             ` Sam James
2023-11-03 12:05               ` Pablo Neira Ayuso
2023-11-03 12:21             ` Pablo Neira Ayuso
2023-10-19 13:00 ` [PATCH nft v2 5/7] build: no recursive make for "src/Makefile.am" Thomas Haller
2023-10-19 13:00 ` [PATCH nft v2 6/7] build: no recursive make for "examples/Makefile.am" Thomas Haller
2023-10-19 13:00 ` [PATCH nft v2 7/7] build: no recursive make for "doc/Makefile.am" Thomas Haller
2023-11-02 11:07 ` [PATCH nft v2 0/7] no recursive make Florian Westphal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.