allow targets to define a default subtarget when using automatic subtarget detection...
[openwrt.git] / package / libpcap / patches / 100-debian_shared_lib.patch
1 Debian-specific modifications to the upstream Makefile.in to
2 build a shared library.
3 ---
4 Makefile.in | 45 ++++++++++++++++++++++++++++++++++++++++++---
5 configure | 2 +-
6 configure.in | 2 +-
7 3 files changed, 44 insertions(+), 5 deletions(-)
8
9 --- a/Makefile.in
10 +++ b/Makefile.in
11 @@ -40,6 +40,14 @@ mandir = @mandir@
12 srcdir = @srcdir@
13 VPATH = @srcdir@
14
15 +# some defines for shared library compilation
16 +MAJ=1.1
17 +LIBVERSION=$(MAJ).1
18 +LIBNAME=pcap
19 +LIBRARY=lib$(LIBNAME).a
20 +SOLIBRARY=lib$(LIBNAME).so
21 +SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
22 +
23 #
24 # You shouldn't need to edit anything below.
25 #
26 @@ -59,6 +67,7 @@ PROG=libpcap
27
28 # Standard CFLAGS
29 CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
30 +CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
31
32 INSTALL = @INSTALL@
33 INSTALL_PROGRAM = @INSTALL_PROGRAM@
34 @@ -78,7 +87,11 @@ YACC = @V_YACC@
35 # problem if you don't own the file but can write to the directory.
36 .c.o:
37 @rm -f $@
38 - $(CC) $(CFLAGS) -c $(srcdir)/$*.c
39 + $(CC) $(CFLAGS) -c -o $@ $(srcdir)/$*.c
40 +
41 +%_pic.o: %.c
42 + @rm -f $@
43 + $(CC) -fPIC $(CFLAGS) -c -o $@ $(srcdir)/$*.c
44
45 PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@
46 FSRC = fad-@V_FINDALLDEVS@.c
47 @@ -94,6 +107,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(
48 # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
49 # hack the extra indirection
50 OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
51 +OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
52 PUBHDR = \
53 pcap.h \
54 pcap-bpf.h \
55 @@ -131,7 +145,7 @@ TAGFILES = \
56
57 CLEANFILES = $(OBJ) libpcap.* filtertest findalldevstest selpolltest \
58 opentest $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
59 - lex.yy.c pcap-config
60 + lex.yy.c pcap-config $(OBJ_PIC)
61
62 MAN1 = pcap-config.1
63
64 @@ -324,21 +338,14 @@ EXTRA_DIST = \
65 Win32/Src/inet_net.c \
66 Win32/Src/inet_pton.c
67
68 -all: libpcap.a shared pcap-config
69 +all: libpcap.a shared pcap-config $(SHAREDLIB)
70
71 libpcap.a: $(OBJ)
72 @rm -f $@
73 ar rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
74 $(RANLIB) $@
75
76 -shared: libpcap.$(DYEXT)
77 -
78 -libpcap.so: $(OBJ)
79 - @rm -f $@
80 - VER=`cat $(srcdir)/VERSION`; \
81 - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
82 - @V_SHLIB_CMD@ @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER $(LDFLAGS) \
83 - -o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
84 +shared: $(SHAREDLIB)
85
86 #
87 # The following rule succeeds, but the result is untested.
88 @@ -409,6 +416,13 @@ libpcap.shareda: $(OBJ)
89 #
90 libpcap.none:
91
92 +$(SHAREDLIB): $(OBJ_PIC)
93 + -@rm -f $@
94 + -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ)
95 + $(CC) $(CFLAGS_SHARED) -o $(SHAREDLIB) $(OBJ_PIC) -lc
96 + ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ)
97 + ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY)
98 +
99 scanner.c: $(srcdir)/scanner.l
100 @rm -f $@
101 $(srcdir)/runlex.sh $(LEX) -o$@ $<
102 @@ -416,6 +430,9 @@ scanner.c: $(srcdir)/scanner.l
103 scanner.o: scanner.c tokdefs.h
104 $(CC) $(CFLAGS) -c scanner.c
105
106 +scanner_pic.o: scanner.c tokdefs.h
107 + $(CC) -fPIC $(CFLAGS) -o $@ -c scanner.c
108 +
109 pcap.o: version.h
110
111 tokdefs.h: grammar.c
112 @@ -429,9 +446,17 @@ grammar.o: grammar.c
113 @rm -f $@
114 $(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
115
116 +grammar_pic.o: grammar.c
117 + @rm -f $@
118 + $(CC) -fPIC $(CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
119 +
120 version.o: version.c
121 $(CC) $(CFLAGS) -c version.c
122
123 +version_pic.o: version.c
124 + $(CC) -fPIC $(CFLAGS) -c version.c -o $@
125 +
126 +
127 snprintf.o: $(srcdir)/missing/snprintf.c
128 $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
129
130 @@ -469,6 +494,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt
131 bpf_filter.o: bpf_filter.c
132 $(CC) $(CFLAGS) -c bpf_filter.c
133
134 +bpf_filter_pic.o: bpf_filter.c
135 + $(CC) -fPIC $(CFLAGS) -c bpf_filter.c -o $@
136 +
137 #
138 # Generate the pcap-config script.
139 #
140 @@ -562,14 +590,12 @@ install: install-shared install-archive
141 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
142
143 install-shared: install-shared-$(DYEXT)
144 -install-shared-so: libpcap.so
145 +install-shared-so: $(SHAREDLIB)
146 [ -d $(DESTDIR)$(libdir) ] || \
147 (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
148 - VER=`cat $(srcdir)/VERSION`; \
149 - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
150 - $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
151 - ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
152 - ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
153 + $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
154 + ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
155 + ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
156 install-shared-dylib: libpcap.dylib
157 [ -d $(DESTDIR)$(libdir) ] || \
158 (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
159 --- a/configure
160 +++ b/configure
161 @@ -3229,7 +3229,7 @@ _ACEOF
162 # or accepts command-line arguments like
163 # those the GNU linker accepts.
164 #
165 - V_CCOPT="$V_CCOPT -fpic"
166 + V_CCOPT="$V_CCOPT"
167 V_SONAME_OPT="-Wl,-soname,"
168 V_RPATH_OPT="-Wl,-rpath,"
169 ;;
170 @@ -3292,7 +3292,7 @@ _ACEOF
171 #
172 # "cc" is GCC.
173 #
174 - V_CCOPT="$V_CCOPT -fpic"
175 + V_CCOPT="$V_CCOPT"
176 V_SHLIB_CMD="\$(CC)"
177 V_SHLIB_OPT="-shared"
178 V_SONAME_OPT="-Wl,-soname,"
This page took 0.057154 seconds and 5 git commands to generate.