[PATCH] Generalize library names

Ulf Hermann ulf.hermann@qt.io
Mon May 1 14:40:00 GMT 2017


On windows library names end with ".dll" and the prefix "lib" us usually
omitted. Take this into account and also drop the $(EXEEXT) workaround.
We don't need to use noinst_PROGRAMS as there is also noinst_DATA.

Change-Id: I7e4ba2432811d5ad85051ea0c9d5674eabf79b3c
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 ChangeLog               |  5 +++++
 backends/ChangeLog      |  5 +++++
 backends/Makefile.am    | 33 +++++++++++++++++----------------
 configure.ac            | 30 ++++++++++++++++++++++++++++++
 libasm/ChangeLog        |  5 +++++
 libasm/Makefile.am      | 28 +++++++++++++---------------
 libdw/ChangeLog         |  5 +++++
 libdw/Makefile.am       | 28 +++++++++++++---------------
 libebl/ChangeLog        |  6 ++++++
 libebl/Makefile.am      |  2 ++
 libebl/eblopenbackend.c |  9 +++++----
 libelf/ChangeLog        |  5 +++++
 libelf/Makefile.am      | 26 ++++++++++++--------------
 m4/ChangeLog            |  4 ++++
 m4/libname.m4           | 38 ++++++++++++++++++++++++++++++++++++++
 src/ChangeLog           |  5 +++++
 src/Makefile.am         |  6 +++---
 tests/ChangeLog         |  8 ++++++++
 tests/Makefile.am       | 22 +++++++++++++---------
 tests/run-deleted.sh    |  8 +++++---
 20 files changed, 199 insertions(+), 79 deletions(-)
 create mode 100644 m4/libname.m4

diff --git a/ChangeLog b/ChangeLog
index 01f88f3..3613beb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-28  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* configure.ac: Determine library naming conventions and define
+	LIBPREFIX, LIBEXT and common names for elf, dw, asm accordingly.
+
 2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* configure.ac: Check if the compiler supports
diff --git a/backends/ChangeLog b/backends/ChangeLog
index baeb7b9..e2f0529 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-28  Ulf Hermann <ulf.hermann@qt.io>
+
+	* Makefile.am: Have the backend file names follow the platform's
+	convention for naming shared libraries.
+
 2017-04-27  Ulf Hermann <ulf.hermann@qt.io>
 
 	* Makefile.am: Use dso_LDFLAGS.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 6dc2022..55ff871 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -40,11 +40,12 @@ libebl_pic = libebl_i386_pic.a libebl_sh_pic.a libebl_x86_64_pic.a    \
 	     libebl_ppc64_pic.a libebl_s390_pic.a libebl_tilegx_pic.a \
 	     libebl_m68k_pic.a libebl_bpf_pic.a
 noinst_LIBRARIES = $(libebl_pic)
-noinst_DATA = $(libebl_pic:_pic.a=.so)
+libebl_pic_prefixed = $(libebl_pic:lib%=$(LIBPREFIX)%)
+noinst_DATA = $(libebl_pic_prefixed:_pic.a=$(LIBEXT))
 
 
-libelf = ../libelf/libelf.so
-libdw = ../libdw/libdw.so
+libelf = ../libelf/$(libelf_BARE)
+libdw = ../libdw/$(libdw_BARE)
 if USE_GNULIB
 libgnu = ../libgnu/libgnu.a
 else
@@ -134,32 +135,32 @@ libebl_bpf_pic_a_SOURCES = $(bpf_SRCS)
 am_libebl_bpf_pic_a_OBJECTS = $(bpf_SRCS:.c=.os)
 
 
-libebl_%.so libebl_%.map: libebl_%_pic.a $(libelf) $(libdw) $(libgnu)
-	@rm -f $(@:.so=.map)
+$(LIBPREFIX)ebl_%$(LIBEXT) $(LIBPREFIX)ebl_%.map: libebl_%_pic.a $(libelf) $(libdw) $(libgnu)
+	@rm -f $(@:$(LIBEXT)=.map)
 	$(AM_V_at)echo 'ELFUTILS_$(PACKAGE_VERSION) { global: $*_init; local: *; };' \
