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