libpcap: update to 1.3.0
[openwrt/svn-archive/archive.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,14 @@
7 srcdir = @srcdir@
8 VPATH = @srcdir@
9
10 +# some defines for shared library compilation
11 +MAJ=1.3
12 +LIBVERSION=$(MAJ).0
13 +LIBNAME=pcap
14 +LIBRARY=lib$(LIBNAME).a
15 +SOLIBRARY=lib$(LIBNAME).so
16 +SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
17 +
18 #
19 # You shouldn't need to edit anything below.
20 #
21 @@ -60,7 +68,8 @@
22 PROG=libpcap
23
24 # Standard CFLAGS
25 -FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
26 +FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) $(CPPFLAGS)
27 +CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
28
29 INSTALL = @INSTALL@
30 INSTALL_PROGRAM = @INSTALL_PROGRAM@
31 @@ -80,7 +89,11 @@
32 # problem if you don't own the file but can write to the directory.
33 .c.o:
34 @rm -f $@
35 - $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
36 + $(CC) $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c
37 +
38 +%_pic.o: %.c
39 + @rm -f $@
40 + $(CC) -fPIC $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c
41
42 PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@
43 FSRC = fad-@V_FINDALLDEVS@.c
44 @@ -96,6 +109,7 @@
45 # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
46 # hack the extra indirection
47 OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
48 +OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
49 PUBHDR = \
50 pcap.h \
51 pcap-bpf.h \
52 @@ -148,7 +162,7 @@
53
54 CLEANFILES = $(OBJ) libpcap.* $(TESTS) \
55 $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
56 - lex.yy.c pcap-config
57 + lex.yy.c pcap-config $(OBJ_PIC)
58
59 MAN1 = pcap-config.1
60
61 @@ -352,7 +366,7 @@
62 $(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
63 $(RANLIB) $@
64
65 -shared: libpcap.$(DYEXT)
66 +shared: $(SHAREDLIB)
67
68 libpcap.so: $(OBJ)
69 @rm -f $@
70 @@ -430,6 +444,13 @@
71 #
72 libpcap.none:
73
74 +$(SHAREDLIB): $(OBJ_PIC)
75 + -@rm -f $@
76 + -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ)
77 + $(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $(SHAREDLIB) $(OBJ_PIC) -lc $(LIBS)
78 + ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ)
79 + ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY)
80 +
81 scanner.c: $(srcdir)/scanner.l
82 @rm -f $@
83 $(srcdir)/runlex.sh $(LEX) -o$@ $<
84 @@ -437,6 +458,9 @@
85 scanner.o: scanner.c tokdefs.h
86 $(CC) $(FULL_CFLAGS) -c scanner.c
87
88 +scanner_pic.o: scanner.c tokdefs.h
89 + $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c scanner.c
90 +
91 pcap.o: version.h
92
93 tokdefs.h: grammar.c
94 @@ -450,9 +474,16 @@
95 @rm -f $@
96 $(CC) $(FULL_CFLAGS) -Dyylval=pcap_lval -c grammar.c
97
98 +grammar_pic.o: grammar.c
99 + @rm -f $@
100 + $(CC) -fPIC $(FULL_CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
101 +
102 version.o: version.c
103 $(CC) $(FULL_CFLAGS) -c version.c
104
105 +version_pic.o: version.c
106 + $(CC) -fPIC $(FULL_CFLAGS) -c version.c -o $@
107 +
108 snprintf.o: $(srcdir)/missing/snprintf.c
109 $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
110
111 @@ -490,6 +521,9 @@
112 bpf_filter.o: bpf_filter.c
113 $(CC) $(FULL_CFLAGS) -c bpf_filter.c
114
115 +bpf_filter_pic.o: bpf_filter.c
116 + $(CC) -fPIC $(FULL_CFLAGS) -c bpf_filter.c -o $@
117 +
118 #
119 # Generate the pcap-config script.
120 #
121 @@ -607,11 +641,9 @@
122 install-shared-so: libpcap.so
123 [ -d $(DESTDIR)$(libdir) ] || \
124 (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
125 - VER=`cat $(srcdir)/VERSION`; \
126 - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
127 - $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
128 - ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
129 - ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
130 + $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
131 + ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
132 + ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
133 install-shared-dylib: libpcap.dylib
134 [ -d $(DESTDIR)$(libdir) ] || \
135 (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
136 --- a/aclocal.m4
137 +++ b/aclocal.m4
138 @@ -262,7 +262,7 @@
139 esac
140 ;;
141 esac
142 - V_CCOPT="$V_CCOPT $PIC_OPT"
143 + V_CCOPT="$V_CCOPT"
144 V_SONAME_OPT="-Wl,-soname,"
145 V_RPATH_OPT="-Wl,-rpath,"
146 ;;
147 @@ -325,7 +325,7 @@
148 #
149 # "cc" is GCC.
150 #
151 - V_CCOPT="$V_CCOPT -fpic"
152 + V_CCOPT="$V_CCOPT"
153 V_SHLIB_CMD="\$(CC)"
154 V_SHLIB_OPT="-shared"
155 V_SONAME_OPT="-Wl,-soname,"
156 --- a/pcap-config.in
157 +++ b/pcap-config.in
158 @@ -36,16 +36,6 @@
159 esac
160 shift
161 done
162 -if [ "$V_RPATH_OPT" != "" ]
163 -then
164 - #
165 - # If libdir isn't /usr/lib, add it to the run-time linker path.
166 - #
167 - if [ "$libdir" != "/usr/lib" ]
168 - then
169 - RPATH=$V_RPATH_OPT$libdir
170 - fi
171 -fi
172 if [ "$static" = 1 ]
173 then
174 #