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