Mailing List Archive

[PATCH] make make install DESTDIR=xxx work
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/
PPS: Hope I managed to fight Netscape's word wrapping successfully.
Probably the last time I use Netscape to submit patches :(
Re: [PATCH] make make install DESTDIR=xxx work [ In reply to ]
On Wed, Jul 25, 2001 at 12:19:57AM +0200, Peter Firefly Lund wrote:
> 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.

That is exactly how it is _not_ supposed to work.

the DESTDIR stuff is mainly intended for automatic packaging systems
(like RPM) who do out-of-system installs (i.e. into a RPM BuildRoot).

This way you install the files somewhere else in your system, just because
it is easier to package them up from there, and you don't need to be root
to build the package, ...

After you then install the just-built package (RPM, whatever) the files are
on their real locations within the system. And we certainly don't want to
have the DESTDIR compiled into the binaries, exactly for that reason.

Nothing iptables specific, it's the same with almost all packages.

> +.PHONY: default

The phony fixes are valid, I'm including them in the Makefile just now.

> -Peter
> Probably the last time I use Netscape to submit patches :(

maybe a good idea not to use proprietary mail clients anyway :)

--
Live long and prosper
- Harald Welte / laforge@gnumonks.org http://www.gnumonks.org
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M-
V-- PS+ PE-- Y+ PGP++ t++ 5-- !X !R tv-- b+++ DI? !D G+ e* h+ r% y+(*)
Re: [PATCH] make make install DESTDIR=xxx work [ In reply to ]
On Tue, Jul 31, 2001 at 03:31:06PM +0200, Peter Firefly Lund wrote:

> Now, what is then the right way then to install more than one version of
> iptables?
> Should we pass some other environment variable as a -D define into the
> compilation of the iptable binaries so they can find the right ipt_*.so files
> for handling extensions?

you can define IPT_LIBDIR to point to /usr/lib/iptables-1.2.2 or something
else with the version number included.

> It just seemed natural to me that since make install uses DESTDIR to figure
> out where to place the ipt_*.so files, the binaries should be compiled to
> match that destination.

well, as explained in the original mail: no.

> If I send you a patch that uses one more environment variables so both
> scenarios are supported and that defaults to the current way of working, will
> you accept that?

well, as stated above, I don't really see the need. Maybe we could have
the makefile include the version in the IPT_LIBDIR automatically, if you
specify a certain define to the make process. But I don't know... seems
to be a feature which I think is not needed very widely.

> > > +.PHONY: default
> > The phony fixes are valid, I'm including them in the Makefile just now.
>
> Thanks.

Thank you.

> > > -Peter
>
> -Peter

> PS: Btw. got a lot further with our debug today. Seems that it wasn't even a
> netfilter problem but a switch or router problem... arggh. :(

mh. Ironically I'm happy to hear that :)

--
Live long and prosper
- Harald Welte / laforge@gnumonks.org http://www.gnumonks.org
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M-
V-- PS+ PE-- Y+ PGP++ t++ 5-- !X !R tv-- b+++ DI? !D G+ e* h+ r% y+(*)
Re: [PATCH] make make install DESTDIR=xxx work [ In reply to ]
Harald Welte wrote:

> On Wed, Jul 25, 2001 at 12:19:57AM +0200, Peter Firefly Lund wrote:
> > 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.
>
> That is exactly how it is _not_ supposed to work.

Oh?

Thanks for telling me :) (it wasn't really obvious)

> the DESTDIR stuff is mainly intended for automatic packaging systems
> (like RPM) who do out-of-system installs (i.e. into a RPM BuildRoot).

I see... don't have any experience building RPMs and unfortunately still only a
little building Debian packages :/

> This way you install the files somewhere else in your system, just because
> it is easier to package them up from there, and you don't need to be root
> to build the package, ...
>
> After you then install the just-built package (RPM, whatever) the files are
> on their real locations within the system. And we certainly don't want to
> have the DESTDIR compiled into the binaries, exactly for that reason.
>
> Nothing iptables specific, it's the same with almost all packages.

Now, what is then the right way then to install more than one version of
iptables?
Should we pass some other environment variable as a -D define into the
compilation of the iptable binaries so they can find the right ipt_*.so files
for handling extensions?

It just seemed natural to me that since make install uses DESTDIR to figure out
where to place the ipt_*.so files, the binaries should be compiled to match
that destination.
I still have the need, occasionally, to play around with several versions of
some programs, including, I think, iptables.
If I send you a patch that uses one more environment variables so both
scenarios are supported and that defaults to the current way of working, will
you accept that?

> > +.PHONY: default
>
> The phony fixes are valid, I'm including them in the Makefile just now.

Thanks.

> > -Peter
> > Probably the last time I use Netscape to submit patches :(
>
> maybe a good idea not to use proprietary mail clients anyway :)

I'll switch to Evolution Real Soon Now. v0.10 wasn't really good enough, v0.11
should be a lot better but I haven't tried it yet (Not Enough Time :/ ).
Anyway, I send patches from firefly@diku.dk with Pine from now on.

-Peter

PS: Btw. got a lot further with our debug today. Seems that it wasn't even a
netfilter problem but a switch or router problem... arggh. :(