-	  > $(@:.so=.map)
-	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $(@:.map=.so) \
+	  > $(@:$(LIBEXT)=.map)
+	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $(@:.map=$(LIBEXT)) \
 		-Wl,--whole-archive $< $(cpu_$*) -Wl,--no-whole-archive \
-		-Wl,--version-script,$(@:.so=.map) \
+		-Wl,--version-script,$(@:$(LIBEXT)=.map) \
 		-Wl,--as-needed $(libelf) $(libdw) $(libgnu) $(intl_LDADD)
 	@$(textrel_check)
 
-libebl_i386.so: $(cpu_i386)
-libebl_x86_64.so: $(cpu_x86_64)
-libebl_bpf.so: $(cpu_bpf)
+$(LIBPREFIX)ebl_i386$(LIBEXT): $(cpu_i386)
+$(LIBPREFIX)ebl_x86_64$(LIBEXT): $(cpu_x86_64)
+$(LIBPREFIX)ebl_bpf$(LIBEXT): $(cpu_bpf)
 
 install: install-am install-ebl-modules
 install-ebl-modules:
 	$(mkinstalldirs) $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)
 	for m in $(modules); do \
-	  $(INSTALL_PROGRAM) libebl_$${m}.so $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}-$(PACKAGE_VERSION).so; \
-	  ln -fs libebl_$${m}-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}.so; \
+	  $(INSTALL_PROGRAM) $(LIBPREFIX)ebl_$${m}$(LIBEXT) $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/$(LIBPREFIX)ebl_$${m}-$(PACKAGE_VERSION)$(LIBEXT); \
+	  ln -fs $(LIBPREFIX)ebl_$${m}-$(PACKAGE_VERSION)$(LIBEXT) $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/$(LIBPREFIX)ebl_$${m}$(LIBEXT); \
 	done
 
 uninstall: uninstall-am
 	for m in $(modules); do \
-	  rm -f $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}-$(PACKAGE_VERSION).so; \
-	  rm -f $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/libebl_$${m}.so; \
+	  rm -f $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/$(LIBPREFIX)ebl_$${m}-$(PACKAGE_VERSION)$(LIBEXT); \
+	  rm -f $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)/$(LIBPREFIX)ebl_$${m}$(LIBEXT); \
 	done
 	rmdir --ignore-fail-on-non-empty $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)
 
@@ -167,5 +168,5 @@ 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 \
+			$(LIBPREFIX)ebl_$(m).map $(LIBPREFIX)ebl_$(m)$(LIBEXT) \
 			$(am_libebl_$(m)_pic_a_OBJECTS))
diff --git a/configure.ac b/configure.ac
index b943547..b2e03bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -63,6 +63,36 @@ AC_CONFIG_FILES([elfutils.spec:config/elfutils.spec.in])
 
 AC_CANONICAL_HOST
 
