Skip to contentSkip to conversation

configure: add an option to compile the examples

PATCH In review Dario Binacchi 2 participants 3 messages Apr 25, 2022 – Apr 26, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure: add an option to compile the examples

Using a configure option to compile the examples is a more common practice. This can also increase library usage (e.g. buildroot would now be able to install such applications on the created rootfs).

---
 Makefile.am               | 7 ++++++-
 README                    | 2 +-
 configure.ac              | 8 +++++++-
 examples/rtnl/Makefile.am | 2 +-
 4 files changed, 15 insertions(+), 4 deletions(-)
Makefile.am +6 -1
index 94e6935..7f8ae56 100644
@@ -2,9 +2,14 @@ include $(top_srcdir)/Make_global.am
 
 ACLOCAL_AMFLAGS = -I m4
 
-SUBDIRS = src include examples doxygen
+SUBDIRS = src include doxygen
 DIST_SUBDIRS = src include examples doxygen
 
+if ENABLE_EXAMPLES
+SUBDIRS += examples
+DIST_SUBDIRS += examples
+endif
+
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = libmnl.pc
 
README +1 -1
index fbac9d2..b5f917e 100644
@@ -21,7 +21,7 @@ forced to use them.
 = Example files =
 
 You can find several example files under examples/ that you can compile by
-invoking `make check'.
+invoking `./configure --enable-examples && make'.
 
 --
 08/sep/2010
configure.ac +7 -1
index 314481d..8c88c9b 100644
@@ -21,6 +21,11 @@ case "$host" in
 *) AC_MSG_ERROR([Linux only, dude!]);;
 esac
 
+AC_ARG_ENABLE([examples],
+	AS_HELP_STRING([--enable-examples], [Build examples]),
+	[enable_examples="$enableval"], [enable_examples="no"])
+AM_CONDITIONAL([ENABLE_EXAMPLES], [test "$enable_examples" = "yes"])
+
 regular_CPPFLAGS="-D_FILE_OFFSET_BITS=64 -D_REENTRANT"
 regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
 	-Wmissing-prototypes -Wshadow -Wstrict-prototypes \
@@ -53,4 +58,5 @@ AC_OUTPUT
 
 echo "
 libmnl configuration:
-  doxygen:          ${with_doxygen}"
+  doxygen:          ${with_doxygen}
+  examples:         ${enable_examples}"
examples/rtnl/Makefile.am +1 -1
index dd8a77d..017468f 100644
@@ -1,6 +1,6 @@
 include $(top_srcdir)/Make_global.am
 
-check_PROGRAMS = rtnl-addr-add \
+bin_PROGRAMS = rtnl-addr-add \
 		 rtnl-addr-dump \
 		 rtnl-link-dump rtnl-link-dump2 rtnl-link-dump3 \
 		 rtnl-link-event \
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Dario Binacchi

Using a configure option to compile the examples is a more common practice. This can also increase library usage (e.g. buildroot would now be able to install such applications on the created rootfs).

From context, I assume this is for libmnl.

If you run `make' it does not compile the examples.

#2 lore raw
Quoted 10 lines

Il 26/04/2022 14:58 Pablo Neira Ayuso <[email protected]> ha scritto:

Quoted 3 lines · Dario Binacchi

Using a configure option to compile the examples is a more common practice. This can also increase library usage (e.g. buildroot would now be able to install such applications on the created rootfs).

From context, I assume this is for libmnl

Yes, libmnl

Quoted 2 lines

If you run `make' it does not compile the examples.

yes, as before the patch.
To compile the examples you need to run ./configure --enable-examples && make' instead of make check'.

Thanks and regards,
Dario