This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 5/6] Use -lintl when libc doesn't provide dgettext


From: Daniel Guzman <daniel@guzman.io>

dgettext is usually provided directly by libc, but when using uClibc,
the macro is expanded to libintl_dgettext, which is provided by
libintl. This causes a compilation failure, so this patch fixes that
by explicitly checking if the libc provides dgettext, then checking
if libintl provides it and mending the linker flags if so. If not,
configure will properly fail.

Signed-off-by: Daniel Guzman <daniel@guzman.io>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 ChangeLog          |  5 +++++
 configure.ac       | 34 ++++++++++++++++++++++++++++++++++
 libasm/ChangeLog   |  4 ++++
 libasm/Makefile.am |  1 +
 libdw/ChangeLog    |  5 +++++
 libdw/Makefile.am  |  2 +-
 libelf/ChangeLog   |  4 ++++
 libelf/Makefile.am |  1 +
 src/ChangeLog      |  7 +++++++
 src/Makefile.am    | 30 +++++++++++++++---------------
 tests/ChangeLog    |  7 +++++++
 tests/Makefile.am  | 20 ++++++++++----------
 12 files changed, 94 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 89045ef..e86032b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-04  Daniel Guzman  <daniel@guzman.io>
+
+	* configure.ac (intl_LDADD): Check if libc has dgettext and if
+	libintl is available and set intl_LDADD accordingly.
+
 2015-05-04  Anthony G. Basile  <blueness@gentoo.org>
 
 	* configure.ac (futimes): Check if function exists.
diff --git a/configure.ac b/configure.ac
index 35dfa08..0b9218f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -278,6 +278,40 @@ else
 fi
 AC_SUBST([argp_LDADD])
 