+case "$host_os" in
+	cygwin*|mingw*|msys*)
+		LIBEXT=".dll"
+		LIBPREFIX=""
+		eu_postfix_lib_version="no"
+		;;
+	darwin)
+		LIBEXT=".dylib"
+		LIBPREFIX="lib"
+		eu_postfix_lib_version="no"
+		;;
+	*)
+		LIBEXT=".so"
+		LIBPREFIX="lib"
+		eu_postfix_lib_version="yes"
+		;;
+esac
+
+AC_SUBST([LIBEXT])
+AC_DEFINE_UNQUOTED(LIBEXT, "$LIBEXT")
+AH_TEMPLATE([LIBEXT], [Host system file name extension for dynamic libraries.])
+AC_SUBST([LIBPREFIX])
+AC_DEFINE_UNQUOTED(LIBPREFIX, "$LIBPREFIX")
+AH_TEMPLATE([LIBPREFIX], [Host system file name prefix for dynamic libraries.])
+AM_CONDITIONAL(POSTFIX_LIB_VERSION, test "$eu_postfix_lib_version" = "yes")
+
+eu_LIBNAME(elf,1)
+eu_LIBNAME(dw,1)
+eu_LIBNAME(asm,1)
+
 AC_ARG_ENABLE(deterministic-archives,
 [AS_HELP_STRING([--enable-deterministic-archives],
 		[ar and ranlib default to -D behavior])], [
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index 971492a..5321213 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-28  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Use the predefined common library names rather than
+	hardcoding to libasm.so and friends.
+
 2017-02-27  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Use dso_LDFLAGS.
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index 30f7fa9..c6038aa 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -31,11 +31,10 @@ include $(top_srcdir)/config/eu.am
 AM_CPPFLAGS += -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl -I$(top_srcdir)/libdw -I$(top_srcdir)/libdwelf
 
 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)
+noinst_DATA = $(libasm_BARE)
 pkginclude_HEADERS = libasm.h
 
 libasm_a_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \
@@ -63,29 +62,28 @@ if USE_GNULIB
 libasm_so_LDLIBS += ../libgnu/libgnu.a
 endif
 
-libasm_so_SOURCES =
-libasm.so$(EXEEXT): libasm_pic.a libasm.map
+$(libasm_BARE): libasm_pic.a libasm.map
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 		-Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \
-		-Wl,--soname,$@.$(VERSION) \
-		../libebl/libebl.a ../libelf/libelf.so ../libdw/libdw.so \
+		-Wl,--soname,$(libasm_SONAME) \
+		../libebl/libebl.a ../libelf/$(libelf_BARE) ../libdw/$(libdw_BARE) \
 		$(libasm_so_LDLIBS)
 	@$(textrel_check)
-	$(AM_V_at)ln -fs $@ $@.$(VERSION)
+	$(AM_V_at)ln -fs $@ $(libasm_SONAME)
 
-install: install-am libasm.so
+install: install-am $(libasm_BARE)
 	$(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
+	$(INSTALL_PROGRAM) $(libasm_BARE) $(DESTDIR)$(libdir)/$(libasm_VERSIONED)
+	ln -fs $(libasm_VERSIONED) $(DESTDIR)$(libdir)/$(libasm_SONAME)
+	ln -fs $(libasm_SONAME) $(DESTDIR)$(libdir)/$(libasm_BARE)
 
 uninstall: uninstall-am
-	rm -f $(DESTDIR)$(libdir)/libasm-$(PACKAGE_VERSION).so
-	rm -f $(DESTDIR)$(libdir)/libasm.so.$(VERSION)
-	rm -f $(DESTDIR)$(libdir)/libasm.so
+	rm -f $(DESTDIR)$(libdir)/$(libasm_VERSIONED)
+	rm -f $(DESTDIR)$(libdir)/$(libasm_SONAME)
+	rm -f $(DESTDIR)$(libdir)/$(libasm_BARE)
 	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)
+CLEANFILES += $(am_libasm_pic_a_OBJECTS) $(libasm_SONAME) $(libasm_BARE)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 79c3898..5b2fc60 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-28  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Use the predefined common library names rather than
+	hardcoding to libdw.so and friends.
+
 2017-02-27  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* libdwP.h: Use attribute_hidden.
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 055e3f1..aeb84dc 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -32,11 +32,10 @@ if BUILD_STATIC
 AM_CFLAGS += $(fpic_CFLAGS)
 endif
 AM_CPPFLAGS += -I$(srcdir)/../libelf
-VERSION = 1
 
 lib_LIBRARIES = libdw.a
 noinst_LIBRARIES = libdw_pic.a
-noinst_PROGRAMS = $(noinst_LIBRARIES:_pic.a=.so)
+noinst_DATA = $(libdw_BARE)
 
 include_HEADERS = dwarf.h
 pkginclude_HEADERS = libdw.h known-dwarf.h
@@ -114,29 +113,28 @@ else
 libgnu =
 endif
 
-libdw_so_SOURCES =
-libdw.so$(EXEEXT): $(srcdir)/libdw.map libdw_pic.a ../libdwelf/libdwelf_pic.a \
+$(libdw_BARE): $(srcdir)/libdw.map libdw_pic.a ../libdwelf/libdwelf_pic.a \
 	  ../libdwfl/libdwfl_pic.a ../libebl/libebl.a \
-	  ../libelf/libelf.so
+	  ../libelf/$(libelf_BARE)
 # The rpath is necessary for libebl because its $ORIGIN use will
 # not fly in a setuid executable that links in libdw.
-	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ -Wl,--soname,$@.$(VERSION) \
+	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ -Wl,--soname,$(libdw_SONAME) \
 		-Wl,--version-script,$<,--no-undefined $(PKG_RPATH) \
 		-Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\
 		-ldl -lz $(intl_LDADD) $(zip_LIBS) $(libgnu)
 	@$(textrel_check)
-	$(AM_V_at)ln -fs $@ $@.$(VERSION)
+	$(AM_V_at)ln -fs $@ $(libdw_SONAME)
 
-install: install-am libdw.so
+install: install-am $(libdw_BARE)
 	$(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
+	$(INSTALL_PROGRAM) $(libdw_BARE) $(DESTDIR)$(libdir)/$(libdw_VERSIONED)
+	ln -fs $(libdw_VERSIONED) $(DESTDIR)$(libdir)/$(libdw_SONAME)
+	ln -fs $(libdw_SONAME) $(DESTDIR)$(libdir)/$(libdw_BARE)
 
 uninstall: uninstall-am
-	rm -f $(DESTDIR)$(libdir)/libdw-$(PACKAGE_VERSION).so
-	rm -f $(DESTDIR)$(libdir)/libdw.so.$(VERSION)
-	rm -f $(DESTDIR)$(libdir)/libdw.so
+	rm -f $(DESTDIR)$(libdir)/$(libdw_VERSIONED)
+	rm -f $(DESTDIR)$(libdir)/$(libdw_SONAME)
+	rm -f $(DESTDIR)$(libdir)/$(libdw_BARE)
 	rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/elfutils
 
 libdwfl_objects = $(shell $(AR) t ../libdwfl/libdwfl.a)
@@ -150,4 +148,4 @@ noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h \
 
 EXTRA_DIST = libdw.map
 
-MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) libdw.so.$(VERSION)
+MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) $(libdw_SONAME) $(libdw_BARE)
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 56b0421..f9f5d89 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,9 @@
+2017-04-28  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Forward LIBPREFIX and LIBEXT as defined by configure.
+	* eblopenbackend.c: Use platform-specific naming conventions for
+	finding the backend libraries.
+
 2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Use fpic_CFLAGS.
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index 60d0e73..a167549 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -32,6 +32,8 @@ AM_CFLAGS += $(fpic_CFLAGS)
 AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libdw -I$(srcdir)/../libasm
 VERSION = 1
 LIBEBL_SUBDIR = @LIBEBL_SUBDIR@
