1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
--- libpcap-0.8.3-orig/Makefile.in 2003-12-15 02:42:23.000000000 +0100
+++ libpcap-0.8.3-7/Makefile.in 2005-03-08 03:38:22.000000000 +0100
@@ -37,6 +37,15 @@
srcdir = @srcdir@
VPATH = @srcdir@
+# some defines for shared library compilation
+MAJ=0.8
+MIN=3
+VERSION=$(MAJ).$(MIN)
+LIBNAME=pcap
+LIBRARY=lib$(LIBNAME).a
+SOLIBRARY=lib$(LIBNAME).so
+SHAREDLIB=$(SOLIBRARY).$(VERSION)
+
#
# You shouldn't need to edit anything below.
#
@@ -49,6 +58,7 @@
# Standard CFLAGS
CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
+CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -68,7 +78,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
FSRC = fad-@V_FINDALLDEVS@.c
@@ -83,6 +97,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)
HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
ethertype.h gencode.h gnuc.h
GENHDR = \
@@ -94,15 +109,22 @@
TAGFILES = \
$(SRC) $(HDR) $(TAGHDR)
-CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
+CLEANFILES = $(OBJ) $(OBJ_PIC) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c libpcap.so*
-all: libpcap.a
+all: libpcap.a $(SHAREDLIB)
libpcap.a: $(OBJ)
@rm -f $@
ar rc $@ $(OBJ) $(LIBS)
$(RANLIB) $@
+$(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 $@
$(LEX) -t $< > $$$$.$@; mv $$$$.$@ $@
@@ -110,6 +132,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
@@ -123,9 +148,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
@@ -151,10 +184,16 @@
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 $@
+
install:
[ -d $(DESTDIR)$(libdir) ] || \
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
+ $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
+ ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
+ ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
[ -d $(DESTDIR)$(includedir) ] || \
(mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
|