+dnl Check if we have dgettext available from our libc
+AC_LINK_IFELSE(
+	[AC_LANG_PROGRAM(
+		[#include <libintl.h>],
+		[char *test=dgettext("test","test"); return 0;]
+		)],
+	[libc_has_dgettext="true"],
+	[libc_has_dgettext="false"]
+)
+
+dnl If our libc doesn't provide dgettext, then test for libintl support
+if test "$libc_has_dgettext" = "false" ; then
+	OLD_LIBS="$LIBS"
+	LIBS="$OLD_LIBS -lintl"
+	AC_MSG_WARN("libc does not have dgettext")
+	AC_LINK_IFELSE(
+		[AC_LANG_PROGRAM(
+		        [#include <libintl.h>],
+		        [char *test=dgettext("test","test"); return 0;]
+		        )],
+		[libintl_has_dgettext="true"],
+		[libintl_has_dgettext="false"]
+	)
+	if test "$libintl_has_dgettext" = "false"; then
+		AC_MSG_ERROR("no libintl with dgettext found")
+	else
+		intl_LDADD="-lintl"
+	fi
+	LIBS="$OLD_LIBS"
+else
+	intl_LDADD=""
+fi
+AC_SUBST([intl_LDADD])
+
 dnl Check for futimes
 AC_CHECK_FUNC([futimes])
 
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index 9b25af9..5d63e07 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-04  Daniel Guzman  <daniel@guzman.io>
+
+	* Makefile.am (libasm_so_LDLIBS): Append $(intl_LDADD).
+
 2014-12-18  Ulrich Drepper  <drepper@gmail.com>
 
 	* Makefile.am: Suppress output of textrel_check command.
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index 6ea2a8e..ec1ce1a 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -56,6 +56,7 @@ libasm_pic_a_SOURCES =
 am_libasm_pic_a_OBJECTS = $(libasm_a_SOURCES:.c=.os)
 
 libasm_so_LDLIBS =
+libasm_so_LDLIBS += $(intl_LDADD)
 if USE_LOCKS
 libasm_so_LDLIBS += -lpthread
 endif
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index fd3e4ad..d165ffe 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-04  Daniel Guzman  <daniel@guzman.io>
+
+	* Makefile.am (libdw_so_SOURCES): Append $(intl_LDADD) to link
+	command.
+
 2015-05-04  Anthony G. Basile  <blueness@gentoo.org>
 
 	* Makefile.am (libdw_so_SOURCES): Append $(argp_LDADD) to link
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 2299b2f..b1c5312 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -112,7 +112,7 @@ libdw.so$(EXEEXT): $(srcdir)/libdw.map libdw_pic.a ../libdwelf/libdwelf_pic.a \
 		-Wl,--enable-new-dtags,-rpath,$(pkglibdir) \
 		-Wl,--version-script,$<,--no-undefined \
 		-Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\
-		-ldl $(argp_LDADD) $(zip_LIBS)
+		-ldl $(argp_LDADD) $(intl_LDADD) $(zip_LIBS)
 	@$(textrel_check)
 	ln -fs $@ $@.$(VERSION)
 
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index a1b0ee4..8bc086e 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-04  Daniel Guzman  <daniel@guzman.io>
+
+	* Makefile.am (libelf_so_LDLIBS): Append $(intl_LDADD).
+
 2015-03-28  Mark Wielaard  <mjw@redhat.com>
 
 	* elf.h: Update from glibc.
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index afcb2aa..6361cf2 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -94,6 +94,7 @@ libelf_pic_a_SOURCES =
 am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os)
 
 libelf_so_LDLIBS =
+libelf_so_LDLIBS += $(intl_LDADD)
 if USE_LOCKS
 libelf_so_LDLIBS += -lpthread
 endif
diff --git a/src/ChangeLog b/src/ChangeLog
index 2bb2f0b..af80c1d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
+2015-05-04  Daniel Guzman  <daniel@guzman.io>
+
+	* Makefile.am (readelf_LDADD, nm_LDADD, size_LDADD, strip_LDADD)
+	(ld_LDADD, elflint_LDADD, findtextrel_LDADD, addr2line_LDADD)
+	(elfcmp_LDADD, objdump_LDADD, ranlib_LDADD, strings_LDADD)
+	(ar_LDADD, unstrip_LDADD, stack_LDADD): Append $(intl_LDADD).
+
 2015-05-04  Anthony G. Basile  <blueness@gentoo.org>
 
 	* ld.h (DL_CALL_FCT): Define if this macro is undefined.
diff --git a/src/Makefile.am b/src/Makefile.am
index ab5364f..b606e09 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -89,27 +89,27 @@ endif
 # XXX While the file is not finished, don't warn about this
 ldgeneric_no_Wunused = yes
 
-readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
-nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl \
+readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD) -ldl
+nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD) -ldl \
 	   $(demanglelib)
-size_LDADD = $(libelf) $(libeu) $(argp_LDADD)
-strip_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
-ld_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
+size_LDADD = $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD)
+strip_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD) -ldl
+ld_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD) -ldl
 if NATIVE_LD
 # -ldl is always needed for libebl.
 ld_LDADD += libld_elf.a
 endif
 ld_LDFLAGS = -rdynamic
-elflint_LDADD  = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
-findtextrel_LDADD = $(libdw) $(libelf) $(argp_LDADD)
-addr2line_LDADD = $(libdw) $(libelf) $(argp_LDADD)
-elfcmp_LDADD = $(libebl) $(libelf) $(argp_LDADD) -ldl
-objdump_LDADD  = $(libasm) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl
-ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
-strings_LDADD = $(libelf) $(libeu) $(argp_LDADD)
-ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD)
-unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl
-stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl $(demanglelib)
+elflint_LDADD  = $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD) -ldl
+findtextrel_LDADD = $(libdw) $(libelf) $(argp_LDADD) $(intl_LDADD)
+addr2line_LDADD = $(libdw) $(libelf) $(argp_LDADD) $(intl_LDADD)
+elfcmp_LDADD = $(libebl) $(libelf) $(argp_LDADD) $(intl_LDADD) -ldl
+objdump_LDADD  = $(libasm) $(libebl) $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD) -ldl
+ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD)
+strings_LDADD = $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD)
+ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(intl_LDADD)
+unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(intl_LDADD) -ldl
+stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(intl_LDADD) -ldl $(demanglelib)
 
 ldlex.o: ldscript.c
 ldlex_no_Werror = yes
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 11e96a7..f5d9a1b 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,10 @@
+2015-05-04  Daniel Guzman  <daniel@guzman.io>
+
+	* Makefile.am (line2addr_LDADD, addrscopes_LDADD, funcscopes_LDADD)
+	(funcretval_LDADD, allregs_LDADD, find_prologues_LDADD)
+	(dwflmodtest_LDADD, dwfl_addr_sect_LDADD, addrcfi_LDADD)
+	(low_high_pc_LDADD): Append $(intl_LDADD).
+
 2015-05-04  Anthony G. Basile  <blueness@gentoo.org>
 
 	* Makefile.am (line2addr_LDADD, addrscopes_LDADD, funcscopes_LDADD)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fdbf5bf..f64742f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -380,12 +380,12 @@ get_lines_LDADD = $(libdw) $(libelf)
 get_files_LDADD = $(libdw) $(libelf)
 get_aranges_LDADD = $(libdw) $(libelf)
 allfcts_LDADD = $(libdw) $(libelf)
