101-shared-conditional.patch 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. --- a/configure.ac
  2. +++ b/configure.ac
  3. @@ -102,6 +102,8 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
  4. AC_CHECK_TOOL([READELF], [readelf])
  5. AC_CHECK_TOOL([NM], [nm])
  6. +LT_INIT([shared disable-static])
  7. +
  8. AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))],
  9. ac_cv_visibility, [dnl
  10. save_CFLAGS="$CFLAGS"
  11. @@ -419,7 +421,10 @@ AS_HELP_STRING([--enable-install-elfh],[
  12. AM_CONDITIONAL(INSTALL_ELFH, test "$install_elfh" = yes)
  13. AM_CONDITIONAL(BUILD_STATIC, [dnl
  14. -test "$use_gprof" = yes -o "$use_gcov" = yes])
  15. +test "$use_gprof" = yes -o "$use_gcov" = yes -o "$enable_static" = yes])
  16. +
  17. +AM_CONDITIONAL(BUILD_SHARED, [dnl
  18. +test "$enable_shared" = yes])
  19. AC_ARG_ENABLE([tests-rpath],
  20. AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]),
  21. --- a/libelf/Makefile.am
  22. +++ b/libelf/Makefile.am
  23. @@ -35,8 +35,11 @@ endif
  24. VERSION = 1
  25. lib_LIBRARIES = libelf.a
  26. +if BUILD_SHARED
  27. noinst_LIBRARIES = libelf_pic.a
  28. noinst_DATA = $(noinst_LIBRARIES:_pic.a=.so)
  29. +endif
  30. +
  31. include_HEADERS = libelf.h gelf.h nlist.h
  32. noinst_HEADERS = abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \
  33. @@ -122,11 +125,15 @@ libelf.so: $(srcdir)/libelf.map $(libelf
  34. @$(textrel_check)
  35. $(AM_V_at)ln -fs $@ $@.$(VERSION)
  36. +if BUILD_SHARED
  37. install: install-am libelf.so
  38. $(mkinstalldirs) $(DESTDIR)$(libdir)
  39. $(INSTALL_PROGRAM) libelf.so $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so
  40. ln -fs libelf-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libelf.so.$(VERSION)
  41. ln -fs libelf.so.$(VERSION) $(DESTDIR)$(libdir)/libelf.so
  42. +else
  43. +libelf_a_LIBADD = $(foreach dep,$(libelf_so_DEPS:.so=.a) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep)))
  44. +endif
  45. uninstall: uninstall-am
  46. rm -f $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so
  47. --- a/libdw/Makefile.am
  48. +++ b/libdw/Makefile.am
  49. @@ -35,8 +35,10 @@ AM_CPPFLAGS += -I$(srcdir)/../libebl -I$
  50. VERSION = 1
  51. lib_LIBRARIES = libdw.a
  52. +if BUILD_SHARED
  53. noinst_LIBRARIES = libdw_pic.a
  54. noinst_DATA = $(noinst_LIBRARIES:_pic.a=.so)
  55. +endif
  56. include_HEADERS = dwarf.h
  57. pkginclude_HEADERS = libdw.h known-dwarf.h
  58. @@ -121,11 +123,13 @@ libdw.so: $(srcdir)/libdw.map $(libdw_so
  59. @$(textrel_check)
  60. $(AM_V_at)ln -fs $@ $@.$(VERSION)
  61. +if BUILD_SHARED
  62. install: install-am libdw.so
  63. $(mkinstalldirs) $(DESTDIR)$(libdir)
  64. $(INSTALL_PROGRAM) libdw.so $(DESTDIR)$(libdir)/libdw-$(PACKAGE_VERSION).so
  65. ln -fs libdw-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdw.so.$(VERSION)
  66. ln -fs libdw.so.$(VERSION) $(DESTDIR)$(libdir)/libdw.so
  67. +endif
  68. uninstall: uninstall-am
  69. rm -f $(DESTDIR)$(libdir)/libdw-$(PACKAGE_VERSION).so
  70. @@ -148,6 +152,10 @@ libdw_a_LIBADD += $(addprefix ../backend
  71. libcpu_objects = $(shell $(AR) t ../libcpu/libcpu.a)
  72. libdw_a_LIBADD += $(addprefix ../libcpu/,$(libcpu_objects))
  73. +if !BUILD_SHARED
  74. +libdw_a_LIBADD += $(foreach dep,$(libdw_so_DEPS:.so=.a) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep)))
  75. +endif
  76. +
  77. noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h \
  78. dwarf_sig8_hash.h cfi.h encoded-value.h
  79. --- a/libasm/Makefile.am
  80. +++ b/libasm/Makefile.am
  81. @@ -33,8 +33,11 @@ AM_CPPFLAGS += -I$(top_srcdir)/libelf -I
  82. VERSION = 1
  83. lib_LIBRARIES = libasm.a
  84. +if BUILD_SHARED
  85. noinst_LIBRARIES = libasm_pic.a
  86. noinst_DATA = $(noinst_LIBRARIES:_pic.a=.so)
  87. +endif
  88. +
  89. pkginclude_HEADERS = libasm.h
  90. libasm_a_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \
  91. @@ -71,11 +74,15 @@ libasm.so: $(srcdir)/libasm.map $(libasm
  92. @$(textrel_check)
  93. $(AM_V_at)ln -fs $@ $@.$(VERSION)
  94. +if BUILD_SHARED
  95. install: install-am libasm.so
  96. $(mkinstalldirs) $(DESTDIR)$(libdir)
  97. $(INSTALL_PROGRAM) libasm.so $(DESTDIR)$(libdir)/libasm-$(PACKAGE_VERSION).so
  98. ln -fs libasm-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libasm.so.$(VERSION)
  99. ln -fs libasm.so.$(VERSION) $(DESTDIR)$(libdir)/libasm.so
  100. +else
  101. +libasm_a_LIBADD = $(foreach dep,$(libasm_so_DEPS:.so=.a) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep)))
  102. +endif
  103. uninstall: uninstall-am
  104. rm -f $(DESTDIR)$(libdir)/libasm-$(PACKAGE_VERSION).so
  105. --- a/debuginfod/Makefile.am
  106. +++ b/debuginfod/Makefile.am
  107. @@ -77,8 +77,10 @@ debuginfod_find_LDADD = $(libdw) $(libel
  108. if LIBDEBUGINFOD
  109. noinst_LIBRARIES = libdebuginfod.a
  110. +if BUILD_SHARED
  111. noinst_LIBRARIES += libdebuginfod_pic.a
  112. endif
  113. +endif
  114. libdebuginfod_a_SOURCES = debuginfod-client.c
  115. libdebuginfod_pic_a_SOURCES = debuginfod-client.c
  116. @@ -111,12 +113,16 @@ $(LIBDEBUGINFOD_SONAME): $(srcdir)/libde
  117. libdebuginfod.so: $(LIBDEBUGINFOD_SONAME)
  118. ln -fs $< $@
  119. +if BUILD_SHARED
  120. install: install-am libdebuginfod.so
  121. $(mkinstalldirs) $(DESTDIR)$(libdir)
  122. $(INSTALL_PROGRAM) $(LIBDEBUGINFOD_SONAME) \
  123. $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
  124. ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME)
  125. ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so
  126. +else
  127. +libdebuginfod_a_LIBADD = $(foreach dep,$(wildcard $(libdebuginfod_so_LDLIBS:.so=.a)) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep)))
  128. +endif
  129. uninstall: uninstall-am
  130. rm -f $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so
  131. --- a/tests/Makefile.am
  132. +++ b/tests/Makefile.am
  133. @@ -50,7 +50,7 @@ check_PROGRAMS = arextract arsymtest new
  134. dwfl-report-offline-memory \
  135. varlocs backtrace backtrace-child \
  136. backtrace-data backtrace-dwarf debuglink debugaltlink \
  137. - buildid deleted deleted-lib.so aggregate_size peel_type \
  138. + buildid aggregate_size peel_type \
  139. vdsosyms \
  140. getsrc_die strptr newdata elfstrtab dwfl-proc-attach \
  141. elfshphehdr elfstrmerge dwelfgnucompressed elfgetchdr \
  142. @@ -180,7 +180,7 @@ TESTS = run-arextract.sh run-arsymtest.s
  143. run-readelf-addr.sh run-readelf-str.sh \
  144. run-readelf-multi-noline.sh \
  145. run-readelf-types.sh \
  146. - run-readelf-dwz-multi.sh run-allfcts-multi.sh run-deleted.sh \
  147. + run-readelf-dwz-multi.sh run-allfcts-multi.sh \
  148. run-linkmap-cut.sh run-aggregate-size.sh run-peel-type.sh \
  149. vdsosyms run-readelf-A.sh \
  150. run-getsrc-die.sh run-strptr.sh newdata elfstrtab dwfl-proc-attach \
  151. @@ -284,6 +284,11 @@ funcretval_test__11_SOURCES = funcretval
  152. TESTS += run-funcretval++11.sh
  153. endif
  154. +if BUILD_SHARED
  155. +check_PROGRAMS += deleted deleted-lib.so
  156. +TESTS += run-deleted.sh
  157. +endif
  158. +
  159. EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
  160. run-ar-N.sh \
  161. run-show-die-info.sh run-get-files.sh run-get-lines.sh \