Mailing List Archive

[PATCH] make make install DESTDIR=xxx work (improved - no wordwrap)
Since iptables and ip6tables load extensions from shared libraries at
run-time, the destination patch for the shared library files must be
compiled into the programs. Also a few .PHONY targets.

patch: make-install-destdir.patch
description: compile IPT_LIB_DIR /with/ $DESTDIR into iptables/ip6tables.
==================== Cut here =================
--- cvs/netfilter/userspace/Makefile Fri May 11 23:41:47 2001
+++ netfilter/userspace/Makefile Tue Jul 24 23:44:16 2001
@@ -7,6 +7,11 @@
NETFILTER_VERSION:=1.2.2
OLD_NETFILTER_VERSION:=1.2.1a

+# Where to install the programs
+ifndef DESTDIR
+DESTDIR=
+endif
+
# Waiting for inclusions in the kernel tree.
PENDING_PATCHES:=
# These went in previous kernels.
@@ -58,16 +63,19 @@
IPT_LIBDIR:=$(LIBDIR)/iptables
endif

+.PHONY: default
default: print-extensions all

+.PHONY: print-extensions
print-extensions:
@[ -n "$(OPTIONALS)" ] && echo Extensions found: $(OPTIONALS)

+.PHONY: pending-patches
pending-patches:
@cd patch-o-matic && KERNEL_DIR=$(KERNEL_DIR) ./runme $(PENDING_PATCHES)

iptables.o: iptables.c
- $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
+ $(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(DESTDIR)$(IPT_LIBDIR)\" -c -o $@ $<

iptables: iptables-standalone.c iptables.o libiptc/libiptc.a
$(CC) $(CFLAGS) -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
@@ -91,7 +99,7 @@
cp $< $@

ip6tables.o: ip6tables.c
- $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -c -o $@ $<
+ $(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(DESTDIR)$(IPT_LIBDIR)\" -c -o $@ $<

ip6tables: ip6tables-standalone.c ip6tables.o libiptc/libiptc.a
$(CC) $(CFLAGS) -DIP6T_LIB_DIR=\"$(IPT_LIBDIR)\" -rdynamic -o $@ $^ -ldl
@@ -125,20 +133,25 @@


# Development Targets
+.PHONY: install-devel-man3
install-devel-man3: $(DEVEL_MAN3)
@[ -d $(DESTDIR)$(MANDIR)/man3 ] || mkdir -p $(DESTDIR)$(MANDIR)/man3
@cp -v $(DEVEL_MAN3) $(DESTDIR)$(MANDIR)/man3

+.PHONY: install-devel-headers
install-devel-headers: $(DEVEL_HEADERS)
@[ -d $(DESTDIR)$(INCDIR) ] || mkdir -p $(DESTDIR)$(INCDIR)
@cp -v $(DEVEL_HEADERS) $(DESTDIR)$(INCDIR)

+.PHONY: install-devel-libs
install-devel-libs: $(DEVEL_LIBS)
@[ -d $(DESTDIR)$(LIBDIR) ] || mkdir -p $(DESTDIR)$(LIBDIR)
@cp -v $(DEVEL_LIBS) $(DESTDIR)$(LIBDIR)

+.PHONY: install-devel
install-devel: all install-devel-man3 install-devel-headers install-devel-libs

+.PHONY: distclean
distclean: clean
@rm -f TAGS `find . -name '*~' -o -name '.*~'` `find . -name '*.rej'` `find . -name '*.d'` .makefirst

@@ -147,30 +160,36 @@
@cd $@ && KERNEL_DIR=$(KERNEL_DIR) ./runme

# Rusty's distro magic.
+.PHONY: distrib
distrib: check distclean delrelease /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2 diff md5sums # nowhitespace

# Makefile must not define:
# -g -pg
# And must define -NDEBUG
+.PHONY: check
check:
@if echo $(CFLAGS) | egrep -e '-g|-pg' >/dev/null; then echo Remove debugging flags; exit 1; else exit 0; fi
@if echo $(CFLAGS) | egrep -e NDEBUG >/dev/null; then exit 0; else echo Define -DNDEBUG; exit 1; fi

+.PHONY: nowhitespace
nowhitespace:
@if grep -n '[ ]$$' `find . -name 'Makefile' -o -name '*.[ch]'`; then exit 1; else exit 0; fi

+.PHONY: delrelease
delrelease:
rm -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2

/home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2:
cd .. && ln -sf userspace iptables-$(NETFILTER_VERSION) && tar cvf - --exclude CVS iptables-$(NETFILTER_VERSION)/. | bzip2 -9 > $@ && rm iptables-$(NETFILTER_VERSION)

+.PHONY: diff
diff: /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
@mkdir /tmp/diffdir
@cd /tmp/diffdir && tar -x --bzip2 -f /home/public/netfilter/iptables-$(NETFILTER_VERSION).tar.bz2
@set -e; cd /tmp/diffdir; tar -x --bzip2 -f /home/public/netfilter/iptables-$(OLD_NETFILTER_VERSION).tar.bz2; echo Creating patch-iptables-$(OLD_NETFILTER_VERSION)-$(NETFILTER_VERSION).bz2; diff -urN iptables-$(OLD_NETFILTER_VERSION) iptables-$(NETFILTER_VERSION) | bzip2 -9 > /home/public/netfilter/patch-iptables-$(OLD_NETFILTER_VERSION)-$(NETFILTER_VERSION).bz2
@rm -rf /tmp/diffdir

+.PHONY: md5sums
md5sums:
cd /home/public/netfilter/ && md5sum patch-iptables-*-$(NETFILTER_VERSION).bz2 iptables-$(NETFILTER_VERSION).tar.bz2


-Peter

PS: See also http://oss.one2one-networks.com/