+LIBPREFIX = @LIBPREFIX@
+LIBEXT = @LIBEXT@
 
 lib_LIBRARIES = libebl.a
 
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index aa75b95..0b261e7 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -313,20 +313,21 @@ openbackend (Elf *elf, const char *emulation, GElf_Half machine)
 # define LIBEBL_SUBDIR PACKAGE
 #endif
 #define ORIGINDIR "$ORIGIN/../$LIB/" LIBEBL_SUBDIR "/"
+#define LIBEBL_PREFIX LIBPREFIX "ebl_"
 
 	/* Give it a try.  At least the machine type matches.  First
            try to load the module.  */
 	char dsoname[100];
-	strcpy (stpcpy (stpcpy (dsoname, ORIGINDIR "libebl_"),
+	strcpy (stpcpy (stpcpy (dsoname, ORIGINDIR LIBEBL_PREFIX),
 			machines[cnt].dsoname),
-		".so");
+		LIBEXT);
 
 	void *h = dlopen (dsoname, RTLD_LAZY);
 	if (h == NULL)
 	  {
-	    strcpy (stpcpy (stpcpy (dsoname, "libebl_"),
+	    strcpy (stpcpy (stpcpy (dsoname, LIBEBL_PREFIX),
 			    machines[cnt].dsoname),
-		    ".so");
+		    LIBEXT);
 	    h = dlopen (dsoname, RTLD_LAZY);
 	  }
 
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index fd58ed3..0a5200f 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-28  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Use the predefined common library names rather than
+	hardcoding to libelf.so and friends.
+
 2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* libelfP.h: Use attribute_hidden.
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index 64687b7..cc31898 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -32,11 +32,10 @@ if BUILD_STATIC
 AM_CFLAGS += $(fpic_CFLAGS)
 endif
 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)
+noinst_DATA = $(libelf_BARE)
 include_HEADERS = libelf.h gelf.h nlist.h
 
 pkginclude_HEADERS = elf-knowledge.h
@@ -103,28 +102,27 @@ if USE_GNULIB
 libelf_so_LDLIBS += ../libgnu/libgnu.a
 endif
 
-libelf_so_SOURCES =
-libelf.so$(EXEEXT): libelf_pic.a libelf.map
+$(libelf_BARE): libelf_pic.a libelf.map
 	$(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
 		-Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \
-		-Wl,--soname,$@.$(VERSION) $(libelf_so_LDLIBS)
+		-Wl,--soname,$(libelf_SONAME) $(libelf_so_LDLIBS)
 	@$(textrel_check)
-	$(AM_V_at)ln -fs $@ $@.$(VERSION)
+	$(AM_V_at)ln -fs $@ $(libelf_SONAME)
 
-install: install-am libelf.so
+install: install-am $(libelf_BARE)
 	$(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
+	$(INSTALL_PROGRAM) $(libelf_BARE) $(DESTDIR)$(libdir)/$(libelf_VERSIONED)
+	ln -fs $(libelf_VERSIONED) $(DESTDIR)$(libdir)/$(libelf_SONAME)
+	ln -fs $(libelf_SONAME) $(DESTDIR)$(libdir)/$(libelf_BARE)
 
 uninstall: uninstall-am
-	rm -f $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so
-	rm -f $(DESTDIR)$(libdir)/libelf.so.$(VERSION)
-	rm -f $(DESTDIR)$(libdir)/libelf.so
+	rm -f $(DESTDIR)$(libdir)/$(libelf_VERSIONED)
+	rm -f $(DESTDIR)$(libdir)/$(libelf_SONAME)
+	rm -f $(DESTDIR)$(libdir)/$(libelf_BARE)
 
 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)
+CLEANFILES += $(am_libelf_pic_a_OBJECTS) $(libelf_SONAME) $(libelf_BARE)
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 9ee06d7..65da9c9 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-28  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* libname.m4: New file.
+
 2015-05-01  Mark Wielaard  <mjw@redhat.com>
 
 	* zip.m4: Explicitly set with_ to no, if not yes.
diff --git a/m4/libname.m4 b/m4/libname.m4
new file mode 100644
index 0000000..cccb5c0
--- /dev/null
+++ b/m4/libname.m4
@@ -0,0 +1,38 @@
+dnl -*- Autoconf -*- Determine platform-specific name of library.
+
+dnl Copyright (C) 2017 The Qt Company, Ltd
+dnl This file is free software; the Qt Company
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl $1 is the library basename, $2 the library version.
+dnl Defines lib[$1]_BARE, lib[$1]_SONAME, and lib[$1]_VERSIONED AC_SUBST.
+
+AC_DEFUN([eu_LIBNAME], [dnl
+
+name="$1"
+version="$2"
+
+AC_CACHE_CHECK([bare name of $1 lib], [eu_cv_sys_lib[$1]_bare], [
+eu_cv_sys_lib[$1]_bare=$LIBPREFIX$name$LIBEXT
+])
+lib[$1]_BARE=$eu_cv_sys_lib[$1]_bare
+AC_SUBST([lib$1_BARE])
+
+AC_CACHE_CHECK([versioned name of $1 lib], [eu_cv_sys_lib[$1]_versioned], [
+eu_cv_sys_lib[$1]_versioned=$LIBPREFIX$name-$PACKAGE_VERSION$LIBEXT
+])
+lib[$1]_VERSIONED=$eu_cv_sys_lib[$1]_versioned
+AC_SUBST([lib$1_VERSIONED])
+
+AC_CACHE_CHECK([soame of $1 lib], [eu_cv_sys_lib[$1]_soname], [
+if test "$eu_postfix_lib_version" = "yes"; then
+eu_cv_sys_lib[$1]_soname=$LIBPREFIX$name$LIBEXT.$version
+else
+eu_cv_sys_lib[$1]_soname=$LIBPREFIX$name$version$LIBEXT
+fi
+])
+lib[$1]_SONAME=$eu_cv_sys_lib[$1]_soname
+AC_SUBST([lib$1_SONAME])
+
+])
diff --git a/src/ChangeLog b/src/ChangeLog
index c5805c9..64db1ca 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-28  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Use the predefined names for libelf, libdw, libasm,
+	rather than hardcoding to the elf conventions.
+
 2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* Makefile.am: Drop argp_LDADD.
diff --git a/src/Makefile.am b/src/Makefile.am
index cc852ca..39ade95 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,9 +44,9 @@ libasm = ../libasm/libasm.a
 libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) $(libebl) -ldl
 libelf = ../libelf/libelf.a -lz
 else
-libasm = ../libasm/libasm.so
-libdw = ../libdw/libdw.so
-libelf = ../libelf/libelf.so
+libasm = ../libasm/$(libasm_BARE)
+libdw = ../libdw/$(libdw_BARE)
+libelf = ../libelf/$(libelf_BARE)
 endif
 libebl = ../libebl/libebl.a
 libeu = ../lib/libeu.a
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 9d20341..d5bda6d 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,11 @@
+2017-04-28  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* Makefile.am: Use the predefined names for libelf, libdw, libasm,
+	rather than hardcoding to the elf conventions and add the right
+	extension to deleted-lib.<libext>.
+	* run-deleted.sh: Use the correct file name extension for
+	deleted-lib.<libext>.
+
 2017-04-27  Ulf Hermann <ulf.hermann@qt.io>
 
 	* Makefile.am: Use fpie_CFLAGS and fpic_CFLAGS.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f9b556d..9a57a6d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -50,13 +50,15 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
 		  test-elf_cntl_gelf_getshdr dwflsyms dwfllines \
 		  dwfl-report-elf-align varlocs backtrace backtrace-child \
 		  backtrace-data backtrace-dwarf debuglink debugaltlink \
-		  buildid deleted deleted-lib.so aggregate_size peel_type \
-		  vdsosyms \
+		  buildid deleted aggregate_size peel_type vdsosyms \
 		  getsrc_die strptr newdata elfstrtab dwfl-proc-attach \
 		  elfshphehdr elfstrmerge dwelfgnucompressed elfgetchdr \
 		  elfgetzdata elfputzdata zstrptr emptyfile vendorelf \
 		  fillfile
 
+check_DATA = deleted-lib$(LIBEXT)
+CLEANFILES += deleted-lib$(LIBEXT)
+
 asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
 	    asm-tst6 asm-tst7 asm-tst8 asm-tst9
 
@@ -338,6 +340,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
 	     testfile-bpf-dis1.expect.bz2 testfile-bpf-dis1.o.bz2 \
 	     testfile-m68k-core.bz2 testfile-m68k.bz2 testfile-m68k-s.bz2
 
+EXTRA_DIST += deleted-lib.c
+
 if USE_VALGRIND
 valgrind_cmd='valgrind -q --leak-check=full --error-exitcode=1'
 endif
@@ -389,9 +393,9 @@ libdw = ../libdw/libdw.a -lz $(zip_LIBS) $(libelf) $(libebl) -ldl
 libelf = ../libelf/libelf.a -lz
 libasm = ../libasm/libasm.a
 else
-libdw = ../libdw/libdw.so
-libelf = ../libelf/libelf.so
-libasm = ../libasm/libasm.so
+libdw = ../libdw/$(libdw_BARE)
+libelf = ../libelf/$(libelf_BARE)
+libasm = ../libasm/$(libasm_BARE)
 endif
 libebl = ../libebl/libebl.a
 libeu = ../lib/libeu.a
@@ -477,10 +481,7 @@ backtrace_dwarf_LDADD = $(libdw) $(libelf) $(libgnu)
 debuglink_LDADD = $(libdw) $(libelf) $(libgnu)
 debugaltlink_LDADD = $(libdw) $(libelf) $(libgnu)
 buildid_LDADD = $(libdw) $(libelf) $(libgnu)
-deleted_LDADD = ./deleted-lib.so $(libgnu)
-deleted_lib_so_LDFLAGS = -shared -rdynamic
-deleted_lib_so_CFLAGS = $(fpic_CFLAGS) -fasynchronous-unwind-tables
-deleted_lib_so_LDADD = $(libgnu)
+deleted_LDADD = ./deleted-lib$(LIBEXT) $(libgnu)
 aggregate_size_LDADD = $(libdw) $(libelf) $(libgnu)
 peel_type_LDADD = $(libdw) $(libelf) $(libgnu)
 vdsosyms_LDADD = $(libdw) $(libelf) $(libgnu)
@@ -509,6 +510,9 @@ system_elf_libelf_test_CPPFLAGS += -I$(top_srcdir)/libgnu -I$(top_builddir)/libg
 endif
 system_elf_libelf_test_LDADD = $(libelf) $(libgnu)
 
+deleted-lib$(LIBEXT): deleted-lib.c $(libgnu)
+	$(AM_V_CCLD)$(COMPILE) $(fpic_CFLAGS) -fasynchronous-unwind-tables -shared -rdynamic -o $@ $^
+
 if GCOV
 check: check-am coverage
 .PHONY: coverage
diff --git a/tests/run-deleted.sh b/tests/run-deleted.sh
index 0f64762..38b9e91 100755
--- a/tests/run-deleted.sh
+++ b/tests/run-deleted.sh
@@ -17,8 +17,10 @@
 
 . $srcdir/backtrace-subr.sh
 
-tempfiles deleted deleted-lib.so
-cp -p ${abs_builddir}/deleted ${abs_builddir}/deleted-lib.so .
+LIBEXT=`grep "#define LIBEXT" ${abs_top_builddir}/config.h | awk '{print $3}' | sed -e 's/"//g'`
+
+tempfiles deleted deleted-lib$LIBEXT
+cp -p ${abs_builddir}/deleted ${abs_builddir}/deleted-lib$LIBEXT .
 
 # We don't want to run the deleted process under valgrind then
 # stack will see the valgrind process backtrace.
@@ -27,7 +29,7 @@ unset VALGRIND_CMD
 
 pid=$(testrun ${abs_builddir}/deleted)
 sleep 1
-rm -f deleted deleted-lib.so
+rm -f deleted deleted-lib$LIBEXT
 tempfiles bt bt.err
 
 set VALGRIND_CMD="$OLD_VALGRIND_CMD"
-- 
2.1.4



More information about the Elfutils-devel mailing list