amd64 and -fPIC
Roman Neuhauser
neuhauser at sigpipe.cz
Wed Mar 29 01:00:29 UTC 2006
# kris at obsecurity.org / 2006-02-19 23:38:13 -0500:
> On Mon, Feb 20, 2006 at 05:18:15AM +0100, pfgshield-freebsd at yahoo.com wrote:
(relocation errors in -fPIC-less static libraries on amd64)
> The best solution is to make the port also build a shared version;
> it's usually not that difficult to modify the makefile. That way you
> don't have to add nasty hacks.
>
> Kris
Bruce,
net/libpcap port installs libpcap.so and libpcap.so.2 only with
-DLIBPCAP_OVERWRITE_BASE, and has CFLAGS+=-fPIC on amd64.
- Should the -fPIC be dropped?
- Should the port install the .so even without the
LIBPCAP_OVERWRITE_BASE flag?
- If yes, what about the (upstream) /usr/local/lib/libpcap.so.0.9.4
vs /usr/lib/libpcap.so.2 that's in files/patchbase-Makefile.in?
Please see the attached patch. It
- replaces files/patchbase-Makefile.in with an INSTALL_TARGET
- installs libpcap.so{,.2} unconditionally. I'm not sure the
LIBPCAP_SOVER handling is correct, but can fix the patch according
to your instructions (The code is broken at least when
${LIBPCAP_SOVER} equals ${PORTVERSION}).
- drops -fPIC
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/net/libpcap/Makefile,v
retrieving revision 1.7
diff -u -r1.7 Makefile
--- Makefile 13 Dec 2005 00:13:50 -0000 1.7
+++ Makefile 29 Mar 2006 00:47:54 -0000
@@ -16,26 +16,25 @@
COMMENT= Ubiquitous network traffic capture library
WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION}
+INSTALL_TARGET= install install-shared
MAN3= pcap.3
GNU_CONFIGURE= yes
USE_BISON= yes
+INSTALLS_SHLIB= yes
.if defined(LIBPCAP_OVERWRITE_BASE)
PREFIX= /usr
PKGNAMESUFFIX= -overwrite-base
MANPREFIX= ${PREFIX}/share
CONFIGURE_ARGS+=--mandir=${MANPREFIX}/man
-PLIST_SUB+= NOTBASE="@comment "
-PLIST_SUB+= BASE=""
-EXTRA_PATCHES+= ${FILESDIR}/patchbase-Makefile.in
PKGMESSAGE= ${FILESDIR}/pkg-message-base
-.else
-PLIST_SUB+= BASE="@comment "
-PLIST_SUB+= NOTBASE=""
.endif
+LIBPCAP_SOVER= 2
+PLIST_SUB+= LIBPCAP_SOVER="${LIBPCAP_SOVER}"
+
.if !defined(WITHOUT_IPV6)
CONFIGURE_ARGS+= --enable-ipv6
.endif
@@ -44,15 +43,14 @@
CONFIGURE_ARGS+= --without-dag
.endif
+display-pkg-message: .USE
.if defined(LIBPCAP_OVERWRITE_BASE)
-post-install:
${CAT} ${PKGMESSAGE}
.endif
-.include <bsd.port.pre.mk>
-
-.if ${ARCH} == "amd64"
-CFLAGS+= -fPIC
-.endif
+post-install: display-pkg-message
+ cd ${PREFIX}/lib/ && \
+ ${MV} libpcap.so.${PORTVERSION} libpcap.so.${LIBPCAP_SOVER} && \
+ ${LN} -sf libpcap.so.${LIBPCAP_SOVER} libpcap.so
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
Index: pkg-plist
===================================================================
RCS file: /home/ncvs/ports/net/libpcap/pkg-plist,v
retrieving revision 1.2
diff -u -r1.2 pkg-plist
--- pkg-plist 13 Jan 2004 18:04:51 -0000 1.2
+++ pkg-plist 29 Mar 2006 00:47:54 -0000
@@ -1,6 +1,6 @@
lib/libpcap.a
-%%BASE%%lib/libpcap.so.2
-%%BASE%%lib/libpcap.so
+lib/libpcap.so.%%LIBPCAP_SOVER%%
+lib/libpcap.so
include/pcap.h
include/pcap-namedb.h
include/pcap-bpf.h
Index: files/patchbase-Makefile.in
===================================================================
RCS file: files/patchbase-Makefile.in
diff -N files/patchbase-Makefile.in
--- files/patchbase-Makefile.in 13 Jan 2004 18:04:51 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
---- Makefile.in.orig Thu Jan 8 16:38:30 2004
-+++ Makefile.in Thu Jan 8 16:41:40 2004
-@@ -96,13 +96,17 @@
-
- CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
-
--all: libpcap.a
-+all: libpcap.a libpcap.so.2
-
- libpcap.a: $(OBJ)
- @rm -f $@
- ar rc $@ $(OBJ) $(LIBS)
- $(RANLIB) $@
-
-+libpcap.so.2: $(OBJ)
-+ @rm -f $@
-+ $(CC) -shared -Wl,-x -o libpcap.so.2 -Wl,-soname,libpcap.so.2 `lorder *.o | tsort -q`
-+
- scanner.c: $(srcdir)/scanner.l
- @rm -f $@
- $(LEX) -t $< > $$$$.$@; mv $$$$.$@ $@
-@@ -154,6 +158,8 @@
- install:
- [ -d $(DESTDIR)$(libdir) ] || \
- (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
-+ $(INSTALL_DATA) libpcap.so.2 $(DESTDIR)$(libdir)/libpcap.so.2
-+ ln -fs $(DESTDIR)$(libdir)/libpcap.so.2 $(DESTDIR)$(libdir)/libpcap.so
- $(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
- $(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
- [ -d $(DESTDIR)$(includedir) ] || \
More information about the freebsd-ports
mailing list