]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
let DO_MULTI=1 work for ip6tables* binaries
authorHann-Huei Chiou <koala@ascenvision.com>
Tue, 23 Oct 2007 14:22:34 +0000 (14:22 +0000)
committerPatrick McHardy <kaber@trash.net>
Tue, 23 Oct 2007 14:22:34 +0000 (14:22 +0000)
When defining DO_MULTI=1 in Makefile, only iptables is built as
a single multipurpose binary. This patch makes ip6tables also be
built in the same manner.

Hann-huei Chiou <koala@ascenvision.com>

Makefile
ip6tables-restore.c
ip6tables-save.c
ip6tables-standalone.c

index f93ff17a11d0dd84ff24d8417a829bb2fa82e1f6..aa9e3102c6185b61230eec21711670497d4c476f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -61,7 +61,10 @@ EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables-save $(DESTDIR)$(BINDIR)/iptables-r
 ifeq ($(DO_IPV6), 1)
 EXTRAS+=ip6tables ip6tables.o ip6tables.8
 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables $(DESTDIR)$(MANDIR)/man8/ip6tables.8
+
+ifneq ($(DO_MULTI), 1)
 EXTRAS+=ip6tables-save ip6tables-restore
+endif
 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/ip6tables-save $(DESTDIR)$(BINDIR)/ip6tables-restore $(DESTDIR)$(MANDIR)/man8/ip6tables-save.8 $(DESTDIR)$(MANDIR)/man8/ip6tables-restore.8
 endif
 
@@ -156,8 +159,13 @@ endif
 ip6tables.o: ip6tables.c
        $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
 
+ifeq ($(DO_MULTI), 1)
+ip6tables: ip6tables-multi.c ip6tables-save.c ip6tables-restore.c ip6tables-standalone.c ip6tables.o xtables.o $(STATIC6_LIBS) libiptc/libiptc.a
+       $(CC) $(CFLAGS) -DIPTABLES_MULTI -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
+else
 ip6tables: ip6tables-standalone.c ip6tables.o xtables.o $(STATIC6_LIBS) libiptc/libiptc.a
        $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
+endif
 
 $(DESTDIR)$(BINDIR)/ip6tables: ip6tables
        @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
@@ -166,16 +174,28 @@ $(DESTDIR)$(BINDIR)/ip6tables: ip6tables
 ip6tables-save: ip6tables-save.c ip6tables.o xtables.o $(STATIC6_LIBS) libiptc/libiptc.a
        $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
+ifeq ($(DO_MULTI), 1)
+$(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables
+       @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
+       ln -sf $< $@
+else
 $(DESTDIR)$(BINDIR)/ip6tables-save: ip6tables-save
        @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
        cp $< $@
+endif
 
 ip6tables-restore: ip6tables-restore.c ip6tables.o xtables.o $(STATIC6_LIBS) libiptc/libiptc.a
        $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
+ifeq ($(DO_MULTI), 1)
+$(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables
+       @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
+       ln -sf $< $@
+else
 $(DESTDIR)$(BINDIR)/ip6tables-restore: ip6tables-restore
        @[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
        cp $< $@
+endif
 
 $(DESTDIR)$(MANDIR)/man8/%.8: %.8
        @[ -d $(DESTDIR)$(MANDIR)/man8 ] || mkdir -p $(DESTDIR)$(MANDIR)/man8
index 8b56c0831cbd6dc0dd152de5ee78b1533dc77a14..f7c360973c7786316f36cc90f9733b09f24b38ea 100644 (file)
@@ -111,7 +111,11 @@ static void free_argv(void) {
                free(newargv[i]);
 }
 
+#ifdef IPTABLES_MULTI
+int ip6tables_restore_main(int argc, char *argv[])
+#else
 int main(int argc, char *argv[])
+#endif
 {
        ip6tc_handle_t handle = NULL;
        char buffer[10240];
index d751fb33c6d8ab7e5e6f4a5a16f960f749ca7195..d828404ca1a3ecaa0c233689e6ad7bd3478dbb00 100644 (file)
@@ -316,7 +316,11 @@ static int do_output(const char *tablename)
  * :Chain name POLICY packets bytes
  * rule
  */
+#ifdef IPTABLES_MULTI
+int ip6tables_save_main(int argc, char *argv[])
+#else
 int main(int argc, char *argv[])
+#endif
 {
        const char *tablename = NULL;
        int c;
index 36dde33141ef136010816979811e386ca9435e3c..b7dfd179b42da8672293518091f64dcf036d153a 100644 (file)
 #include <errno.h>
 #include <ip6tables.h>
 
+#ifdef IPTABLES_MULTI
+int
+ip6tables_main(int argc, char *argv[])
+#else
 int
 main(int argc, char *argv[])
+#endif
 {
        int ret;
        char *table = "filter";