100-shared-lib.patch 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. --- a/Makefile.in
  2. +++ b/Makefile.in
  3. @@ -37,6 +37,15 @@
  4. srcdir = @srcdir@
  5. VPATH = @srcdir@
  6. +# some defines for shared library compilation
  7. +MAJ=0.9
  8. +MIN=8
  9. +VERSION=$(MAJ).$(MIN)
  10. +LIBNAME=pcap
  11. +LIBRARY=lib$(LIBNAME).a
  12. +SOLIBRARY=lib$(LIBNAME).so
  13. +SHAREDLIB=$(SOLIBRARY).$(VERSION)
  14. +
  15. #
  16. # You shouldn't need to edit anything below.
  17. #
  18. @@ -52,6 +61,7 @@
  19. # Standard CFLAGS
  20. CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
  21. +CFLAGS_SHARED = -shared -Wl,-soname,$(SOLIBRARY).$(MAJ)
  22. INSTALL = @INSTALL@
  23. INSTALL_PROGRAM = @INSTALL_PROGRAM@
  24. @@ -72,7 +82,12 @@
  25. .c.o:
  26. @rm -f $@
  27. $(CC) $(CFLAGS) -c $(srcdir)/$*.c
  28. + $(CC) $(CFLAGS) -c -o $@ $(srcdir)/$*.c
  29. +%_pic.o: %.c
  30. + @rm -f $@
  31. + $(CC) -fPIC $(CFLAGS) -c -o $@ $(srcdir)/$*.c
  32. +
  33. PSRC = pcap-@[email protected]
  34. FSRC = fad-@[email protected]
  35. SSRC = @SSRC@
  36. @@ -86,6 +101,7 @@
  37. # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
  38. # hack the extra indirection
  39. OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
  40. +OBJ_PIC = $(PSRC:.c=_pic.o) $(FSRC:.c=_pic.o) $(CSRC:.c=_pic.o) $(SSRC:.c=_pic.o) $(GENSRC:.c=_pic.o)
  41. HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
  42. ethertype.h gencode.h gnuc.h
  43. GENHDR = \
  44. @@ -97,15 +113,23 @@
  45. TAGFILES = \
  46. $(SRC) $(HDR) $(TAGHDR)
  47. -CLEANFILES = $(OBJ) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c
  48. +CLEANFILES = $(OBJ) $(OBJ_PIC) libpcap.a $(GENSRC) $(GENHDR) lex.yy.c libpcap.so*
  49. -all: libpcap.a
  50. +all: libpcap.a $(SHAREDLIB)
  51. libpcap.a: $(OBJ)
  52. @rm -f $@
  53. ar rc $@ $(OBJ) $(LIBS)
  54. $(RANLIB) $@
  55. +$(SHAREDLIB): $(OBJ_PIC)
  56. + -@rm -f $@
  57. + -@rm -f $(SOLIBRARY) $(SOLIBRARY).$(MAJ)
  58. + $(CC) $(CFLAGS_SHARED) -o $(SHAREDLIB) $(OBJ_PIC) -lc
  59. + ln -s $(SHAREDLIB) $(SOLIBRARY).$(MAJ)
  60. + ln -s $(SOLIBRARY).$(MAJ) $(SOLIBRARY)
  61. +
  62. +
  63. shared: libpcap.$(DYEXT)
  64. #
  65. @@ -131,6 +155,10 @@
  66. scanner.o: scanner.c tokdefs.h
  67. $(CC) $(CFLAGS) -c scanner.c
  68. +scanner_pic.o: scanner.c tokdefs.h
  69. + $(CC) -fPIC $(CFLAGS) -o $@ -c scanner.c
  70. +
  71. +
  72. pcap.o: version.h
  73. tokdefs.h: grammar.c
  74. @@ -144,9 +172,16 @@
  75. @rm -f $@
  76. $(CC) $(CFLAGS) -Dyylval=pcap_lval -c grammar.c
  77. +grammar_pic.o: grammar.c
  78. + @rm -f $@
  79. + $(CC) -fPIC $(CFLAGS) -Dyylval=pcap_lval -o $@ -c grammar.c
  80. +
  81. version.o: version.c
  82. $(CC) $(CFLAGS) -c version.c
  83. +version_pic.o: version.c
  84. + $(CC) -fPIC $(CFLAGS) -c version.c -o $@
  85. +
  86. snprintf.o: $(srcdir)/missing/snprintf.c
  87. $(CC) $(CFLAGS) -o $@ -c $(srcdir)/missing/snprintf.c
  88. @@ -172,10 +207,17 @@
  89. bpf_filter.o: bpf_filter.c
  90. $(CC) $(CFLAGS) -c bpf_filter.c
  91. +bpf_filter_pic.o: bpf_filter.c
  92. + $(CC) -fPIC $(CFLAGS) -c bpf_filter.c -o $@
  93. +
  94. +
  95. install: libpcap.a
  96. [ -d $(DESTDIR)$(libdir) ] || \
  97. (mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
  98. $(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
  99. + $(INSTALL_DATA) $(SHAREDLIB) $(DESTDIR)$(libdir)/
  100. + ln -sf $(SHAREDLIB) $(DESTDIR)$(libdir)/$(SOLIBRARY).$(MAJ)
  101. + ln -sf $(SOLIBRARY).$(MAJ) $(DESTDIR)$(libdir)/$(SOLIBRARY)
  102. $(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
  103. [ -d $(DESTDIR)$(includedir) ] || \
  104. (mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))