Skip to contentSkip to conversation

libnetfilter_queue: automake portability warning

DISCUSSION Jeremy Sowden 4 participants 6 messages Aug 27, 2021 – Aug 29, 2021 netfilter

lore
Share & tools
lore
#0 lore raw

Running autogen.sh gives the following output when it gets to doxygen/Makefile.am:

doxygen/Makefile.am:3: warning: shell find $(top_srcdir: non-POSIX variable name doxygen/Makefile.am:3: (probably a GNU make extension)

Automake doesn't understand the GNU make $(shell ...) function and tries to interpret it as an Automake variable. The Automake people would probably say we shouldn't do that 'cause it's not portable:

https://www.gnu.org/software/automake/manual/automake.html#Wildcards

However, if we accept that we are targetting GNU make, but we want to get rid of the warning, I believe there are two ways to do so. We can tell Automake not to warn about non-portable constructions:

  diff --git a/configure.ac b/configure.ac
  index 4721eebbab1f..7cd34d079e67 100644
  --- a/configure.ac
  +++ b/configure.ac
  @@ -6,7 +6,7 @@ AC_CANONICAL_HOST
   AC_CONFIG_MACRO_DIR([m4])
   AC_CONFIG_HEADERS([config.h])

-AM_INIT_AUTOMAKE([-Wall foreign subdir-objects +AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects

          tar-pax no-dist-gzip dist-bzip2 1.6])

m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

On the other hand, if we want to suppress the warning for just this one GNU-ism, we can hide it from automake:

diff --git a/configure.ac b/configure.ac index 4721eebbab1f..b2b54d3168ad 100644 --- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,19 @@ AS_IF([test "x$DOXYGEN" = x], [

                  with_doxygen=no
          ])

])
+#
+# Putting $(shell ... ) directly into the doyxgen Makefile.am confuses automake, +# which tries to interpret it as an automake variable:
+#
+# doxygen/Makefile.am:3: warning: shell find $(top_srcdir: non-POSIX variable name
+# doxygen/Makefile.am:3: (probably a GNU make extension)
+#
+# Instead, we use autoconf to substitute it into place after automake has run. +#
+AS_IF([test "x$with_doxygen" != no], [
+ AC_SUBST([DOC_SRCS], ['$(shell find $(top_srcdir)/src -name '"'"'*.c'"'"')']) +])
+
AC_OUTPUT

   echo "
  diff --git a/doxygen/Makefile.am b/doxygen/Makefile.am
  index f38009b24114..6ed30e21ff75 100644
  --- a/doxygen/Makefile.am
  +++ b/doxygen/Makefile.am
  @@ -1,6 +1,6 @@
   if HAVE_DOXYGEN
  -doc_srcs = $(shell find $(top_srcdir)/src -name '*.c')
  +doc_srcs = @DOC_SRCS@
   doxyfile.stamp: $(doc_srcs) Makefile.am
          rm -rf html man

J.

#1 lore raw

Hi Jeremy,

Quoted 63 lines · Jeremy Sowden

Running autogen.sh gives the following output when it gets to doxygen/Makefile.am:

doxygen/Makefile.am:3: warning: shell find $(top_srcdir: non-POSIX variable name doxygen/Makefile.am:3: (probably a GNU make extension)

Automake doesn't understand the GNU make $(shell ...) function and tries to interpret it as an Automake variable. The Automake people would probably say we shouldn't do that 'cause it's not portable:

https://www.gnu.org/software/automake/manual/automake.html#Wildcards

However, if we accept that we are targetting GNU make, but we want to get rid of the warning, I believe there are two ways to do so. We can tell Automake not to warn about non-portable constructions:

  diff --git a/configure.ac b/configure.ac
  index 4721eebbab1f..7cd34d079e67 100644
  --- a/configure.ac
  +++ b/configure.ac
  @@ -6,7 +6,7 @@ AC_CANONICAL_HOST
   AC_CONFIG_MACRO_DIR([m4])
   AC_CONFIG_HEADERS([config.h])

-AM_INIT_AUTOMAKE([-Wall foreign subdir-objects +AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects

          tar-pax no-dist-gzip dist-bzip2 1.6])

m4_ifdef([AM_PROG_AR], [AM_PROG_AR])

On the other hand, if we want to suppress the warning for just this one GNU-ism, we can hide it from automake:

diff --git a/configure.ac b/configure.ac index 4721eebbab1f..b2b54d3168ad 100644 --- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,19 @@ AS_IF([test "x$DOXYGEN" = x], [

                  with_doxygen=no
          ])

])
+#
+# Putting $(shell ... ) directly into the doyxgen Makefile.am confuses automake, +# which tries to interpret it as an automake variable:
+#
+# doxygen/Makefile.am:3: warning: shell find $(top_srcdir: non-POSIX variable name
+# doxygen/Makefile.am:3: (probably a GNU make extension)
+#
+# Instead, we use autoconf to substitute it into place after automake has run. +#
+AS_IF([test "x$with_doxygen" != no], [
+ AC_SUBST([DOC_SRCS], ['$(shell find $(top_srcdir)/src -name '"'"'*.c'"'"')']) +])
+
AC_OUTPUT

   echo "
  diff --git a/doxygen/Makefile.am b/doxygen/Makefile.am
  index f38009b24114..6ed30e21ff75 100644
  --- a/doxygen/Makefile.am
  +++ b/doxygen/Makefile.am
  @@ -1,6 +1,6 @@
   if HAVE_DOXYGEN
