[PATCH 1/2] Allow building the libraries without argp

2017-02-20 Thread Ulf Hermann
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.

[PATCH 2/2] Output information about buildable components

2017-02-20 Thread Ulf Hermann
If argp is missing we build without tools and tests. We might also
make libasm optional in the future, as it is only used in maintainer
mode. A libelf-only build without libdw and the ebl backends is also
feasible.

The user should be notified about what is actually buildable with a
given configuration.

Signed-off-by: Ulf Hermann 
---
 ChangeLog|  5 +
 configure.ac | 16 +++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e93d05f..e97e02b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2017-02-20  Ulf Hermann  
 
+   * configure.ac: Track which components are enabled and output
+   a summary in the end.
+
+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.
diff --git a/configure.ac b/configure.ac
index 60b8796..ed60be5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -403,6 +403,7 @@ dnl Support library.
 AC_CONFIG_FILES([lib/Makefile])
 
 dnl ELF library.
+enable_libelf="yes"
 AC_CONFIG_FILES([libelf/Makefile])
 
 dnl Higher-level ELF support library.
@@ -412,6 +413,7 @@ dnl DWARF-ELF Lower-level Functions support library.
 AC_CONFIG_FILES([libdwelf/Makefile])
 
 dnl DWARF library.
+enable_libdw="yes"
 AC_CONFIG_FILES([libdw/Makefile])
 
 dnl Higher-level DWARF support library.
@@ -421,7 +423,8 @@ dnl CPU handling library.
 AC_CONFIG_FILES([libcpu/Makefile])
 
 dnl Assembler library.
-AM_CONDITIONAL(HAVE_LIBASM, true)dnl Used in tests/Makefile.am, which see.
+enable_libasm="yes"
+AM_CONDITIONAL(HAVE_LIBASM, test "x$enable_libasm" = "xyes")dnl Used in 
tests/Makefile.am, which see.
 AC_CONFIG_FILES([libasm/Makefile])
 
 dnl CPU-specific backend libraries.
@@ -433,11 +436,15 @@ AC_CONFIG_FILES([po/Makefile.in])
 AM_CONDITIONAL(STANDALONE, false)dnl Used in tests/Makefile.am, which see.
 if test "x$with_argp" = "xyes"; then
dnl Tools.
+   enable_tools="yes"
AC_CONFIG_FILES([src/Makefile])
 
dnl Test suite.
+   enable_tests="yes"
AC_CONFIG_FILES([tests/Makefile])
 else
+   enable_tools="no"
+   enable_tests="no"
AC_MSG_WARN("Not building tools or tests.")
 fi
 
@@ -580,4 +587,11 @@ AC_MSG_NOTICE([
 gcc undefined behaviour sanitizer  : ${use_undefined}
 use rpath in tests : ${tests_use_rpath}
 test biarch: ${utrace_cv_cc_biarch}
+
+  BUILDABLE COMPONENTS
+libasm : ${enable_libasm}
+libelf : ${enable_libelf}
+libdw and ebl backends : ${enable_libdw}
+tools  : ${enable_tools}
+tests  : ${enable_tests}
 ])
-- 
2.1.4