]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
build: combine iptables-multi and iptables-static
authorJan Engelhardt <jengelh@medozas.de>
Thu, 23 Jul 2009 15:41:21 +0000 (17:41 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Sat, 25 Jul 2009 19:40:56 +0000 (21:40 +0200)
Changed the Makefile so that:

1. --enable-shared / --disable-shared control the linkage against
   libdl (and thus the potential to use 3rd party extensions)

2. --enable-static / --disable-static controls whether shipped
   extensions are built-in or provided as modules

iptables-static becomes redundant by this action; iptables-multi now
has the feature.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
INSTALL
Makefile.am
extensions/GNUmakefile.in
include/xtables.h.in
ip6tables-restore.c
ip6tables-save.c
ip6tables-standalone.c
iptables-restore.c
iptables-save.c
iptables-standalone.c

diff --git a/INSTALL b/INSTALL
index 4a44989e0375aa3651a715828683e7c84a72f169..acb56cd58bc419ad98f4cd6ce1e028b2b869293a 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -41,18 +41,22 @@ Configuring and compiling
 
        It is enabled by default.
 
+--enable-static
+
+       Produce additional binaries, iptables-static/ip6tables-static,
+       which have all shipped extensions compiled in.
+
+--disable-shared
+
+       Produce binaries that have dynamic loading of extensions disabled.
+       This implies --enable-static.
+       (See some details below.)
+
 --enable-libipq
 
        This option causes libipq to be installed into ${libdir} and
        ${includedir}.
 
---enable-static
-
-       Enable building single standalone multipurpose binaries,
-       (iptables-static and ip6tables-static), which contain every
-       extension compiled-in (and does not support additional
-       extensions).
-
 --with-ksource=
 
        Xtables does not depend on kernel headers anymore, but you can
@@ -74,7 +78,22 @@ The make process will automatically build multipurpose binaries.
 These have the core (iptables), -save, -restore and -xml code
 compiled into one binary, but extensions remain as modules.
 
-If you want to build a statically linked version of the iptables binary,
-without the need for loading the plugins at runtime (e.g. for an
-embedded device or router-on-a-disk), you can use the --enable-static
-configure flag.
+
+Static and shared
+=================
+
+Basically there are three configuration modes defined:
+
+ --disable-static --enable-shared (this is the default)
+
+       Build a binary that relies upon dynamic loading of extensions.
+
+ --enable-static --enable-shared
+
+       Build a binary that has the shipped extensions built-in, but
+       is still capable of loading additional extensions.
+
+ --enable-static --disable-shared
+
+       Shipped extensions are built-in, and dynamic loading is
+       deactivated.
index 23cdedd40145c9fa0935f6ccf697b512395d675f..fc779e9f98800bd086ba2b3ae7baaccac4d2c7d1 100644 (file)
@@ -26,7 +26,13 @@ libiptc_libip6tc_la_LDFLAGS = -version-info 0:0:0
 lib_LTLIBRARIES      += libxtables.la
 libxtables_la_SOURCES = xtables.c
 libxtables_la_LDFLAGS = -version-info ${libxtables_vcurrent}:0:${libxtables_vage}
+if ENABLE_SHARED
+libxtables_la_CFLAGS  = ${AM_CFLAGS}
 libxtables_la_LIBADD  = -ldl
+else
+libxtables_la_CFLAGS  = ${AM_CFLAGS} -DNO_SHARED_LIBS=1
+libxtables_la_LIBADD  =
+endif
 
 # iptables, dynamic
 iptables_SOURCES          = iptables-standalone.c iptables.c xshared.c
@@ -38,6 +44,9 @@ iptables_multi_SOURCES    = iptables-multi.c iptables-save.c \
                             iptables-restore.c iptables-xml.c \
                             iptables-standalone.c iptables.c xshared.c
 iptables_multi_CFLAGS     = ${AM_CFLAGS} -DIPTABLES_MULTI
+if ENABLE_STATIC
+iptables_multi_CFLAGS    += -DALL_INCLUSIVE
+endif
 iptables_multi_LDFLAGS    = ${iptables_LDFLAGS}
 iptables_multi_LDADD      = ${iptables_LDADD}
 
@@ -49,11 +58,6 @@ iptables_save_SOURCES     = iptables-save.c iptables.c xshared.c
 iptables_save_LDFLAGS     = ${iptables_LDFLAGS}
 iptables_save_LDADD       = ${iptables_LDADD}
 
-# iptables-multi, semi-static
-iptables_static_SOURCES   = ${iptables_multi_SOURCES} xtables.c
-iptables_static_CFLAGS    = ${iptables_multi_CFLAGS} -DNO_SHARED_LIBS=1
-iptables_static_LDADD     = libiptc/libip4tc.la extensions/libext4.a -lm
-
 iptables_xml_SOURCES      = iptables-xml.c
 
 # ip6tables, dynamic
@@ -65,6 +69,9 @@ ip6tables_multi_SOURCES   = ip6tables-multi.c ip6tables-save.c \
                             ip6tables-restore.c ip6tables-standalone.c \
                             ip6tables.c xshared.c
 ip6tables_multi_CFLAGS    = ${AM_CFLAGS} -DIPTABLES_MULTI
+if ENABLE_STATIC
+ip6tables_multi_CFLAGS   += -DALL_INCLUSIVE
+endif
 ip6tables_multi_LDFLAGS   = ${ip6tables_LDFLAGS}
 ip6tables_multi_LDADD     = ${ip6tables_LDADD}
 
@@ -76,11 +83,6 @@ ip6tables_save_SOURCES    = ip6tables-save.c ip6tables.c xshared.c
 ip6tables_save_LDFLAGS    = ${ip6tables_LDFLAGS}
 ip6tables_save_LDADD      = ${ip6tables_LDADD}
 
-# iptables-multi, semi-static
-ip6tables_static_SOURCES    = ${ip6tables_multi_SOURCES} xtables.c
-ip6tables_static_CFLAGS     = ${ip6tables_multi_CFLAGS} -DNO_SHARED_LIBS=1
-ip6tables_static_LDADD      = libiptc/libip6tc.la extensions/libext6.a -lm
-
 bin_PROGRAMS     = iptables-xml
 sbin_PROGRAMS    =
 noinst_PROGRAMS  =
@@ -89,22 +91,12 @@ man_MANS         = iptables.8 iptables-restore.8 iptables-save.8 \
                    ip6tables-save.8
 CLEANFILES       = iptables.8 ip6tables.8
 
-if ENABLE_STATIC
-if ENABLE_IPV4
-sbin_PROGRAMS += iptables-static
-endif
-if ENABLE_IPV6
-sbin_PROGRAMS += ip6tables-static
-endif
-endif
-if ENABLE_SHARED
 if ENABLE_IPV4
 sbin_PROGRAMS += iptables iptables-multi iptables-restore iptables-save
 endif
 if ENABLE_IPV6
 sbin_PROGRAMS += ip6tables ip6tables-multi ip6tables-restore ip6tables-save
 endif
-endif
 
 iptables.8: ${srcdir}/iptables.8.in extensions/matches4.man extensions/targets4.man
        ${AM_VERBOSE_GEN} sed -e 's/@PACKAGE_AND_VERSION@/${PACKAGE} ${PACKAGE_VERSION}/g' -e '/@MATCH@/ r extensions/matches4.man' -e '/@TARGET@/ r extensions/targets4.man' $< >$@;
index e1f1f494f47cfef4ae90df0a008205fe04d2c7f9..709366a12eecbed7146151b0b470bf692d595eb8 100644 (file)
@@ -56,8 +56,8 @@ targets := libext4.a libext6.a matches4.man matches6.man \
 targets_install :=
 @ENABLE_STATIC_TRUE@ libext4_objs := ${pfx_objs} ${pf4_objs}
 @ENABLE_STATIC_TRUE@ libext6_objs := ${pfx_objs} ${pf6_objs}
-@ENABLE_SHARED_TRUE@ targets += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
-@ENABLE_SHARED_TRUE@ targets_install += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
+@ENABLE_STATIC_FALSE@ targets += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
+@ENABLE_STATIC_FALSE@ targets_install += ${pfx_solibs} ${pf4_solibs} ${pf6_solibs}
 
 .SECONDARY:
 
index 7468302c67d6b166a87cfda2dc2227a1ec606f04..3955716d5cf4036e447bb78cfb4b1f60da82bc67 100644 (file)
@@ -277,7 +277,7 @@ extern void xtables_ip6parse_multiple(const char *, struct in6_addr **,
  */
 extern void xtables_save_string(const char *value);
 
-#ifdef NO_SHARED_LIBS
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
 #      ifdef _INIT
 #              undef _init
 #              define _init _INIT
index 06a82aec3172ca5218dd942f6f3fca8251ec5ce5..d0efbeed73f23d59683f29e0f255323c1b6eefa8 100644 (file)
@@ -137,7 +137,7 @@ int main(int argc, char *argv[])
                                ip6tables_globals.program_version);
                exit(1);
        }
