1 Debian-specific modifications to the upstream Makefile.in to
2 build a shared library.
4 Makefile.in | 45 ++++++++++++++++++++++++++++++++++++++++++---
7 3 files changed, 44 insertions(+), 5 deletions(-)
11 @@ -40,6 +40,14 @@ mandir = @mandir@
15 +# some defines for shared library compilation
19 +LIBRARY=lib$(LIBNAME).a
20 +SOLIBRARY=lib$(LIBNAME).so
21 +SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
24 # You shouldn't need to edit anything below.
26 @@ -59,6 +67,7 @@ PROG=libpcap
29 CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
30 +CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
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.
38 - $(CC) $(CFLAGS) -c $(srcdir)/$*.c
39 + $(CC) $(CFLAGS) -c -o $@ $(srcdir)/$*.c
43 + $(CC) -fPIC $(CFLAGS) -c -o $@ $(srcdir)/$*.c
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)
55 @@ -131,7 +145,7 @@ TAGFILES = \
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)
64 @@ -324,21 +338,14 @@ EXTRA_DIST = \
65 Win32/Src/inet_net.c \
68 -all: libpcap.a shared pcap-config
69 +all: libpcap.a shared pcap-config $(SHAREDLIB)
73 ar rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
76 -shared: libpcap.$(DYEXT)
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)
87 # The following rule succeeds, but the result is untested.
88 @@ -409,6 +416,13 @@ libpcap.shareda: $(OBJ)
92 +$(SHAREDLIB): $(OBJ_PIC)
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)
99 scanner.c: $(srcdir)/scanner.l
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
106 +scanner_pic.o: scanner.c tokdefs.h
107 + $(CC) -fPIC $(CFLAGS) -o $@ -c scanner.c
112 @@ -429,9 +446,17 @@ grammar.o: grammar.c
114 $(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
116 +grammar_pic.o: grammar.c
118 + $(CC) -fPIC $(CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
121 $(CC) $(CFLAGS) -c version.c
123 +version_pic.o: version.c
124 + $(CC) -fPIC $(CFLAGS) -c version.c -o $@
127 snprintf.o: $(srcdir)/missing/snprintf.c
128 $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
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
134 +bpf_filter_pic.o: bpf_filter.c
135 + $(CC) -fPIC $(CFLAGS) -c bpf_filter.c -o $@
138 # Generate the pcap-config script.
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
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))
161 @@ -3229,7 +3229,7 @@ _ACEOF
162 # or accepts command-line arguments like
163 # those the GNU linker accepts.
165 - V_CCOPT="$V_CCOPT -fpic"
167 V_SONAME_OPT="-Wl,-soname,"
168 V_RPATH_OPT="-Wl,-rpath,"
170 @@ -3292,7 +3292,7 @@ _ACEOF
174 - V_CCOPT="$V_CCOPT -fpic"
177 V_SHLIB_OPT="-shared"
178 V_SONAME_OPT="-Wl,-soname,"