-line2addr_LDADD = $(libdw) $(argp_LDADD)
-addrscopes_LDADD = $(libdw) $(argp_LDADD)
-funcscopes_LDADD = $(libdw) $(argp_LDADD)
-funcretval_LDADD = $(libdw) $(argp_LDADD)
-allregs_LDADD = $(libdw) $(argp_LDADD)
-find_prologues_LDADD = $(libdw) $(argp_LDADD)
+line2addr_LDADD = $(libdw) $(argp_LDADD) $(intl_LDADD)
+addrscopes_LDADD = $(libdw) $(argp_LDADD) $(intl_LDADD)
+funcscopes_LDADD = $(libdw) $(argp_LDADD) $(intl_LDADD)
+funcretval_LDADD = $(libdw) $(argp_LDADD) $(intl_LDADD)
+allregs_LDADD = $(libdw) $(argp_LDADD) $(intl_LDADD)
+find_prologues_LDADD = $(libdw) $(argp_LDADD) $(intl_LDADD)
 #show_ciefde_LDADD = ../libdwarf/libdwarf.so $(libelf)
 asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) -ldl
 asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) -ldl
@@ -396,25 +396,25 @@ asm_tst6_LDADD = $(libasm) $(libebl) $(libelf) -ldl
 asm_tst7_LDADD = $(libasm) $(libebl) $(libelf) -ldl
 asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) -ldl
 asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) -ldl
-dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl
+dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) $(intl_LDADD) -ldl
 rdwrmmap_LDADD = $(libelf)
 dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) -ldl
 arls_LDADD = $(libelf)
 dwfl_bug_fd_leak_LDADD = $(libdw) $(libebl) $(libelf) -ldl
 dwfl_bug_report_LDADD = $(libdw) $(libebl) $(libelf) -ldl
 dwfl_bug_getmodules_LDADD = $(libdw) $(libebl) $(libelf) -ldl
-dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl
+dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) $(intl_LDADD) -ldl
 dwarf_getmacros_LDADD = $(libdw)
 dwarf_ranges_LDADD = $(libdw)
 dwarf_getstring_LDADD = $(libdw)
-addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) -ldl
+addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(argp_LDADD) $(intl_LDADD) -ldl
 test_flag_nobits_LDADD = $(libelf)
 rerequest_tag_LDADD = $(libdw)
 alldts_LDADD = $(libebl) $(libelf)
 md5_sha1_test_LDADD = $(libeu)
 typeiter_LDADD = $(libdw) $(libelf)
 typeiter2_LDADD = $(libdw) $(libelf)
-low_high_pc_LDADD = $(libdw) $(libelf) $(argp_LDADD)
+low_high_pc_LDADD = $(libdw) $(libelf) $(argp_LDADD) $(intl_LDADD)
 test_elf_cntl_gelf_getshdr_LDADD = $(libelf)
 dwflsyms_LDADD = $(libdw) $(libelf) $(argp_LDADD)
 dwfllines_LDADD = $(libdw) $(libelf) $(argp_LDADD)
-- 
1.8.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]