build: resolve link failure for ip6t_NETMAP

Submitted by Jan Engelhardt on Jan. 2, 2013, 8:47 a.m.

Details

Message ID 1357116471-27433-1-git-send-email-jengelh@inai.de
State Accepted
Headers show

Commit Message

Jan Engelhardt Jan. 2, 2013, 8:47 a.m.
Link stage of libip6t_NETMAP failed since recently.

  CCLD     libip6t_NETMAP.so
/usr/lib64/gcc/x86_64-suse-linux/4.7/../../../../x86_64-suse-linux/bin/ld:
cannot find -lip6tc

libip6t_NETMAP.c uses the "ipv6_prefix_length" function from
libip6tc.so; "-lip6tc" is used in the Makefile, but, the directory to
it is not specified.

Why does the link succeed for some people? Because
/usr/lib(64)/libip6tc.so satisfies -lip6tc, but not all environments,
especially those without iptables development files, have that file,
hence this link error can happen.

By suggestion of Mike Frysinger, this patch uses libtool to produce
and link the plugins.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
---

 * use of ../libxtables/libxtables.la

 extensions/GNUmakefile.in |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

Comments

Mike Frysinger Jan. 2, 2013, 5:23 p.m.
Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
Pablo Neira Jan. 2, 2013, 11:50 p.m.
On Wed, Jan 02, 2013 at 12:23:08PM -0500, Mike Frysinger wrote:
> Acked-by: Mike Frysinger <vapier@gentoo.org>

Applied, thanks for your feedback Mike.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry V. Levin Jan. 11, 2013, 11:34 p.m.
Hi,

On Wed, Jan 02, 2013 at 09:47:51AM +0100, Jan Engelhardt wrote:
[...]
> --- a/extensions/GNUmakefile.in
> +++ b/extensions/GNUmakefile.in
[...]
> @@ -75,7 +76,7 @@ install: ${targets_install}
>  	if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;

No, this is a regression.  If ${targets_install} shared objects are made
by libtool, they are intermediate files not expected to be installed by
hand (due to funny RPATHs and so on), so they have to be installed by
libtool --mode=install.

Something like
	for f in $^; do ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=install ${INSTALL} -pm0755 $${f/.so/.la} "${DESTDIR}${xtlibdir}/"; done
would work.

