libpcap: update to 1.9.0
[openwrt/staging/mkresin.git] / package / libs / libpcap / patches / 100-debian_shared_lib.patch
1 Debian-specific modifications to the upstream Makefile.in to
2 build a shared library.
3
4 --- a/Makefile.in
5 +++ b/Makefile.in
6 @@ -40,6 +40,13 @@ mandir = @mandir@
7 srcdir = @srcdir@
8 VPATH = @srcdir@
9
10 +# some defines for shared library compilation
11 +LIBVERSION=1
12 +LIBNAME=pcap
13 +LIBRARY=lib$(LIBNAME).a
14 +SOLIBRARY=lib$(LIBNAME).so
15 +SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
16 +
17 #
18 # You shouldn't need to edit anything below.
19 #
20 @@ -69,7 +76,8 @@ INSTALL_RPCAPD=@INSTALL_RPCAPD@
21 EXTRA_NETWORK_LIBS=@EXTRA_NETWORK_LIBS@
22
23 # Standard CFLAGS for building members of a shared library
24 -FULL_CFLAGS = $(CCOPT) $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
25 +FULL_CFLAGS = $(CCOPT) $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS) $(CPPFLAGS)
26 +CFLAGS_SHARED = -shared -Wl,-soname,$(SHAREDLIB)
27
28 INSTALL = @INSTALL@
29 INSTALL_PROGRAM = @INSTALL_PROGRAM@
30 @@ -84,7 +92,11 @@ YACC = @YACC@
31 # problem if you don't own the file but can write to the directory.
32 .c.o:
33 @rm -f $@
34 - $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
35 + $(CC) $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c
36 +
37 +%_pic.o: %.c %.o
38 + @rm -f $@
39 + $(CC) -fPIC $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c
40
41 PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ @NETMAP_SRC@ @RDMA_SRC@
42 FSRC = @V_FINDALLDEVS@
43 @@ -101,6 +113,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(
44 # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
45 # hack the extra indirection
46 OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
47 +OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
48 PUBHDR = \
49 pcap.h \
50 pcap-bpf.h \
51 @@ -154,7 +167,7 @@ TAGFILES = \
52
53 CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION` \
54 $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
55 - lex.yy.c pcap-config libpcap.pc
56 + lex.yy.c pcap-config libpcap.pc $(OBJ_PIC)
57
58 MAN1 = pcap-config.1
59
60 @@ -386,7 +399,7 @@ libpcap.a: $(OBJ)
61 $(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
62 $(RANLIB) $@
63
64 -shared: libpcap.$(DYEXT)
65 +shared: $(SHAREDLIB)
66
67 libpcap.so: $(OBJ)
68 @rm -f $@
69 @@ -462,6 +475,12 @@ libpcap.shareda: $(OBJ)
70 #
71 libpcap.none:
72
73 +$(SHAREDLIB): $(OBJ_PIC)
74 + -@rm -f $@
75 + -@rm -f $(SOLIBRARY)
76 + $(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $(SHAREDLIB) $(OBJ_PIC) -lc $(LIBS)
77 + ln -s $(SHAREDLIB) $(SOLIBRARY)
78 +
79 scanner.c: $(srcdir)/scanner.l
80 $(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $<
81 scanner.h: scanner.c
82 @@ -474,6 +493,9 @@ scanner.h: scanner.c
83 scanner.o: scanner.c grammar.h
84 $(CC) $(FULL_CFLAGS) -c scanner.c
85
86 +scanner_pic.o: scanner.c grammar.h
87 + $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c scanner.c
88 +
89 grammar.c: $(srcdir)/grammar.y
90 $(YACC) -p pcap_ -o grammar.c -d $<
91 grammar.h: grammar.c
92 @@ -486,6 +508,9 @@ grammar.h: grammar.c
93 grammar.o: grammar.c scanner.h
94 $(CC) $(FULL_CFLAGS) -c grammar.c
95
96 +grammar_pic.o: grammar.c scanner.h
97 + $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c grammar.c
98 +
99 gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
100 $(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
101
102 @@ -524,6 +549,9 @@ pcap-config: $(srcdir)/pcap-config.in ./
103 mv $@.tmp $@
104 chmod a+x $@
105
106 +bpf_filter_pic.o: bpf_filter.c
107 + $(CC) -fPIC $(FULL_CFLAGS) -c bpf_filter.c -o $@
108 +
109 #
110 # Remote pcap daemon.
111 #
112 @@ -614,14 +642,11 @@ install: install-shared install-archive
113 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
114
115 install-shared: install-shared-$(DYEXT)
116 -install-shared-so: libpcap.so
117 +install-shared-so: $(SHAREDLIB)
118 [ -d $(DESTDIR)$(libdir) ] || \
119 (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
120 - VER=`cat $(srcdir)/VERSION`; \
121 - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
122 - $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
123 - ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
124 - ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
125 + $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
126 + ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY)
127 install-shared-dylib: libpcap.dylib
128 [ -d $(DESTDIR)$(libdir) ] || \
129 (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
130 --- a/aclocal.m4
131 +++ b/aclocal.m4
132 @@ -507,7 +507,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
133 esac
134 ;;
135 esac
136 - V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT"
137 + V_SHLIB_CCOPT="$V_SHLIB_CCOPT"
138 V_SONAME_OPT="-Wl,-soname,"
139 V_RPATH_OPT="-Wl,-rpath,"
140 ;;
141 @@ -570,7 +570,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
142 #
143 # "cc" is GCC.
144 #
145 - V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
146 + V_SHLIB_CCOPT="$V_SHLIB_CCOPT"
147 V_SHLIB_CMD="\$(CC)"
148 V_SHLIB_OPT="-shared"
149 V_SONAME_OPT="-Wl,-soname,"
150 --- a/pcap-config.in
151 +++ b/pcap-config.in
152 @@ -41,16 +41,6 @@ do
153 esac
154 shift
155 done
156 -if [ "$V_RPATH_OPT" != "" ]
157 -then
158 - #
159 - # If libdir isn't /usr/lib, add it to the run-time linker path.
160 - #
161 - if [ "$libdir" != "/usr/lib" ]
162 - then
163 - RPATH=$V_RPATH_OPT$libdir
164 - fi
165 -fi
166 if [ "$static" = 1 ]
167 then
168 #