summaryrefslogtreecommitdiff
path: root/package/libpcap/patches/100-debian_shared_lib.patch
blob: 1c1f8c1e3b8a27adb6dfaf494b92b54fe4ec962d (plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
Debian-specific modifications to the upstream Makefile.in to
build a shared library.
---
 Makefile.in  |   45 ++++++++++++++++++++++++++++++++++++++++++---
 configure    |    2 +-
 configure.in |    2 +-
 3 files changed, 44 insertions(+), 5 deletions(-)

--- a/Makefile.in
+++ b/Makefile.in
@@ -40,6 +40,14 @@ mandir = @mandir@
 srcdir = @srcdir@
 VPATH = @srcdir@
 
+# some defines for shared library compilation
+MAJ=1.1
+LIBVERSION=$(MAJ).1
+LIBNAME=pcap
+LIBRARY=lib$(LIBNAME).a
+SOLIBRARY=lib$(LIBNAME).so
+SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
+
 #
 # You shouldn't need to edit anything below.
 #
@@ -59,6 +67,7 @@ PROG=libpcap
 
 # Standard CFLAGS
 CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
+CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
 
 INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -78,7 +87,11 @@ YACC = @V_YACC@
 # 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 @USB_SRC@ @BT_SRC@ @CAN_SRC@
 FSRC =  fad-@V_FINDALLDEVS@.c
@@ -94,6 +107,7 @@ SRC =	$(PSRC) $(FSRC) $(CSRC) $(SSRC) $(
 # 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)
 PUBHDR = \
 	pcap.h \
 	pcap-bpf.h \
@@ -131,7 +145,7 @@ TAGFILES = \
 
 CLEANFILES = $(OBJ) libpcap.* filtertest findalldevstest selpolltest \
 	opentest $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
-	lex.yy.c pcap-config
+	lex.yy.c pcap-config $(OBJ_PIC)
 
 MAN1 = pcap-config.1
 
@@ -324,7 +338,7 @@ EXTRA_DIST = \
 	Win32/Src/inet_net.c \
 	Win32/Src/inet_pton.c
 
-all: libpcap.a shared pcap-config
+all: libpcap.a shared pcap-config $(SHAREDLIB)
 
 libpcap.a: $(OBJ)
 	@rm -f $@
@@ -409,6 +423,13 @@ libpcap.shareda: $(OBJ)
 #
 libpcap.none:
 
+$(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 $@
 	$(srcdir)/runlex.sh $(LEX) -o$@ $<
@@ -416,6 +437,9 @@ scanner.c: $(srcdir)/scanner.l
 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
@@ -429,9 +453,17 @@ grammar.o: grammar.c
 	@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
 
@@ -469,6 +501,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt
 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 $@
+
 #
 # Generate the pcap-config script.
 #
@@ -604,6 +639,9 @@ install-archive-so install-archive-dylib
 	    (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
 	$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
 	$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
+	$(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
+	ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
+	ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
 install-archive-shareda:
 	#
 	# AIX, however, doesn't, so we don't install the archive
--- a/configure
+++ b/configure
@@ -3229,7 +3229,7 @@ _ACEOF
 		    # or accepts command-line arguments like
 		    # those the GNU linker accepts.
 		    #
-		    V_CCOPT="$V_CCOPT -fpic"
+		    V_CCOPT="$V_CCOPT"
 		    V_SONAME_OPT="-Wl,-soname,"
 		    V_RPATH_OPT="-Wl,-rpath,"
 		    ;;
@@ -3292,7 +3292,7 @@ _ACEOF
 		    #
 		    # "cc" is GCC.
 		    #
-		    V_CCOPT="$V_CCOPT -fpic"
+		    V_CCOPT="$V_CCOPT"
 		    V_SHLIB_CMD="\$(CC)"
 		    V_SHLIB_OPT="-shared"
 		    V_SONAME_OPT="-Wl,-soname,"