Quoted 7 lines
  -doc_srcs = $(shell find $(top_srcdir)/src -name '*.c')
  +doc_srcs = @DOC_SRCS@
   doxyfile.stamp: $(doc_srcs) Makefile.am
          rm -rf html man

J.

Thanks for the suggestioms. I strongly prefer adding -Wno-portability to AM_INIT_AUTOMAKE.

The alternative patch is longer, and IMHO less clear to follow. Also it's error-prone - consider this line:

Quoted 1 line

AS_IF([test "x$with_doxygen" != no], [

The test needs to be one of the following:

Quoted 3 lines

[test "x$with_doxygen" != xno]
[test "$with_doxygen" != no]
[test "$with_doxygen" = yes]

I'd like to get rid of the warning so will send a v3.

Cheers ... Duncan.

#2 lore raw
In reply to Jeremy Sowden
Quoted 7 lines · Jeremy Sowden

Running autogen.sh gives the following output when it gets to doxygen/Makefile.am:

doxygen/Makefile.am:3: warning: shell find $(top_srcdir: non-POSIX variable name doxygen/Makefile.am:3: (probably a GNU make extension)

Automake doesn't understand the GNU make $(shell ...) [...]

Or, third option, ditch the wildcarding and just name the sources. If going for a single Makefile (ditching recursive make), that will also be beneficial for parallel building, and the repo is not too large for such undertaking to be infeasible.

#3 lore raw
Quoted 9 lines · Jan Engelhardt
Quoted 6 lines · Jeremy Sowden

Running autogen.sh gives the following output when it gets to doxygen/Makefile.am:

doxygen/Makefile.am:3: warning: shell find $(top_srcdir: non-POSIX variable name doxygen/Makefile.am:3: (probably a GNU make extension)

Quoted 7 lines
Quoted 1 line

Automake doesn't understand the GNU make $(shell ...) [...]

Or, third option, ditch the wildcarding and just name the sources. If going for a single Makefile (ditching recursive make), that will also be beneficial for parallel building, and the repo is not too large for such undertaking to be infeasible.

Certainly naming the sources would work.

But, with wildcarding, Makefile.am works unmodified in other projects, such as libmnl. Indeed I was planning to have libmnl/autogen.sh fetch both doxygen/Makefile.am and doxygen/build_man.sh

If the project ends up with a single Makefile, it could include nearly all of the existing doxygen/Makefile.am, and autogen.sh could fetch that in other projects.

In any case, is wildcarding incompatible with having a single Makefile?

Cheers ... Duncan.

#4 lore raw
Quoted 19 lines · Duncan Roe
Quoted 9 lines · Jan Engelhardt
Quoted 6 lines · Jeremy Sowden

Running autogen.sh gives the following output when it gets to doxygen/Makefile.am:

doxygen/Makefile.am:3: warning: shell find $(top_srcdir: non-POSIX variable name doxygen/Makefile.am:3: (probably a GNU make extension)

Quoted 7 lines
Quoted 1 line

Automake doesn't understand the GNU make $(shell ...) [...]

Or, third option, ditch the wildcarding and just name the sources. If going for a single Makefile (ditching recursive make), that will also be beneficial for parallel building, and the repo is not too large for such undertaking to be infeasible.

Certainly naming the sources would work.

Quoted 7 lines

But, with wildcarding, Makefile.am works unmodified in other projects, such as libmnl. Indeed I was planning to have libmnl/autogen.sh fetch both doxygen/Makefile.am and doxygen/build_man.sh

If the project ends up with a single Makefile, it could include nearly all of the existing doxygen/Makefile.am, and autogen.sh could fetch that in other projects.

doxygen's Makefile.am is relatively small now.

autogen.sh can be used to keep build_man.sh in sync, that should be good enough, my main concern is that addressed with shell script split off.

So I'd suggest remove the wildcarding from Makefile.am too.

#5 lore raw
Quoted 28 lines · Pablo Neira Ayuso
Quoted 19 lines · Duncan Roe
Quoted 9 lines · Jan Engelhardt
Quoted 6 lines · Jeremy Sowden

Running autogen.sh gives the following output when it gets to doxygen/Makefile.am:

doxygen/Makefile.am:3: warning: shell find $(top_srcdir: non-POSIX variable name doxygen/Makefile.am:3: (probably a GNU make extension)

Quoted 7 lines
Quoted 1 line

Automake doesn't understand the GNU make $(shell ...) [...]

Or, third option, ditch the wildcarding and just name the sources. If going for a single Makefile (ditching recursive make), that will also be beneficial for parallel building, and the repo is not too large for such undertaking to be infeasible.

Certainly naming the sources would work.

Quoted 7 lines

But, with wildcarding, Makefile.am works unmodified in other projects, such as libmnl. Indeed I was planning to have libmnl/autogen.sh fetch both doxygen/Makefile.am and doxygen/build_man.sh

If the project ends up with a single Makefile, it could include nearly all of the existing doxygen/Makefile.am, and autogen.sh could fetch that in other projects.

Quoted 7 lines

doxygen's Makefile.am is relatively small now.

autogen.sh can be used to keep build_man.sh in sync, that should be good enough, my main concern is that addressed with shell script split off.

So I'd suggest remove the wildcarding from Makefile.am too.

I pushed a v2 which does that.

Cheers ... Duncan.