public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Allow to choose to build shared or static library
@ 2016-10-11 14:11 Akihiko Odaki
  0 siblings, 0 replies; 2+ messages in thread
From: Akihiko Odaki @ 2016-10-11 14:11 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 8925 bytes --]

Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
---
 backends/Makefile.am |  9 ++++++---
 configure.ac         | 11 ++++++++++-
 libasm/Makefile.am   | 11 +++++++----
 libdw/Makefile.am    | 25 ++++++++++++++-----------
 libdwelf/Makefile.am |  6 +++++-
 libdwfl/Makefile.am  |  9 ++++++---
 libebl/Makefile.am   |  2 ++
 libelf/Makefile.am   | 17 ++++++++++-------
 8 files changed, 60 insertions(+), 30 deletions(-)

diff --git a/backends/Makefile.am b/backends/Makefile.am
index b553ec3..d576099 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -34,6 +34,11 @@ AM_CPPFLAGS += -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \
 
 modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \
 	  tilegx m68k bpf
+
+noinst_HEADERS = libebl_CPU.h common-reloc.c linux-core-note.c x86_corenote.c
+EXTRA_DIST = $(foreach m,$(modules),$($(m)_SRCS)) $(modules:=_reloc.def)
+
+if BUILD_SHARED
 libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a    \
 	     libebl_ia64_pic.a libebl_alpha_pic.a libebl_arm_pic.a    \
 	     libebl_aarch64_pic.a libebl_sparc_pic.a libebl_ppc_pic.a \
@@ -158,9 +163,7 @@ uninstall: uninstall-am
 	done
 	rmdir --ignore-fail-on-non-empty $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)
 
-noinst_HEADERS = libebl_CPU.h common-reloc.c linux-core-note.c x86_corenote.c
-EXTRA_DIST = $(foreach m,$(modules),$($(m)_SRCS)) $(modules:=_reloc.def)
-
 CLEANFILES += $(foreach m,$(modules),\
 			libebl_$(m).map libebl_$(m).so \
 			$(am_libebl_$(m)_pic_a_OBJECTS))
+endif
diff --git a/configure.ac b/configure.ac
index e5503f1..3b06071 100644
--- a/configure.ac
+++ b/configure.ac
@@ -206,8 +206,17 @@ if test "$use_valgrind" = yes; then
 fi
 AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes)
 
+AC_ARG_ENABLE([static],
+AS_HELP_STRING([--enable-static],[enable static library]), [static=$enableval], [static=no])
+
 AM_CONDITIONAL(BUILD_STATIC, [dnl
-test "$use_gprof" = yes -o "$use_gcov" = yes])
+test "$use_gprof" = yes -o "$use_gcov" = yes -o "$static" = no])
+
+AC_ARG_ENABLE([shared],
+AS_HELP_STRING([--disable-shared],[disable shared library]), [shared=$enableval], [shared=yes])
+
+AM_CONDITIONAL(BUILD_SHARED, [dnl
+test "$shared" = yes])
 
 AC_ARG_ENABLE([tests-rpath],
 AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]),
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index 8094b05..8abe2f1 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -34,8 +34,6 @@ GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
 VERSION = 1
 
 lib_LIBRARIES = libasm.a
-noinst_LIBRARIES = libasm_pic.a
-noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
 pkginclude_HEADERS = libasm.h
 
 libasm_a_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \
@@ -52,6 +50,12 @@ libasm_a_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \
 		   disasm_begin.c disasm_cb.c disasm_end.c disasm_str.c \
 		   symbolhash.c
 
+noinst_HEADERS = libasmP.h symbolhash.h
+
+if BUILD_SHARED
+noinst_LIBRARIES = libasm_pic.a
+noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
+
 libasm_pic_a_SOURCES =
 am_libasm_pic_a_OBJECTS = $(libasm_a_SOURCES:.c=.os)
 
