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 <ulf.herm...@qt.io> --- 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 <ulf.herm...@qt.io> + + * 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 <ulf.herm...@qt.io> * 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 <argp.h>], [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 <linux/bpf.h> 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 <ulf.herm...@qt.io> + + * 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 <ulf.herm...@qt.io> * 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.c \ - color.c printversion.c + crc32.c crc32_file.c md5.c sha1.c noinst_HEADERS = fixedsizehash.h libeu.h system.h dynamicsizehash.h list.h \ - md5.h sha1.h eu-config.h color.h printversion.h + md5.h sha1.h eu-config.h EXTRA_DIST = dynamicsizehash.c if !HAVE_MEMPCPY libeu_a_SOURCES += mempcpy.c endif +if ARGP +libeu_a_SOURCES += printversion.c color.c +noinst_HEADERS += printversion.h color.h +endif + if !GPROF xmalloc_CFLAGS = -ffunction-sections endif diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 4c9f4f6..570c66f 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2017-02-20 Ulf Hermann <ulf.herm...@qt.io> + + * argp-dummy.c: New file. + * Makefile.am (libdwfl_a_SOURCES): If argp is not available, + compile argp-dummy.c rather than argp-std.c. + 2017-02-15 Ulf Hermann <ulf.herm...@qt.io> * linux-kernel-modules.c: Include system.h. diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am index 89ca92e..69ea431 100644 --- a/libdwfl/Makefile.am +++ b/libdwfl/Makefile.am @@ -46,7 +46,7 @@ libdwfl_a_SOURCES = dwfl_begin.c dwfl_end.c dwfl_error.c dwfl_version.c \ dwfl_module_info.c dwfl_getmodules.c dwfl_getdwarf.c \ dwfl_module_getdwarf.c dwfl_module_getelf.c \ dwfl_validate_address.c \ - argp-std.c find-debuginfo.c \ + find-debuginfo.c \ dwfl_build_id_find_elf.c \ dwfl_build_id_find_debuginfo.c \ linux-kernel-modules.c linux-proc-maps.c \ @@ -71,6 +71,12 @@ libdwfl_a_SOURCES = dwfl_begin.c dwfl_end.c dwfl_error.c dwfl_version.c \ linux-pid-attach.c linux-core-attach.c dwfl_frame_regs.c \ gzip.c +if ARGP +libdwfl_a_SOURCES += argp-std.c +else +libdwfl_a_SOURCES += argp-dummy.c +endif + if BZLIB libdwfl_a_SOURCES += bzip2.c endif diff --git a/libdwfl/argp-dummy.c b/libdwfl/argp-dummy.c new file mode 100644 index 0000000..7d561c0 --- /dev/null +++ b/libdwfl/argp-dummy.c @@ -0,0 +1,38 @@ +/* Dummy argp argument parser. + Copyright (C) 2017 The Qt Company Ltd. + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify + it under the terms of either + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at + your option) any later version + + or + + * the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at + your option) any later version + + or both in parallel, as here. + + elfutils is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received copies of the GNU General Public License and + the GNU Lesser General Public License along with this program. If + not, see <http://www.gnu.org/licenses/>. */ + +#include "libdwflP.h" + +/* If argp is unavailable we cannot implement this. It is not really + libdwfl's job to do argument parsing, though. */ + +const struct argp * +dwfl_standard_argp (void) +{ + return NULL; +} -- 2.1.4