100-debian_shared_lib.patch 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. Debian-specific modifications to the upstream Makefile.in to
  2. build a shared library.
  3. --- a/Makefile.in
  4. +++ b/Makefile.in
  5. @@ -40,6 +40,14 @@ mandir = @mandir@
  6. srcdir = @srcdir@
  7. VPATH = @srcdir@
  8. +# some defines for shared library compilation
  9. +MAJ=0.8
  10. +LIBVERSION=$(shell head -1 debian/changelog | perl -nle 'm/\S+\s+\((\S+)-\S+\)/ and print $$1')
  11. +LIBNAME=pcap
  12. +LIBRARY=lib$(LIBNAME).a
  13. +SOLIBRARY=lib$(LIBNAME).so
  14. +SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
  15. +
  16. #
  17. # You shouldn't need to edit anything below.
  18. #
  19. @@ -69,7 +77,8 @@ INSTALL_RPCAPD=@INSTALL_RPCAPD@
  20. EXTRA_NETWORK_LIBS=@EXTRA_NETWORK_LIBS@
  21. # Standard CFLAGS for building members of a shared library
  22. -FULL_CFLAGS = $(CCOPT) @V_LIB_CCOPT_FAT@ $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
  23. +FULL_CFLAGS = $(CCOPT) @V_LIB_CCOPT_FAT@ $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS) $(CPPFLAGS)
  24. +CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ) -Wl,--version-script=libpcap-symbols.lds
  25. INSTALL = @INSTALL@
  26. INSTALL_PROGRAM = @INSTALL_PROGRAM@
  27. @@ -84,7 +93,11 @@ YACC = @YACC@
  28. # problem if you don't own the file but can write to the directory.
  29. .c.o:
  30. @rm -f $@
  31. - $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
  32. + $(CC) $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c
  33. +
  34. +%_pic.o: %.c
  35. + @rm -f $@
  36. + $(CC) -fPIC $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c
  37. PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ @NETMAP_SRC@ @RDMA_SRC@
  38. FSRC = @V_FINDALLDEVS@
  39. @@ -101,6 +114,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(
  40. # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
  41. # hack the extra indirection
  42. OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
  43. +OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o) $(LIBOBJS:.o=_pic.o)
  44. PUBHDR = \
  45. pcap.h \
  46. pcap-bpf.h \
  47. @@ -155,7 +169,7 @@ TAGFILES = \
  48. CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION` \
  49. $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
  50. - lex.yy.c pcap-config libpcap.pc
  51. + lex.yy.c pcap-config libpcap.pc $(OBJ_PIC)
  52. MAN1 = pcap-config.1
  53. @@ -392,7 +406,7 @@ libpcap.a: $(OBJ)
  54. $(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
  55. $(RANLIB) $@
  56. -shared: libpcap.$(DYEXT)
  57. +shared: $(SHAREDLIB)
  58. libpcap.so: $(OBJ)
  59. @rm -f $@
  60. @@ -468,6 +482,13 @@ libpcap.shareda: $(OBJ)
  61. #
  62. libpcap.none:
  63. +$(SHAREDLIB): $(OBJ_PIC)
  64. + -@rm -f $@
  65. + -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ)
  66. + $(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $(SHAREDLIB) $(OBJ_PIC) -lc $(LIBS)
  67. + ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ)
  68. + ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY)
  69. +
  70. scanner.c: $(srcdir)/scanner.l
  71. $(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $<
  72. scanner.h: scanner.c
  73. @@ -480,6 +501,9 @@ scanner.h: scanner.c
  74. scanner.o: scanner.c grammar.h
  75. $(CC) $(FULL_CFLAGS) -c scanner.c
  76. +scanner_pic.o: scanner.c grammar.h
  77. + $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c scanner.c
  78. +
  79. grammar.c: $(srcdir)/grammar.y
  80. $(YACC) -p pcap_ -o grammar.c -d $<
  81. grammar.h: grammar.c
  82. @@ -492,6 +516,10 @@ grammar.h: grammar.c
  83. grammar.o: grammar.c scanner.h
  84. $(CC) $(FULL_CFLAGS) -c grammar.c
  85. +grammar_pic.o: grammar.c
  86. + @rm -f $@
  87. + $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c grammar.c
  88. +
  89. gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
  90. $(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
  91. @@ -504,9 +532,17 @@ snprintf.o: $(srcdir)/missing/snprintf.c
  92. strlcat.o: $(srcdir)/missing/strlcat.c
  93. $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
  94. +strlcat_pic.o: $(srcdir)/missing/strlcat.c
  95. + @rm -f $@
  96. + $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcat.c
  97. +
  98. strlcpy.o: $(srcdir)/missing/strlcpy.c
  99. $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
  100. +strlcpy_pic.o: $(srcdir)/missing/strlcpy.c
  101. + @rm -f $@
  102. + $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c
  103. +
  104. strtok_r.o: $(srcdir)/missing/strtok_r.c
  105. $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strtok_r.c
  106. @@ -539,6 +575,9 @@ pcap-config: $(srcdir)/pcap-config.in ./
  107. mv $@.tmp $@
  108. chmod a+x $@
  109. +bpf_filter_pic.o: bpf_filter.c
  110. + $(CC) -fPIC $(FULL_CFLAGS) -c bpf_filter.c -o $@
  111. +
  112. #
  113. # Remote pcap daemon.
  114. #
  115. @@ -635,11 +674,9 @@ install-shared: install-shared-$(DYEXT)
  116. install-shared-so: libpcap.so
  117. [ -d $(DESTDIR)$(libdir) ] || \
  118. (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
  119. - VER=`cat $(srcdir)/VERSION`; \
  120. - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
  121. - $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
  122. - ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
  123. - ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
  124. + $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
  125. + ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
  126. + ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
  127. install-shared-dylib: libpcap.dylib
  128. [ -d $(DESTDIR)$(libdir) ] || \
  129. (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
  130. --- a/aclocal.m4
  131. +++ b/aclocal.m4
  132. @@ -507,7 +507,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
  133. esac
  134. ;;
  135. esac
  136. - V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT"
  137. + V_SHLIB_CCOPT="$V_SHLIB_CCOPT"
  138. V_SONAME_OPT="-Wl,-soname,"
  139. V_RPATH_OPT="-Wl,-rpath,"
  140. ;;
  141. @@ -570,7 +570,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
  142. #
  143. # "cc" is GCC.
  144. #
  145. - V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
  146. + V_SHLIB_CCOPT="$V_SHLIB_CCOPT"
  147. V_SHLIB_CMD="\$(CC)"
  148. V_SHLIB_OPT="-shared"
  149. V_SONAME_OPT="-Wl,-soname,"
  150. --- /dev/null
  151. +++ b/libpcap-symbols.lds
  152. @@ -0,0 +1,106 @@
  153. +{
  154. + global:
  155. + bpf_dump;
  156. + bpf_filter;
  157. + bpf_image;
  158. + bpf_validate;
  159. + eproto_db;
  160. + pcap_breakloop;
  161. + pcap_can_set_rfmon;
  162. + pcap_close;
  163. + pcap_compile;
  164. + pcap_compile_nopcap;
  165. + pcap_datalink;
  166. + pcap_datalink_name_to_val;
  167. + pcap_datalink_val_to_description;
  168. + pcap_datalink_val_to_name;
  169. + pcap_dispatch;
  170. + pcap_dump;
  171. + pcap_dump_close;
  172. + pcap_dump_file;
  173. + pcap_dump_flush;
  174. + pcap_dump_fopen;
  175. + pcap_dump_ftell;
  176. + pcap_dump_open;
  177. + pcap_ether_aton;
  178. + pcap_ether_hostton;
  179. + pcap_file;
  180. + pcap_fileno;
  181. + pcap_findalldevs;
  182. + pcap_fopen_offline;
  183. + pcap_freealldevs;
  184. + pcap_freecode;
  185. + pcap_get_selectable_fd;
  186. + pcap_geterr;
  187. + pcap_getnonblock;
  188. + pcap_inject;
  189. + pcap_is_swapped;
  190. + pcap_lib_version;
  191. + pcap_list_datalinks;
  192. + pcap_lookupdev;
  193. + pcap_lookupnet;
  194. + pcap_loop;
  195. + pcap_major_version;
  196. + pcap_minor_version;
  197. + pcap_nametoaddr;
  198. + pcap_nametoaddrinfo;
  199. + pcap_nametoeproto;
  200. + pcap_nametollc;
  201. + pcap_nametonetaddr;
  202. + pcap_nametoport;
  203. + pcap_nametoportrange;
  204. + pcap_nametoproto;
  205. + pcap_next;
  206. + pcap_next_etherent;
  207. + pcap_next_ex;
  208. + pcap_open_dead;
  209. + pcap_open_live;
  210. + pcap_open_offline;
  211. + pcap_perror;
  212. + pcap_sendpacket;
  213. + pcap_set_datalink;
  214. + pcap_setdirection;
  215. + pcap_setfilter;
  216. + pcap_setnonblock;
  217. + pcap_snapshot;
  218. + pcap_stats;
  219. + pcap_statustostr;
  220. + pcap_strerror;
  221. + pcap_version;
  222. + /* introduced in pcap 1.0 */
  223. + pcap_activate;
  224. + pcap_create;
  225. + pcap_datalink_ext;
  226. + pcap_free_datalinks;
  227. + pcap_offline_filter;
  228. + pcap_set_buffer_size;
  229. + pcap_set_promisc;
  230. + pcap_set_rfmon;
  231. + pcap_set_snaplen;
  232. + pcap_set_timeout;
  233. + /* introduced in pcap 1.2 */
  234. + pcap_set_tstamp_type;
  235. + pcap_list_tstamp_types;
  236. + pcap_free_tstamp_types;
  237. + pcap_tstamp_type_name_to_val;
  238. + pcap_tstamp_type_val_to_name;
  239. + pcap_tstamp_type_val_to_description;
  240. + /* introduced in pcap 1.5 */
  241. + pcap_set_immediate_mode;
  242. + pcap_set_tstamp_precision;
  243. + pcap_get_tstamp_precision;
  244. + pcap_open_dead_with_tstamp_precision;
  245. + pcap_open_offline_with_tstamp_precision;
  246. + pcap_fopen_offline_with_tstamp_precision;
  247. + /* introduced in pcap 1.7 */
  248. + pcap_dump_open_append;
  249. + /* introduced in pcap 1.9.0 */
  250. + pcap_bufsize;
  251. + pcap_dump_ftell64;
  252. + pcap_get_required_select_timeout;
  253. + pcap_set_protocol_linux; /* linux-only */
  254. + /* introduced in pcap 1.9.1 */
  255. + pcap_datalink_val_to_description_or_dlt;
  256. + local:
  257. + *;
  258. +};