[...]
> @@ -89,19 +90,22 @@ init%.o: init%.c
>  #
>  #	Shared libraries
>  #
> -lib%.so: lib%.oo
> -	${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $< -L../libxtables/.libs -lxtables ${$*_LIBADD};
> +lib%.so: lib%.la
> +	${AM_VERBOSE_NULL} ln -fs .libs/$@ $@
>  
> -lib%.oo: ${srcdir}/lib%.c
> -	${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
> +lib%.la: lib%.lo
> +	${AM_VERBOSE_CCLD} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=link ${CCLD} ${AM_LDFLAGS} -module ${LDFLAGS} -o $@ $< ../libxtables/libxtables.la ${$*_LIBADD} -rpath ${xtlibdir}

Please also add -avoid-version along with -module, otherwise it produces
(and --mode=install installs) useless symlinks.
Dmitry V. Levin Jan. 12, 2013, midnight
On Sat, Jan 12, 2013 at 03:34:30AM +0400, Dmitry V. Levin wrote:
> Hi,
> 
> On Wed, Jan 02, 2013 at 09:47:51AM +0100, Jan Engelhardt wrote:
> [...]
> > --- a/extensions/GNUmakefile.in
> > +++ b/extensions/GNUmakefile.in
> [...]
> > @@ -75,7 +76,7 @@ install: ${targets_install}
> >  	if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;
> 
> No, this is a regression.  If ${targets_install} shared objects are made
> by libtool, they are intermediate files not expected to be installed by
> hand (due to funny RPATHs and so on), so they have to be installed by
> libtool --mode=install.
> 
> Something like
> 	for f in $^; do ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=install ${INSTALL} -pm0755 $${f/.so/.la} "${DESTDIR}${xtlibdir}/"; done
> would work.

No, it didn't work because of ${pfx_symlinks} modules which are not
libtool files.  I've managed to build it with a more complex yet reliable
rule:

	for f in $^; do la="$${f/.so/.la}"; if test -f "$$la"; then ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=install ${INSTALL} -pm0755 "$$la" "${DESTDIR}${xtlibdir}/"; elif test -L "$$f"; then cp -a "$$f" "${DESTDIR}${xtlibdir}/"; else exit 1; fi || exit; done
Jan Engelhardt Jan. 12, 2013, 1:37 a.m.
On Saturday 2013-01-12 00:34, Dmitry V. Levin wrote:
>On Wed, Jan 02, 2013 at 09:47:51AM +0100, Jan Engelhardt wrote:
>[...]
>> --- a/extensions/GNUmakefile.in
>> +++ b/extensions/GNUmakefile.in
>[...]
>> @@ -75,7 +76,7 @@ install: ${targets_install}
>>  	if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;
>
>No, this is a regression.  If ${targets_install} shared objects are made
>by libtool, they are intermediate files not expected to be installed by
>Please also add -avoid-version along with -module, otherwise it produces
>(and --mode=install installs) useless symlinks.

Already posted patches for those -
http://marc.info/?l=netfilter-devel&m=135783093113355&w=2
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch hide | download patch | download mbox

diff --git a/extensions/GNUmakefile.in b/extensions/GNUmakefile.in
index e71e3ff..adad4d6 100644
--- a/extensions/GNUmakefile.in
+++ b/extensions/GNUmakefile.in
@@ -33,6 +33,7 @@  AM_VERBOSE_CXX    = @echo "  CXX     " $@;
 AM_VERBOSE_CXXLD  = @echo "  CXXLD   " $@;
 AM_VERBOSE_AR     = @echo "  AR      " $@;
 AM_VERBOSE_GEN    = @echo "  GEN     " $@;
+AM_VERBOSE_NULL   = @
 endif
 
 #
@@ -75,7 +76,7 @@  install: ${targets_install}
 	if test -n "${targets_install}"; then install -pm0755 $^ "${DESTDIR}${xtlibdir}/"; fi;
 
 clean:
-	rm -f *.o *.oo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c;
+	rm -f *.la *.o *.lo *.so *.a {matches,targets}.man initext.c initext4.c initext6.c;
 	rm -f .*.d .*.dd;
 
 distclean: clean
@@ -89,19 +90,22 @@  init%.o: init%.c
 #
 #	Shared libraries
 #
-lib%.so: lib%.oo
-	${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $< -L../libxtables/.libs -lxtables ${$*_LIBADD};
+lib%.so: lib%.la
+	${AM_VERBOSE_NULL} ln -fs .libs/$@ $@
 
-lib%.oo: ${srcdir}/lib%.c
-	${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
+lib%.la: lib%.lo
+	${AM_VERBOSE_CCLD} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=link ${CCLD} ${AM_LDFLAGS} -module ${LDFLAGS} -o $@ $< ../libxtables/libxtables.la ${$*_LIBADD} -rpath ${xtlibdir}
+
+lib%.lo: ${srcdir}/lib%.c
+	${AM_VERBOSE_CC} ../libtool ${AM_LIBTOOL_SILENT} --tag=CC --mode=compile ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<
 
 libxt_NOTRACK.so: libxt_CT.so
-	ln -fs $< $@
+	${AM_VERBOSE_GEN} ln -fs $< $@
 libxt_state.so: libxt_conntrack.so
-	ln -fs $< $@
+	${AM_VERBOSE_GEN} ln -fs $< $@
 
 # Need the LIBADDs in iptables/Makefile.am too for libxtables_la_LIBADD
-ip6t_NETMAP_LIBADD  = -lip6tc
+ip6t_NETMAP_LIBADD  = ../libiptc/libip6tc.la
 xt_RATEEST_LIBADD   = -lm
 xt_statistic_LIBADD = -lm