100-debian_shared_lib.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. Debian-specific modifications to the upstream Makefile.in to
  2. build a shared library.
  3. --- a/Makefile.in
  4. +++ b/Makefile.in
  5. @@ -38,6 +38,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. @@ -62,7 +69,8 @@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
  19. PROG=libpcap
  20. # Standard CFLAGS
  21. -FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS)
  22. +FULL_CFLAGS = $(CCOPT) $(INCLS) $(DEFS) $(CFLAGS) $(CPPFLAGS)
  23. +CFLAGS_SHARED = -shared -Wl,-soname,$(SHAREDLIB)
  24. INSTALL = @INSTALL@
  25. INSTALL_PROGRAM = @INSTALL_PROGRAM@
  26. @@ -77,7 +85,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@
  37. FSRC = @V_FINDALLDEVS@
  38. @@ -93,6 +105,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. @@ -157,7 +170,7 @@ TAGFILES = \
  47. CLEANFILES = $(OBJ) libpcap.* $(TESTS) \
  48. $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \
  49. - lex.yy.c pcap-config
  50. + lex.yy.c pcap-config $(OBJ_PIC)
  51. MAN1 = pcap-config.1
  52. @@ -365,7 +378,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. @@ -443,6 +456,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. @@ -455,6 +474,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. pcap.o: pcap_version.h
  78. grammar.c: $(srcdir)/grammar.y
  79. @@ -472,9 +494,16 @@ grammar.o: grammar.c
  80. gencode.o: $(srcdir)/gencode.c grammar.h scanner.h
  81. $(CC) $(FULL_CFLAGS) -c $(srcdir)/gencode.c
  82. +grammar_pic.o: grammar.c
  83. + @rm -f $@
  84. + $(CC) -fPIC $(FULL_CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
  85. +
  86. version.o: version.c
  87. $(CC) $(FULL_CFLAGS) -c version.c
  88. +version_pic.o: version.c
  89. + $(CC) -fPIC $(FULL_CFLAGS) -c version.c -o $@
  90. +
  91. snprintf.o: $(srcdir)/missing/snprintf.c
  92. $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
  93. @@ -501,6 +530,9 @@ bpf_filter.c: $(srcdir)/bpf/net/bpf_filt
  94. bpf_filter.o: bpf_filter.c
  95. $(CC) $(FULL_CFLAGS) -c bpf_filter.c
  96. +bpf_filter_pic.o: bpf_filter.c
  97. + $(CC) -fPIC $(FULL_CFLAGS) -c bpf_filter.c -o $@
  98. +
  99. #
  100. # Generate the pcap-config script.
  101. #
  102. @@ -623,14 +655,11 @@ install: install-shared install-archive
  103. $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
  104. install-shared: install-shared-$(DYEXT)
  105. -install-shared-so: libpcap.so
  106. +install-shared-so: $(SHAREDLIB)
  107. [ -d $(DESTDIR)$(libdir) ] || \
  108. (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
  109. - VER=`cat $(srcdir)/VERSION`; \
  110. - MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
  111. - $(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
  112. - ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
  113. - ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
  114. + $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
  115. + ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY)
  116. install-shared-dylib: libpcap.dylib
  117. [ -d $(DESTDIR)$(libdir) ] || \
  118. (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
  119. --- a/aclocal.m4
  120. +++ b/aclocal.m4
  121. @@ -470,7 +470,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
  122. esac
  123. ;;
  124. esac
  125. - V_CCOPT="$V_CCOPT $PIC_OPT"
  126. + V_CCOPT="$V_CCOPT"
  127. V_SONAME_OPT="-Wl,-soname,"
  128. V_RPATH_OPT="-Wl,-rpath,"
  129. ;;
  130. @@ -533,7 +533,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
  131. #
  132. # "cc" is GCC.
  133. #
  134. - V_CCOPT="$V_CCOPT -fpic"
  135. + V_CCOPT="$V_CCOPT"
  136. V_SHLIB_CMD="\$(CC)"
  137. V_SHLIB_OPT="-shared"
  138. V_SONAME_OPT="-Wl,-soname,"
  139. --- a/pcap-config.in
  140. +++ b/pcap-config.in
  141. @@ -36,16 +36,6 @@ do
  142. esac
  143. shift
  144. done
  145. -if [ "$V_RPATH_OPT" != "" ]
  146. -then
  147. - #
  148. - # If libdir isn't /usr/lib, add it to the run-time linker path.
  149. - #
  150. - if [ "$libdir" != "/usr/lib" ]
  151. - then
  152. - RPATH=$V_RPATH_OPT$libdir
  153. - fi
  154. -fi
  155. if [ "$static" = 1 ]
  156. then
  157. #