100-debian_shared_lib.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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,13 @@ mandir = @mandir@
  6. srcdir = @srcdir@
  7. VPATH = @srcdir@
  8. +# some defines for shared library compilation
  9. +LIBVERSION=1
  10. +LIBNAME=pcap
  11. +LIBRARY=lib$(LIBNAME).a
  12. +SOLIBRARY=lib$(LIBNAME).so
  13. +SHAREDLIB=$(SOLIBRARY).$(LIBVERSION)
  14. +
  15. #
  16. # You shouldn't need to edit anything below.
  17. #
  18. @@ -69,7 +76,8 @@ INSTALL_RPCAPD=@INSTALL_RPCAPD@
  19. EXTRA_NETWORK_LIBS=@EXTRA_NETWORK_LIBS@
  20. # Standard CFLAGS for building members of a shared library
  21. -FULL_CFLAGS = $(CCOPT) $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
  22. +FULL_CFLAGS = $(CCOPT) $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS) $(CPPFLAGS)
  23. +CFLAGS_SHARED = -shared -Wl,-soname,$(SHAREDLIB)
  24. INSTALL = @INSTALL@
  25. INSTALL_PROGRAM = @INSTALL_PROGRAM@
  26. @@ -84,7 +92,11 @@ YACC = @YACC@
  27. # problem if you don't own the file but can write to the directory.
  28. .c.o:
  29. @rm -f $@
  30. - $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
  31. + $(CC) $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c
  32. +
  33. +%_pic.o: %.c %.o
  34. + @rm -f $@
  35. + $(CC) -fPIC $(FULL_CFLAGS) -c -o $@ $(srcdir)/$*.c
  36. PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ @NETMAP_SRC@ @RDMA_SRC@
  37. FSRC = @V_FINDALLDEVS@
  38. @@ -101,6 +113,7 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(
  39. # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
  40. # hack the extra indirection
  41. OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
  42. +OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
  43. PUBHDR = \
  44. pcap.h \
  45. pcap-bpf.h \
  46. @@ -154,7 +167,7 @@ TAGFILES = \
  47. CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION` \
  48. $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
  49. - lex.yy.c pcap-config libpcap.pc
  50. + lex.yy.c pcap-config libpcap.pc $(OBJ_PIC)
  51. MAN1 = pcap-config.1
  52. @@ -386,7 +399,7 @@ libpcap.a: $(OBJ)
  53. $(AR) rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
  54. $(RANLIB) $@
  55. -shared: libpcap.$(DYEXT)
  56. +shared: $(SHAREDLIB)
  57. libpcap.so: $(OBJ)
  58. @rm -f $@
  59. @@ -462,6 +475,12 @@ libpcap.shareda: $(OBJ)
  60. #
  61. libpcap.none:
  62. +$(SHAREDLIB): $(OBJ_PIC)
  63. + -@rm -f $@
  64. + -@rm -f $(SOLIBRARY)
  65. + $(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $(SHAREDLIB) $(OBJ_PIC) -lc $(LIBS)
  66. + ln -s $(SHAREDLIB) $(SOLIBRARY)
  67. +
  68. scanner.c: $(srcdir)/scanner.l
  69. $(LEX) -P pcap_ --header-file=scanner.h --nounput -o scanner.c $<
  70. scanner.h: scanner.c
  71. @@ -474,6 +493,9 @@ scanner.h: scanner.c
  72. scanner.o: scanner.c grammar.h
  73. $(CC) $(FULL_CFLAGS) -c scanner.c
  74. +scanner_pic.o: scanner.c grammar.h
  75. + $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c scanner.c
  76. +
  77. grammar.c: $(srcdir)/grammar.y
  78. $(YACC) -p pcap_ -o grammar.c -d $<
  79. grammar.h: grammar.c
  80. @@ -486,6 +508,9 @@ grammar.h: grammar.c
  81. grammar.o: grammar.c scanner.h
  82. $(CC) $(FULL_CFLAGS) -c grammar.c
  83. +grammar_pic.o: grammar.c scanner.h
  84. + $(CC) -fPIC $(FULL_CFLAGS) -o $@ -c grammar.c
  85. +
  86. gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
  87. $(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
  88. @@ -524,6 +549,9 @@ pcap-config: $(srcdir)/pcap-config.in ./
  89. mv $@.tmp $@
  90. chmod a+x $@
  91. +bpf_filter_pic.o: bpf_filter.c
  92. + $(CC) -fPIC $(FULL_CFLAGS) -c bpf_filter.c -o $@
  93. +
  94. #
  95. # Remote pcap daemon.
  96. #
  97. @@ -614,14 +642,11 @@ install: install-shared install-archive
  98. $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
  99. install-shared: install-shared-$(DYEXT)
  100. -install-shared-so: libpcap.so
  101. +install-shared-so: $(SHAREDLIB)
  102. [ -d $(DESTDIR)$(libdir) ] || \
  103. (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
  104. - VER=`cat $(srcdir)/VERSION`; \
  105. - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
  106. - $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
  107. - ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
  108. - ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
  109. + $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
  110. + ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY)
  111. install-shared-dylib: libpcap.dylib
  112. [ -d $(DESTDIR)$(libdir) ] || \
  113. (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
  114. --- a/aclocal.m4
  115. +++ b/aclocal.m4
  116. @@ -507,7 +507,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
  117. esac
  118. ;;
  119. esac
  120. - V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT"
  121. + V_SHLIB_CCOPT="$V_SHLIB_CCOPT"
  122. V_SONAME_OPT="-Wl,-soname,"
  123. V_RPATH_OPT="-Wl,-rpath,"
  124. ;;
  125. @@ -570,7 +570,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
  126. #
  127. # "cc" is GCC.
  128. #
  129. - V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
  130. + V_SHLIB_CCOPT="$V_SHLIB_CCOPT"
  131. V_SHLIB_CMD="\$(CC)"
  132. V_SHLIB_OPT="-shared"
  133. V_SONAME_OPT="-Wl,-soname,"
  134. --- a/pcap-config.in
  135. +++ b/pcap-config.in
  136. @@ -41,16 +41,6 @@ do
  137. esac
  138. shift
  139. done
  140. -if [ "$V_RPATH_OPT" != "" ]
  141. -then
  142. - #
  143. - # If libdir isn't /usr/lib, add it to the run-time linker path.
  144. - #
  145. - if [ "$libdir" != "/usr/lib" ]
  146. - then
  147. - RPATH=$V_RPATH_OPT$libdir
  148. - fi
  149. -fi
  150. if [ "$static" = 1 ]
  151. then
  152. #