If argp is unavailable we cannot build tests, tools and argp-std.c in
libdwfl. We can still build the libraries, though. Test for this and
provide a dwfl_standard_argp() that just returns NULL and only gets
compiled if argp is missing.
Signed-off-by: Ulf Hermann
---
ChangeLog| 12
Makefile.am | 6 +-
configure.ac | 31 +--
lib/ChangeLog| 7 +++
lib/Makefile.am | 10 +++---
libdwfl/ChangeLog| 6 ++
libdwfl/Makefile.am | 8 +++-
libdwfl/argp-dummy.c | 38 ++
8 files changed, 103 insertions(+), 15 deletions(-)
create mode 100644 libdwfl/argp-dummy.c
diff --git a/ChangeLog b/ChangeLog
index 15b36dd..e93d05f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2017-02-20 Ulf Hermann
+
+ * configure.ac: Don't abort if no argp is found. Only print a
+ warning, rename have_argp to with_argp (like lzma, bzip2 ..),
+ and use "yes"/"no" as values, as we do for other variables.
+ * configure.ac: Set with_argp also if argp is in libargp, and
+ pass it on as AM_CONDITIONAL ARGP.
+ * configure.ac: Skip configuration of src and tests if
+ argp is not available.
+ * Makefile.am (SUBDIRS): Skip src and tests if argp is not
+ available.
+
2017-02-17 Ulf Hermann
* configure.ac: Define HAVE_MEMPCPY if mempcpy is available.
diff --git a/Makefile.am b/Makefile.am
index 2ff444e..59225cc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,7 +28,11 @@ pkginclude_HEADERS = version.h
# Add doc back when we have some real content.
SUBDIRS = config m4 lib libelf libebl libdwelf libdwfl libdw libcpu libasm \
- backends src po tests
+ backends po
+
+if ARGP
+SUBDIRS += src tests
+endif
EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \
COPYING COPYING-GPLV2 COPYING-LGPLV3
diff --git a/configure.ac b/configure.ac
index 303bf4d..60b8796 100644
--- a/configure.ac
+++ b/configure.ac
@@ -367,24 +367,27 @@ AC_LINK_IFELSE(
[#include ],
[int argc=1; char *argv[]={"test"};
argp_parse(0,argc,&argv,0,0,0); return 0;]
)],
- [libc_has_argp="true"],
- [libc_has_argp="false"]
+ [libc_has_argp="yes"],
+ [libc_has_argp="no"]
)
dnl If our libc doesn't provide argp, then test for libargp
-if test "$libc_has_argp" = "false" ; then
+if test "$libc_has_argp" = "no" ; then
AC_MSG_WARN("libc does not have argp")
- AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"],
[have_argp="false"])
+ AC_CHECK_LIB([argp], [argp_parse], [with_argp="yes"], [with_argp="no"])
- if test "$have_argp" = "false"; then
- AC_MSG_ERROR("no libargp found")
+ if test "$with_argp" = "no"; then
+ AC_MSG_WARN("no libargp found")
+ argp_LDADD=""
else
argp_LDADD="-largp"
fi
else
+ with_argp="yes"
argp_LDADD=""
fi
AC_SUBST([argp_LDADD])
+AM_CONDITIONAL(ARGP, [test "x$with_argp" = "xyes"])
dnl Check if we have for EM_BPF disassembly.
AC_CHECK_HEADERS(linux/bpf.h)
@@ -424,12 +427,19 @@ AC_CONFIG_FILES([libasm/Makefile])
dnl CPU-specific backend libraries.
AC_CONFIG_FILES([backends/Makefile])
-dnl Tools.
-AC_CONFIG_FILES([src/Makefile po/Makefile.in])
+dnl Translations
+AC_CONFIG_FILES([po/Makefile.in])
-dnl Test suite.
AM_CONDITIONAL(STANDALONE, false)dnl Used in tests/Makefile.am, which see.
-AC_CONFIG_FILES([tests/Makefile])
+if test "x$with_argp" = "xyes"; then
+ dnl Tools.
+ AC_CONFIG_FILES([src/Makefile])
+
+ dnl Test suite.
+ AC_CONFIG_FILES([tests/Makefile])
+else
+ AC_MSG_WARN("Not building tools or tests.")
+fi
dnl pkgconfig files
AC_CONFIG_FILES([config/libelf.pc config/libdw.pc])
@@ -546,6 +556,7 @@ AC_MSG_NOTICE([
build arch : ${ac_cv_build}
RECOMMENDED FEATURES (should all be yes)
+argp support : ${with_argp}
gzip support : ${with_zlib}
bzip2 support : ${with_bzlib}
lzma/xz support: ${with_lzma}
diff --git a/lib/ChangeLog b/lib/ChangeLog
index dcd20e1..c97537e 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,10 @@
+2017-02-20 Ulf Hermann
+
+ * Makefile.am (libeu_a_SOURCES): Skip printversion.c and
+ color.c if argp is not available.
+ (noinst_HEADERS): Skip printversion.h and color.h if argp is
+ not available.
+
2017-02-17 Ulf Hermann
* system.h: Make mempcpy a function.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 63738fd..93a965c 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -34,17 +34,21 @@ AM_CPPFLAGS += -I$(srcdir)/../libelf
noinst_LIBRARIES = libeu.a
libeu_a_SOURCES = xstrdup.c xstrndup.c xmalloc.c next_prime.c \
- crc32.c crc32_file.c md5.c sha1.