7 +# some defines for shared library compilation
10 +VERSION=$(MAJ).$(MIN)
12 +LIBRARY=lib$(LIBNAME).a
13 +SOLIBRARY=lib$(LIBNAME).so
14 +SHAREDLIB=$(SOLIBRARY).$(VERSION)
17 # You shouldn't need to edit anything below.
22 CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
23 +CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
26 INSTALL_PROGRAM = @INSTALL_PROGRAM@
30 $(CC) $(CFLAGS) -c $(srcdir)/$*.c
31 + $(CC) $(CFLAGS) -c -o $@ $(srcdir)/$*.c
35 + $(CC) -fPIC $(CFLAGS) -c -o $@ $(srcdir)/$*.c
37 PSRC = pcap-@V_PCAP@.c
38 FSRC = fad-@V_FINDALLDEVS@.c
41 # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
42 # hack the extra indirection
43 OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
44 +OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
45 HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
46 ethertype.h gencode.h gnuc.h
50 $(SRC) $(HDR) $(TAGHDR)
52 -CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
53 +CLEANFILES = $(OBJ) $(OBJ_PIC) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c libpcap.so*
56 +all: libpcap.a $(SHAREDLIB)
60 ar rc $@ $(OBJ) $(LIBS)
63 +$(SHAREDLIB): $(OBJ_PIC)
65 + -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ)
66 + $(CC) $(CFLAGS_SHARED) -o $(SHAREDLIB) $(OBJ_PIC) -lc
67 + ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ)
68 + ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY)
71 shared: libpcap.$(DYEXT)
75 scanner.o: scanner.c tokdefs.h
76 $(CC) $(CFLAGS) -c scanner.c
78 +scanner_pic.o: scanner.c tokdefs.h
79 + $(CC) -fPIC $(CFLAGS) -o $@ -c scanner.c
87 $(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
89 +grammar_pic.o: grammar.c
91 + $(CC) -fPIC $(CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
94 $(CC) $(CFLAGS) -c version.c
96 +version_pic.o: version.c
97 + $(CC) -fPIC $(CFLAGS) -c version.c -o $@
99 snprintf.o: $(srcdir)/missing/snprintf.c
100 $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
102 @@ -172,10 +207,17 @@
103 bpf_filter.o: bpf_filter.c
104 $(CC) $(CFLAGS) -c bpf_filter.c
106 +bpf_filter_pic.o: bpf_filter.c
107 + $(CC) -fPIC $(CFLAGS) -c bpf_filter.c -o $@
111 [ -d $(DESTDIR)$(libdir) ] || \
112 (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
113 $(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
114 + $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
115 + ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
116 + ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
117 $(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
118 [ -d $(DESTDIR)$(includedir) ] || \
119 (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))