finally move buildroot-ng to trunk
[openwrt/staging/dedeckeh.git] / package / libpcap / patches / 100-shared-lib.patch
1 diff -urN libpcap-0.9.4.orig/Makefile.in libpcap-0.9.4/Makefile.in
2 --- libpcap-0.9.4.orig/Makefile.in 2003-12-15 02:35:03.000000000 +0100
3 +++ libpcap-0.9.4/Makefile.in 2006-02-05 16:56:18.000000000 +0100
4 @@ -37,6 +37,15 @@
5 srcdir = @srcdir@
6 VPATH = @srcdir@
7
8 +# some defines for shared library compilation
9 +MAJ=0.9
10 +MIN=4
11 +VERSION=$(MAJ).$(MIN)
12 +LIBNAME=pcap
13 +LIBRARY=lib$(LIBNAME).a
14 +SOLIBRARY=lib$(LIBNAME).so
15 +SHAREDLIB=$(SOLIBRARY).$(VERSION)
16 +
17 #
18 # You shouldn't need to edit anything below.
19 #
20 @@ -50,6 +59,7 @@
21
22 # Standard CFLAGS
23 CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
24 +CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
25
26 INSTALL = @INSTALL@
27 INSTALL_PROGRAM = @INSTALL_PROGRAM@
28 @@ -70,7 +80,12 @@
29 .c.o:
30 @rm -f $@
31 $(CC) $(CFLAGS) -c $(srcdir)/$*.c
32 + $(CC) $(CFLAGS) -c -o $@ $(srcdir)/$*.c
33
34 +%_pic.o: %.c
35 + @rm -f $@
36 + $(CC) -fPIC $(CFLAGS) -c -o $@ $(srcdir)/$*.c
37 +
38 PSRC = pcap-@V_PCAP@.c
39 FSRC = fad-@V_FINDALLDEVS@.c
40 SSRC = @SSRC@
41 @@ -84,6 +99,7 @@
42 # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
43 # hack the extra indirection
44 OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
45 +OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
46 HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
47 ethertype.h gencode.h gnuc.h
48 GENHDR = \
49 @@ -95,15 +111,23 @@
50 TAGFILES = \
51 $(SRC) $(HDR) $(TAGHDR)
52
53 -CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
54 +CLEANFILES = $(OBJ) $(OBJ_PIC) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c libpcap.so*
55
56 -all: libpcap.a
57 +all: libpcap.a $(SHAREDLIB)
58
59 libpcap.a: $(OBJ)
60 @rm -f $@
61 ar rc $@ $(OBJ) $(LIBS)
62 $(RANLIB) $@
63
64 +$(SHAREDLIB): $(OBJ_PIC)
65 + -@rm -f $@
66 + -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ)
67 + $(CC) $(CFLAGS_SHARED) -o $(SHAREDLIB) $(OBJ_PIC) -lc
68 + ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ)
69 + ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY)
70 +
71 +
72 shared: libpcap.$(DYEXT)
73
74 #
75 @@ -129,6 +153,10 @@
76 scanner.o: scanner.c tokdefs.h
77 $(CC) $(CFLAGS) -c scanner.c
78
79 +scanner_pic.o: scanner.c tokdefs.h
80 + $(CC) -fPIC $(CFLAGS) -o $@ -c scanner.c
81 +
82 +
83 pcap.o: version.h
84
85 tokdefs.h: grammar.c
86 @@ -142,9 +170,16 @@
87 @rm -f $@
88 $(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
89
90 +grammar_pic.o: grammar.c
91 + @rm -f $@
92 + $(CC) -fPIC $(CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
93 +
94 version.o: version.c
95 $(CC) $(CFLAGS) -c version.c
96
97 +version_pic.o: version.c
98 + $(CC) -fPIC $(CFLAGS) -c version.c -o $@
99 +
100 snprintf.o: $(srcdir)/missing/snprintf.c
101 $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
102
103 @@ -170,10 +205,17 @@
104 bpf_filter.o: bpf_filter.c
105 $(CC) $(CFLAGS) -c bpf_filter.c
106
107 +bpf_filter_pic.o: bpf_filter.c
108 + $(CC) -fPIC $(CFLAGS) -c bpf_filter.c -o $@
109 +
110 +
111 install: libpcap.a
112 [ -d $(DESTDIR)$(libdir) ] || \
113 (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
114 $(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
115 + $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
116 + ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
117 + ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
118 $(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
119 [ -d $(DESTDIR)$(includedir) ] || \
120 (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))