@@ -81,8 +85,7 @@ uninstall: uninstall-am
 	rm -f $(DESTDIR)$(libdir)/libasm.so.$(VERSION)
 	rm -f $(DESTDIR)$(libdir)/libasm.so
 	rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/elfutils
-
-noinst_HEADERS = libasmP.h symbolhash.h
 EXTRA_DIST = libasm.map
 
 CLEANFILES += $(am_libasm_pic_a_OBJECTS) libasm.so.$(VERSION)
+endif
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 082d96c..a83f9fc 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -35,8 +35,6 @@ AM_CPPFLAGS += -I$(srcdir)/../libelf
 VERSION = 1
 
 lib_LIBRARIES = libdw.a
-noinst_LIBRARIES = libdw_pic.a
-noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
 
 include_HEADERS = dwarf.h
 pkginclude_HEADERS = libdw.h known-dwarf.h
@@ -99,6 +97,19 @@ $(srcdir)/known-dwarf.h: $(top_srcdir)/config/known-dwarf.awk $(srcdir)/dwarf.h
 	mv -f $@.new $@
 endif
 
+libdwfl_objects = $(shell $(AR) t ../libdwfl/libdwfl.a)
+libdw_a_LIBADD = $(addprefix ../libdwfl/,$(libdwfl_objects))
+
+libdwelf_objects = $(shell $(AR) t ../libdwelf/libdwelf.a)
+libdw_a_LIBADD += $(addprefix ../libdwelf/,$(libdwelf_objects))
+
+noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h \
+		 dwarf_sig8_hash.h cfi.h encoded-value.h
+
+if BUILD_SHARED
+noinst_LIBRARIES = libdw_pic.a
+noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
+
 libdw_pic_a_SOURCES =
 am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os)
 
@@ -128,15 +139,7 @@ uninstall: uninstall-am
 	rm -f $(DESTDIR)$(libdir)/libdw.so
 	rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/elfutils
 
-libdwfl_objects = $(shell $(AR) t ../libdwfl/libdwfl.a)
-libdw_a_LIBADD = $(addprefix ../libdwfl/,$(libdwfl_objects))
-
-libdwelf_objects = $(shell $(AR) t ../libdwelf/libdwelf.a)
-libdw_a_LIBADD += $(addprefix ../libdwelf/,$(libdwelf_objects))
-
-noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h \
-		 dwarf_sig8_hash.h cfi.h encoded-value.h
-
 EXTRA_DIST = libdw.map
 
 MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) libdw.so.$(VERSION)
+endif
diff --git a/libdwelf/Makefile.am b/libdwelf/Makefile.am
index 7ca767a..6844250 100644
--- a/libdwelf/Makefile.am
+++ b/libdwelf/Makefile.am
@@ -34,7 +34,7 @@ AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libdw \
 	       -I$(srcdir)/../libdwfl -I$(srcdir)/../libebl
 VERSION = 1
 
-noinst_LIBRARIES = libdwelf.a libdwelf_pic.a
+noinst_LIBRARIES = libdwelf.a
 
 pkginclude_HEADERS = libdwelf.h
 noinst_HEADERS = libdwelfP.h
@@ -43,6 +43,9 @@ libdwelf_a_SOURCES = dwelf_elf_gnu_debuglink.c dwelf_dwarf_gnu_debugaltlink.c \
 		     dwelf_elf_gnu_build_id.c dwelf_scn_gnu_compressed_size.c \
 		     dwelf_strtab.c
 
+if BUILD_SHARED
+noinst_LIBRARIES += libdwelf_pic.a
+
 libdwelf = $(libdw)
 
 libdw = ../libdw/libdw.so
@@ -54,3 +57,4 @@ libdwelf_pic_a_SOURCES =
 am_libdwelf_pic_a_OBJECTS = $(libdwelf_a_SOURCES:.c=.os)
 
 CLEANFILES += $(am_libdwelf_pic_a_OBJECTS)
