This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
RE: autoconf libelf and ARM cross-compilation -lelf linking
Hi Turgis,
On Thu, 2011-09-01 at 16:22 +0200, Turgis, Frederic wrote:
> Well, AC_CHECK_HEADERS([libelf.h],[staprun_LIBS="$staprun_LIBS -lelf"],[]) works fine in fact, I just needed a bit more info to perform the right generation of configure.
> With that, cross-linking does not fail if cross environment does not have libelf.
>
> However I was told internally to use AC_CHECK_LIB instead. So 2 points:
> - This requires a symbol to test at link so I tried to find something generic in libelf.h -> "elf_begin". Feel free to find more generic
> AC_CHECK_LIB(elf, elf_begin, [staprun_LIBS="$staprun_LIBS -lelf"], [])
That looks sane, but I would like to move assignment into the already
existing AC_CHECK_LIB that tests for the function we actually want to
use (elf_getshdrstrndx). Patch attached. Would that work for you?
Thanks,
Mark
diff --git a/runtime/staprun/configure.ac b/runtime/staprun/configure.ac
index 79d68ee..f449411 100644
--- a/runtime/staprun/configure.ac
+++ b/runtime/staprun/configure.ac
@@ -76,8 +76,9 @@ AC_CHECK_HEADERS([libelf.h])
save_LIBS="$LIBS"
dnl this will only succeed with elfutils 0.142+
AC_CHECK_LIB(elf,elf_getshdrstrndx,[
- AC_DEFINE([HAVE_ELF_GETSHDRSTRNDX],[1],[Define to 1 if libelf has elf_getshdrstrndx])])
-staprun_LIBS="$staprun_LIBS -lelf"
+ AC_DEFINE([HAVE_ELF_GETSHDRSTRNDX],[1],[Define to 1 if libelf has elf_getshdrstrndx])
+ staprun_LIBS="$staprun_LIBS -lelf"
+])
LIBS="$save_LIBS"
AC_SUBST(staprun_LIBS)