Signed-off-by: Akihiko Odaki <akihiko.odaki...@stu.hosei.ac.jp> --- Makefile.am | 27 +++++++++++++-- configure.ac | 107 ++++++++++++++++++++++++++++++++++++++++++----------------- lib/system.h | 9 ++++- 3 files changed, 110 insertions(+), 33 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 2ff444e..7abd95f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,8 +27,31 @@ AM_MAKEFLAGS = --no-print-directory 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 +SUBDIRS = config m4 libelf po tests + +if ENABLE_LIBEU +SUBDIRS += lib +endif + +if ENABLE_LIBEBL +SUBDIRS += libebl +endif + +if ENABLE_LIBDW +SUBDIRS += libdwelf libdwfl libdw +endif + +if ENABLE_LIBEBL +SUBDIRS += libcpu backends +endif + +if ENABLE_LIBASM +SUBDIRS += libasm +endif + +if ENABLE_TOOLS +SUBDIRS += src +endif EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING \ COPYING COPYING-GPLV2 COPYING-LGPLV3 diff --git a/configure.ac b/configure.ac index e5503f1..cf6a59c 100644 --- a/configure.ac +++ b/configure.ac @@ -214,6 +214,28 @@ AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]), [tests_use_rpath=$enableval], [tests_use_rpath=no]) AM_CONDITIONAL(TESTS_RPATH, test "$tests_use_rpath" = yes) +AC_ARG_ENABLE([tools], +AS_HELP_STRING([--disable-tools], [do not build tools]), + [tools=$enableval], [tools=yes]) +AM_CONDITIONAL(ENABLE_TOOLS, test "$tools" = yes) + +AC_ARG_ENABLE([libasm], +AS_HELP_STRING([--disable-libasm], [do not build libasm]), + [libasm=$enableval], [libasm=yes]) +AM_CONDITIONAL(ENABLE_LIBASM, test "$libasm" = yes) + +AC_ARG_ENABLE([libdw], +AS_HELP_STRING([--disable-libdw], [do not build libdw]), + [libdw=$enableval], [libdw=yes]) +AM_CONDITIONAL(ENABLE_LIBDW, test "$libdw" = yes) + +AC_ARG_ENABLE([libebl], +AS_HELP_STRING([--disable-libebl], [do not build libebl]), + [libebl=$enableval], [libebl=yes]) +AM_CONDITIONAL(ENABLE_LIBEBL, test "$libebl" = yes) + +AM_CONDITIONAL(ENABLE_LIBEU, test "$libdw" = yes -o "$libebl" = yes) + LIBEBL_SUBDIR="$PACKAGE" AC_ARG_ENABLE([libebl-subdir], AS_HELP_STRING([--enable-libebl-subdir=DIR], @@ -306,30 +328,32 @@ CFLAGS="$old_CFLAGS"]) AM_CONDITIONAL(HAVE_NULL_DEREFERENCE_WARNING, [test "x$ac_cv_null_dereference" != "xno"]) -dnl Check if we have argp available from our libc -AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [#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"] -) - -dnl If our libc doesn't provide argp, then test for libargp -if test "$libc_has_argp" = "false" ; then - AC_MSG_WARN("libc does not have argp") - AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"]) - - if test "$have_argp" = "false"; then - AC_MSG_ERROR("no libargp found") +if test "$tools" = yes ; then + dnl Check if we have argp available from our libc + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#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"] + ) + + dnl If our libc doesn't provide argp, then test for libargp + if test "$libc_has_argp" = "false" ; then + AC_MSG_WARN("libc does not have argp") + AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"]) + + if test "$have_argp" = "false"; then + AC_MSG_ERROR("no libargp found") + else + argp_LDADD="-largp" + fi else - argp_LDADD="-largp" + argp_LDADD="" fi -else - argp_LDADD="" + AC_SUBST([argp_LDADD]) fi -AC_SUBST([argp_LDADD]) dnl Check if we have <linux/bpf.h> for EM_BPF disassembly. AC_CHECK_HEADERS(linux/bpf.h) @@ -348,29 +372,47 @@ dnl ELF library. AC_CONFIG_FILES([libelf/Makefile]) dnl Higher-level ELF support library. -AC_CONFIG_FILES([libebl/Makefile]) +if test "$libebl" = yes ; then + AC_CONFIG_FILES([libebl/Makefile]) +fi dnl DWARF-ELF Lower-level Functions support library. -AC_CONFIG_FILES([libdwelf/Makefile]) +if test "$libdw" = yes; then + AC_CONFIG_FILES([libdwelf/Makefile]) +fi dnl DWARF library. -AC_CONFIG_FILES([libdw/Makefile]) +if test "$libdw" = yes; then + AC_CONFIG_FILES([libdw/Makefile]) +fi dnl Higher-level DWARF support library. -AC_CONFIG_FILES([libdwfl/Makefile]) +if test "$libdw" = yes; then + AC_CONFIG_FILES([libdwfl/Makefile]) +fi dnl CPU handling library. -AC_CONFIG_FILES([libcpu/Makefile]) +if test "$libebl" = yes; then + AC_CONFIG_FILES([libcpu/Makefile]) +fi dnl Assembler library. -AM_CONDITIONAL(HAVE_LIBASM, true)dnl Used in tests/Makefile.am, which see. -AC_CONFIG_FILES([libasm/Makefile]) +AM_CONDITIONAL(HAVE_LIBASM, test "$libasm" = yes)dnl Used in tests/Makefile.am, which see. +if test "$libasm" = yes; then + AC_CONFIG_FILES([libasm/Makefile]) +fi dnl CPU-specific backend libraries. -AC_CONFIG_FILES([backends/Makefile]) +if test "$libebl" = yes; then + AC_CONFIG_FILES([backends/Makefile]) +fi dnl Tools. -AC_CONFIG_FILES([src/Makefile po/Makefile.in]) +if test "$tools" = yes ; then + AC_CONFIG_FILES([src/Makefile]) +fi + +AC_CONFIG_FILES([po/Makefile.in]) dnl Test suite. AM_CONDITIONAL(STANDALONE, false)dnl Used in tests/Makefile.am, which see. @@ -384,6 +426,11 @@ AC_CONFIG_FILES([config/libelf.pc config/libdw.pc]) AC_SUBST(USE_NLS, yes) AM_PO_SUBDIRS +AH_TEMPLATE([ENABLE_TOOLS], [Defined if the tools will be built.]) +if test "$tools" = yes ; then + AC_DEFINE([ENABLE_TOOLS]) +fi + dnl Appended to the config.h file. dnl We hide all kinds of configuration magic in lib/eu-config.h. AH_BOTTOM([#include <eu-config.h>]) diff --git a/lib/system.h b/lib/system.h index f31cfd0..6391dec 100644 --- a/lib/system.h +++ b/lib/system.h @@ -29,7 +29,12 @@ #ifndef LIB_SYSTEM_H #define LIB_SYSTEM_H 1 -#include <argp.h> +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#ifdef ENABLE_TOOLS +# include <argp.h> +#endif #include <stddef.h> #include <stdint.h> #include <endian.h> @@ -126,6 +131,7 @@ pread_retry (int fd, void *buf, size_t len, off_t off) } +#ifdef ENABLE_TOOLS /* We need define two variables, argp_program_version_hook and argp_program_bug_address, in all programs. argp.h declares these variables as non-const (which is correct in general). But we can @@ -136,6 +142,7 @@ pread_retry (int fd, void *buf, size_t len, off_t off) __asm ("argp_program_version_hook") #define ARGP_PROGRAM_BUG_ADDRESS_DEF \ const char *const apba__ __asm ("argp_program_bug_address") +#endif /* The demangler from libstdc++. */ -- 2.10.0 _______________________________________________ elfutils-devel mailing list -- elfutils-devel@lists.fedorahosted.org To unsubscribe send an email to elfutils-devel-le...@lists.fedorahosted.org