Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 1 | Look for libfts and libobstack during configure, these |
| 2 | libraries are external to libc when using musl, whereas |
| 3 | on glibc these libraries are provided in libc itself. |
| 4 | |
| 5 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 6 | Upstream-Status: Inappropriate [workaround for musl] |
| 7 | --- a/configure.ac |
| 8 | +++ b/configure.ac |
| 9 | @@ -494,6 +494,60 @@ else |
| 10 | fi |
| 11 | AC_SUBST([argp_LDADD]) |
| 12 | |
| 13 | +dnl Check if we have fts available from our libc |
| 14 | +AC_LINK_IFELSE( |
| 15 | + [AC_LANG_PROGRAM( |
| 16 | + [#if !defined(__x86_64__) |
| 17 | + #undef _FILE_OFFSET_BITS |
| 18 | + #define _FILE_OFFSET_BITS 32 |
| 19 | + #endif |
| 20 | + #include <fts.h>], |
| 21 | + [FTS* fts = 0; return fts_close(fts); return 0;] |
| 22 | + )], |
| 23 | + [libc_has_fts="true"], |
| 24 | + [libc_has_fts="false"] |
| 25 | +) |
| 26 | + |
| 27 | +dnl If our libc doesn't provide fts, then test for libfts |
| 28 | +if test "$libc_has_fts" = "false" ; then |
| 29 | + AC_MSG_WARN("libc does not have fts") |
| 30 | + AC_CHECK_LIB([fts], [fts_close], [have_fts="true"], [have_fts="false"]) |
| 31 | + |
| 32 | + if test "$have_fts" = "false"; then |
| 33 | + AC_MSG_ERROR("no libfts found") |
| 34 | + else |
| 35 | + fts_LDADD="-lfts" |
| 36 | + fi |
| 37 | +else |
| 38 | + fts_LDADD="" |
| 39 | +fi |
| 40 | +AC_SUBST([fts_LDADD]) |
| 41 | + |
| 42 | +dnl Check if we have obstack available from our libc |
| 43 | +AC_LINK_IFELSE( |
| 44 | + [AC_LANG_PROGRAM( |
| 45 | + [#include <obstack.h>], |
| 46 | + [_obstack_begin(0, 0, 0, NULL, NULL); return 0;] |
| 47 | + )], |
| 48 | + [libc_has_obstack="true"], |
| 49 | + [libc_has_obstack="false"] |
| 50 | +) |
| 51 | + |
| 52 | +dnl If our libc doesn't provide obstack, then test for libobstack |
| 53 | +if test "$libc_has_obstack" = "false" ; then |
| 54 | + AC_MSG_WARN("libc does not have obstack") |
| 55 | + AC_CHECK_LIB([obstack], [_obstack_begin], [have_obstack="true"], [have_obstack="false"]) |
| 56 | + |
| 57 | + if test "$have_obstack" = "false"; then |
| 58 | + AC_MSG_ERROR("no libobstack found") |
| 59 | + else |
| 60 | + obstack_LDADD="-lobstack" |
| 61 | + fi |
| 62 | +else |
| 63 | + obstack_LDADD="" |
| 64 | +fi |
| 65 | +AC_SUBST([obstack_LDADD]) |
| 66 | + |
| 67 | dnl The directories with content. |
| 68 | |
| 69 | dnl Documentation. |
| 70 | --- a/libdw/Makefile.am |
| 71 | +++ b/libdw/Makefile.am |
| 72 | @@ -108,7 +108,7 @@ am_libdw_pic_a_OBJECTS = $(libdw_a_SOURC |
| 73 | libdw_so_LIBS = libdw_pic.a ../libdwelf/libdwelf_pic.a \ |
| 74 | ../libdwfl/libdwfl_pic.a ../libebl/libebl.a |
| 75 | libdw_so_DEPS = ../lib/libeu.a ../libelf/libelf.so |
| 76 | -libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(zip_LIBS) |
| 77 | +libdw_so_LDLIBS = $(libdw_so_DEPS) -ldl -lz $(argp_LDADD) $(fts_LDADD) $(zip_LIBS) |
| 78 | libdw_so_SOURCES = |
| 79 | libdw.so$(EXEEXT): $(srcdir)/libdw.map $(libdw_so_LIBS) $(libdw_so_DEPS) |
| 80 | # The rpath is necessary for libebl because its $ORIGIN use will |
| 81 | --- a/src/Makefile.am |
| 82 | +++ b/src/Makefile.am |
| 83 | @@ -68,8 +68,8 @@ ar_no_Wstack_usage = yes |
| 84 | unstrip_no_Wstack_usage = yes |
| 85 | |
| 86 | readelf_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl |
| 87 | -nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl \ |
| 88 | - $(demanglelib) |
| 89 | +nm_LDADD = $(libdw) $(libebl) $(libelf) $(libeu) $(argp_LDADD) \ |
| 90 | + $(obstack_LDADD) -ldl $(demanglelib) |
| 91 | size_LDADD = $(libelf) $(libeu) $(argp_LDADD) |
| 92 | strip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl |
| 93 | elflint_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl |
| 94 | @@ -77,9 +77,9 @@ findtextrel_LDADD = $(libdw) $(libelf) $ |
| 95 | addr2line_LDADD = $(libdw) $(libelf) $(libeu) $(argp_LDADD) $(demanglelib) |
| 96 | elfcmp_LDADD = $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl |
| 97 | objdump_LDADD = $(libasm) $(libebl) $(libelf) $(libeu) $(argp_LDADD) -ldl |
| 98 | -ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) |
| 99 | +ranlib_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD) |
| 100 | strings_LDADD = $(libelf) $(libeu) $(argp_LDADD) |
| 101 | -ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) |
| 102 | +ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LDADD) |
| 103 | unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl |
| 104 | stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) -ldl $(demanglelib) |
| 105 | elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) |