This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
lsts_glued/rules/libpcap/patches/10_shared_lib.diff

181 lines
4.7 KiB
Diff

Debian-specific modifications to the upstream Makefile.in to
build a shared library.
---
Makefile.in | 49 +++++++++++++++++++++++++++++++++++++++++--------
aclocal.m4 | 4 ++--
configure | 4 ++--
3 files changed, 45 insertions(+), 12 deletions(-)
--- a/Makefile.in
+++ b/Makefile.in
@@ -40,6 +40,14 @@
srcdir = @srcdir@
VPATH = @srcdir@
+# some defines for shared library compilation
+MAJ=1.0
+LIBVERSION=1
+LIBNAME=pcap
+LIBRARY=lib$(LIBNAME).a
+SOLIBRARY=lib$(LIBNAME).so
+SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
+
#
# You shouldn't need to edit anything below.
#
@@ -59,6 +67,7 @@
# Standard CFLAGS
CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
+CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -78,7 +87,11 @@
# problem if you don't own the file but can write to the directory.
.c.o:
@rm -f $@
- $(CC) $(CFLAGS) -c $(srcdir)/$*.c
+ $(CC) $(CFLAGS) -c -o $@ $(srcdir)/$*.c
+
+%_pic.o: %.c
+ @rm -f $@
+ $(CC) -fPIC $(CFLAGS) -c -o $@ $(srcdir)/$*.c
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@
FSRC = fad-@V_FINDALLDEVS@.c
@@ -94,6 +107,7 @@
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
# hack the extra indirection
OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
+OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
PUBHDR = \
pcap.h \
pcap-bpf.h \
@@ -131,7 +145,7 @@
CLEANFILES = $(OBJ) libpcap.* filtertest findalldevstest selpolltest \
opentest $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
- lex.yy.c pcap-config
+ lex.yy.c pcap-config $(OBJ_PIC)
MAN1 = pcap-config.1
@@ -331,7 +345,7 @@
ar rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
$(RANLIB) $@
-shared: libpcap.$(DYEXT)
+shared: $(SHAREDLIB)
libpcap.so: $(OBJ)
@rm -f $@
@@ -409,6 +423,13 @@
#
libpcap.none:
+$(SHAREDLIB): $(OBJ_PIC)
+ -@rm -f $@
+ -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ)
+ $(CC) $(CFLAGS_SHARED) -o $(SHAREDLIB) $(OBJ_PIC) -lc
+ ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ)
+ ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY)
+
scanner.c: $(srcdir)/scanner.l
@rm -f $@
$(srcdir)/runlex.sh $(LEX) -o$@ $<
@@ -416,6 +437,9 @@
scanner.o: scanner.c tokdefs.h
$(CC) $(CFLAGS) -c scanner.c
+scanner_pic.o: scanner.c tokdefs.h
+ $(CC) -fPIC $(CFLAGS) -o $@ -c scanner.c
+
pcap.o: version.h
tokdefs.h: grammar.c
@@ -429,9 +453,17 @@
@rm -f $@
$(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
+grammar_pic.o: grammar.c
+ @rm -f $@
+ $(CC) -fPIC $(CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
+
version.o: version.c
$(CC) $(CFLAGS) -c version.c
+version_pic.o: version.c
+ $(CC) -fPIC $(CFLAGS) -c version.c -o $@
+
+
snprintf.o: $(srcdir)/missing/snprintf.c
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
@@ -469,6 +501,9 @@
bpf_filter.o: bpf_filter.c
$(CC) $(CFLAGS) -c bpf_filter.c
+bpf_filter_pic.o: bpf_filter.c
+ $(CC) -fPIC $(CFLAGS) -c bpf_filter.c -o $@
+
#
# Generate the pcap-config script.
#
@@ -565,11 +600,9 @@
install-shared-so: libpcap.so
[ -d $(DESTDIR)$(libdir) ] || \
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
- VER=`cat $(srcdir)/VERSION`; \
- MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
- $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
- ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
- ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
+ $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
+ ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
+ ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
install-shared-dylib: libpcap.dylib
[ -d $(DESTDIR)$(libdir) ] || \
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -245,7 +245,7 @@
# or accepts command-line arguments like
# those the GNU linker accepts.
#
- V_CCOPT="$V_CCOPT -fpic"
+ V_CCOPT="$V_CCOPT"
V_SONAME_OPT="-Wl,-soname,"
V_RPATH_OPT="-Wl,-rpath,"
;;
@@ -308,7 +308,7 @@
#
# "cc" is GCC.
#
- V_CCOPT="$V_CCOPT -fpic"
+ V_CCOPT="$V_CCOPT"
V_SHLIB_CMD="\$(CC)"
V_SHLIB_OPT="-shared"
V_SONAME_OPT="-Wl,-soname,"
--- a/configure
+++ b/configure
@@ -3229,7 +3229,7 @@
# or accepts command-line arguments like
# those the GNU linker accepts.
#
- V_CCOPT="$V_CCOPT -fpic"
+ V_CCOPT="$V_CCOPT"
V_SONAME_OPT="-Wl,-soname,"
V_RPATH_OPT="-Wl,-rpath,"
;;
@@ -3292,7 +3292,7 @@
#
# "cc" is GCC.
#
- V_CCOPT="$V_CCOPT -fpic"
+ V_CCOPT="$V_CCOPT"
V_SHLIB_CMD="\$(CC)"
V_SHLIB_OPT="-shared"
V_SONAME_OPT="-Wl,-soname,"