-#ifdef NO_SHARED_LIBS
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
 #endif
 
index c59608fb210a846d2f965c95d7a07af012dc7595..dc189e998f227fa1359f2311f5f7f9a95554cd19 100644 (file)
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
                                ip6tables_globals.program_version);
                exit(1);
        }
-#ifdef NO_SHARED_LIBS
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
 #endif
 
index 649ac3d81cf8fbde6e11a93f91202fd6589226fd..8661bd9cf35133a429ac1f98e02a1ba18c59ecb9 100644 (file)
@@ -58,7 +58,7 @@ main(int argc, char *argv[])
                exit(1);
        }
 
-#ifdef NO_SHARED_LIBS
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
 #endif
 
index 5108fda6a682416cec6580e0ad62a99f54b625a6..86d63e28778c23e38797bac425fc8338451fbe5e 100644 (file)
@@ -140,7 +140,7 @@ main(int argc, char *argv[])
                                iptables_globals.program_version);
                exit(1);
        }
-#ifdef NO_SHARED_LIBS
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
 #endif
 
index f63ee6b1595bbbd69cf244682cd49750c3bf597c..3bcf42277338ea294e4c8c82f032725f28088c0d 100644 (file)
@@ -148,7 +148,7 @@ main(int argc, char *argv[])
                                iptables_globals.program_version);
                exit(1);
        }
-#ifdef NO_SHARED_LIBS
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
 #endif
 
index 91853884b3d6378deed12301e29c8c8379109955..1f60e314c13ca741f36c95ea803d0cb829e7289a 100644 (file)
@@ -58,7 +58,7 @@ main(int argc, char *argv[])
                                iptables_globals.program_version);
                                exit(1);
        }
-#ifdef NO_SHARED_LIBS
+#if defined(ALL_INCLUSIVE) || defined(NO_SHARED_LIBS)
        init_extensions();
 #endif