+endif
diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am
index 89ca92e..4f977ff 100644
--- a/libdwfl/Makefile.am
+++ b/libdwfl/Makefile.am
@@ -35,7 +35,6 @@ AM_CPPFLAGS += -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
 VERSION = 1
 
 noinst_LIBRARIES = libdwfl.a
-noinst_LIBRARIES += libdwfl_pic.a
 
 pkginclude_HEADERS = libdwfl.h
 
@@ -78,6 +77,11 @@ if LZMA
 libdwfl_a_SOURCES += lzma.c
 endif
 
+noinst_HEADERS = libdwflP.h
+
+if BUILD_SHARED
+noinst_LIBRARIES += libdwfl_pic.a
+
 libdwfl = $(libdw)
 libdw = ../libdw/libdw.so
 libelf = ../libelf/libelf.so
@@ -87,6 +91,5 @@ libeu = ../lib/libeu.a
 libdwfl_pic_a_SOURCES =
 am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_SOURCES:.c=.os)
 
-noinst_HEADERS = libdwflP.h
-
 CLEANFILES += $(am_libdwfl_pic_a_OBJECTS)
+endif
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index 6f945eb..ee7dd21 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -59,4 +59,6 @@ libebl_a_SOURCES = $(gen_SOURCES)
 
 noinst_HEADERS = libeblP.h ebl-hooks.h
 
+if BUILD_SHARED
 CLEANFILES += $(am_libebl_pic_a_OBJECTS)
+endif
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index 167a832..b418d72 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -35,12 +35,8 @@ GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
 VERSION = 1
 
 lib_LIBRARIES = libelf.a
-noinst_LIBRARIES = libelf_pic.a
-noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
 include_HEADERS = libelf.h gelf.h nlist.h
 
-pkginclude_HEADERS = elf-knowledge.h
-
 libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \
 		   elf_begin.c elf_next.c elf_rand.c elf_end.c elf_kind.c \
 		   gelf_getclass.c elf_getbase.c elf_getident.c \
@@ -92,6 +88,15 @@ libelf_a_SOURCES = elf_version.c elf_hash.c elf_error.c elf_fill.c \
 		   elf32_getchdr.c elf64_getchdr.c gelf_getchdr.c \
 		   elf_compress.c elf_compress_gnu.c
 
+noinst_HEADERS = elf.h abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \
+		 version_xlate.h gnuhash_xlate.h note_xlate.h dl-hash.h \
+		 chdr_xlate.h
+
+if BUILD_SHARED
+noinst_LIBRARIES = libelf_pic.a
+noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
+pkginclude_HEADERS = elf-knowledge.h
+
 libelf_pic_a_SOURCES =
 am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os)
 
@@ -119,9 +124,7 @@ uninstall: uninstall-am
 	rm -f $(DESTDIR)$(libdir)/libelf.so.$(VERSION)
 	rm -f $(DESTDIR)$(libdir)/libelf.so
 
-noinst_HEADERS = elf.h abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \
-		 version_xlate.h gnuhash_xlate.h note_xlate.h dl-hash.h \
-		 chdr_xlate.h
 EXTRA_DIST = libelf.map
 
 CLEANFILES += $(am_libelf_pic_a_OBJECTS) libelf.so.$(VERSION)
+endif
-- 
2.10.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Allow to choose to build shared or static library
@ 2016-10-13 10:16 Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2016-10-13 10:16 UTC (permalink / raw)
  To: elfutils-devel

[-- Attachment #1: Type: text/plain, Size: 585 bytes --]

The problem is that libebl depends on loading any backends dynamically
as shared libraries. See libebl/eblopenbackend.c. Without the backends
various functionality just doesn't work. So you'll have to compile in at
least the native/target backend.

There is a hacky version of that on the mjw/RH-DTS git branch. But that
just hard codes the backends (basically limited to those that RHEL
supports). If we make static linking possible we need to clean that up
to make it configurable (it might simply be all vs native, but it should
include at least the native/target backend).

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-13 10:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-11 14:11 [PATCH] Allow to choose to build shared or static library Akihiko Odaki
2016-10-13 10:16 Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).