configure.ac revision 1e2a1f7a687a5f79fff9c5d6aee38b44b39e9f43
1# -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3AC_PREREQ(2.65) 4 5AC_INIT([ltrace],[0.7.0-git],[ltrace-devel@lists.alioth.debian.org]) 6AC_CONFIG_HEADERS([config.h]) 7AC_CONFIG_SRCDIR(libltrace.c) 8AC_CONFIG_MACRO_DIR([config/m4]) 9AC_CONFIG_AUX_DIR([config/autoconf]) 10AC_CANONICAL_BUILD 11AC_CANONICAL_HOST 12 13case "${host_os}" in 14 linux-gnu*) HOST_OS="linux-gnu" ;; 15 *) AC_MSG_ERROR([unkown host-os ${host_os}]) ;; 16esac 17AC_SUBST(HOST_OS) 18 19case "${host_cpu}" in 20 arm*|sa110) HOST_CPU="arm" ;; 21 cris*) HOST_CPU="cris" ;; 22 powerpc|powerpc64) HOST_CPU="ppc" ;; 23 sun4u|sparc64) HOST_CPU="sparc" ;; 24 s390x) HOST_CPU="s390" ;; 25 i?86|x86_64) HOST_CPU="x86" ;; 26 *) HOST_CPU="${host_cpu}" ;; 27esac 28AC_SUBST(HOST_CPU) 29 30# Checks for programs. 31AC_PROG_CC 32LT_INIT 33# libtool-2: LT_INIT() 34AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2]) 35AM_MAINTAINER_MODE 36 37AC_ARG_WITH([libelf], 38 AS_HELP_STRING([--with-libelf], [Prefix of libelf headers/library]), 39 [case "${withval}" in 40 (no) 41 AC_MSG_ERROR([*** libelf is a required dependency]) 42 ;; 43 (yes) 44 AC_MSG_ERROR([*** --with-libelf requires you to specify a path]) 45 ;; 46 (*) 47 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include" 48 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib" 49 libelf_LD_LIBRARY_PATH="${withval}/lib" 50 ;; 51esac],[]) 52 53# Checks for libraries. 54 55saved_CPPFLAGS="${CPPFLAGS}" 56saved_LDFLAGS="${LDFLAGS}" 57CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" 58LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" 59# libelf 60AC_CHECK_HEADERS([elf.h gelf.h],, 61 [AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])] 62) 63AC_CHECK_LIB([elf], [elf_begin],, 64 [AC_MSG_ERROR([*** libelf not found on your system])] 65) 66CPPFLAGS="${saved_CPPFLAGS}" 67LDFLAGS="${saved_LDFLAGS}" 68 69 70# HAVE_LIBIBERTY 71AC_CHECK_LIB([iberty], [cplus_demangle], [ 72 AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty]) 73 liberty_LIBS="-liberty"], [ 74 liberty_LIBS=""]) 75AC_SUBST(liberty_LIBS) 76 77 78# HAVE_LIBSUPC__ 79AC_CHECK_LIB([supc++], [__cxa_demangle], [ 80 AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++]) 81 libsupcxx_LIBS="-lsupc++"], [ 82 libsupcxx_LIBS=""]) 83AC_SUBST(libsupcxx_LIBS) 84 85 86# HAVE_LIBSTDC__ 87AC_CHECK_LIB([stdc++], [__cxa_demangle], [ 88 AC_DEFINE([HAVE_LIBSTDC__], [1], [we have libstdc++]) 89 libstdcxx_LIBS="-lstdc++"], [ 90 libstdcxx_LIBS=""]) 91AC_SUBST(libstdcxx_LIBS) 92 93 94dnl Check security_get_boolean_active availability. 95AC_CHECK_HEADERS(selinux/selinux.h) 96AC_CHECK_LIB(selinux, security_get_boolean_active) 97 98 99# HAVE_LIBUNWIND 100AC_ARG_WITH(libunwind, 101 AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]), 102 [case "${withval}" in 103 (yes|no) enable_libunwind=$withval;; 104 (*) enable_libunwind=yes 105 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include" 106 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib" 107 libunwind_LD_LIBRARY_PATH="${withval}/lib" 108 ;; 109esac],[enable_libunwind=maybe]) 110 111saved_CPPFLAGS="${CPPFLAGS}" 112CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" 113AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes]) 114AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes]) 115CPPFLAGS="${saved_CPPFLAGS}" 116 117AC_MSG_CHECKING([whether to use libunwind support]) 118case "${enable_libunwind}" in 119(yes|maybe) 120 if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then 121 enable_libunwind=yes 122 elif test $enable_libunwind = maybe; then 123 enable_libunwind=no 124 else 125 AC_MSG_RESULT([$enable_libunwind]) 126 AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found]) 127 fi 128 ;; 129(*) ;; 130esac 131AC_MSG_RESULT([$enable_libunwind]) 132 133if test x"$enable_libunwind" = xyes; then 134 saved_LDFLAGS="${LDFLAGS}" 135 LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" 136 AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=) 137 AC_SUBST(libunwind_LIBS) 138 AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=) 139 AC_SUBST(libunwind_ptrace_LIBS) 140 141 case "${host_cpu}" in 142 arm*|sa110) UNWIND_ARCH="arm" ;; 143 i?86) UNWIND_ARCH="x86" ;; 144 powerpc) UNWIND_ARCH="ppc32" ;; 145 ppc64) UNWIND_ARCH="ppc64" ;; 146 mips*) UNWIND_ARCH="mips" ;; 147 *) UNWIND_ARCH="${host_cpu}" ;; 148 esac 149 150 AC_CHECK_LIB(unwind-${UNWIND_ARCH}, _U${UNWIND_ARCH}_init_remote, libunwind_arch_LIBS=-lunwind-${UNWIND_ARCH}, libunwind_arch_LIBS=) 151 AC_SUBST(libunwind_arch_LIBS) 152 AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind]) 153 LDFLAGS="${saved_LDFLAGS}" 154fi 155 156 157saved_CPPFLAGS="${CPPFLAGS}" 158saved_LDFLAGS="${LDFLAGS}" 159CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" 160LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" 161# HAVE_ELF_C_READ_MMAP 162AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP]) 163AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[ 164int main () { 165 Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0); 166 return 0; 167} 168 ]])],[ 169 AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support]) 170 AC_MSG_RESULT([yes])],[ 171 AC_MSG_RESULT([no])]) 172 173saved_CFLAGS="${CFLAGS}" 174CFLAGS="${CFLAGS} -Wall -Werror" 175AC_MSG_CHECKING([whether elf_hash takes a char* argument]) 176AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[ 177 (void) elf_hash("name"); 178 ]])], 179 [AC_DEFINE([ELF_HASH_TAKES_CHARP], [1], 180 [elf_hash() takes char* (as opposed to unsigned char *)]) 181 AC_MSG_RESULT([yes])], 182 [AC_MSG_RESULT([no])]) 183CFLAGS="${saved_CFLAGS}" 184CPPFLAGS="${saved_CPPFLAGS}" 185LDFLAGS="${saved_LDFLAGS}" 186 187AM_CPPFLAGS=" \ 188 ${AM_CPPFLAGS} \ 189 -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \ 190 -I\$(top_srcdir)/sysdeps/${HOST_OS} \ 191 -I\$(top_srcdir)/sysdeps \ 192 -I\$(top_srcdir) \ 193" 194 195# Checks for header files. 196AC_CHECK_HEADERS([ \ 197 fcntl.h \ 198 limits.h \ 199 stddef.h \ 200 stdint.h \ 201 stdlib.h \ 202 string.h \ 203 sys/ioctl.h \ 204 sys/param.h \ 205 sys/time.h \ 206 unistd.h \ 207]) 208 209# Checks for typedefs, structures, and compiler characteristics. 210AC_TYPE_UID_T 211AC_C_INLINE 212AC_TYPE_PID_T 213AC_TYPE_SIZE_T 214AC_CHECK_SIZEOF([long]) 215 216 217# Checks for library functions. 218AC_FUNC_ERROR_AT_LINE 219AC_FUNC_FORK 220AC_CHECK_FUNCS([ \ 221 alarm \ 222 atexit \ 223 getcwd \ 224 gettimeofday \ 225 memset \ 226 mkdir \ 227 rmdir \ 228 strchr \ 229 strdup \ 230 strerror \ 231 strtol \ 232 strtoul \ 233]) 234 235 236# 237# Debugging 238# 239AC_MSG_CHECKING([whether to enable debugging]) 240AC_ARG_ENABLE(debug, 241 AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]), 242 [case "$enableval" in 243 y | yes) CONFIG_DEBUG=yes ;; 244 *) CONFIG_DEBUG=no ;; 245 esac], 246 [CONFIG_DEBUG=no]) 247AC_MSG_RESULT([${CONFIG_DEBUG}]) 248if test "${CONFIG_DEBUG}" = "yes"; then 249 AC_DEFINE(DEBUG, 1, [debugging]) 250fi 251 252# Ignore the compiler's warnings at your own risk. 253AM_CFLAGS="${AM_CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security" 254AC_ARG_ENABLE([werror], 255 AS_HELP_STRING([--disable-werror], [disable use of -Werror]), 256 [enable_werror=$enableval], [enable_werror=yes]) 257if test x$enable_werror = xyes; then 258 AM_CFLAGS="${AM_CFLAGS} -Werror" 259fi 260 261AC_SUBST(AM_CPPFLAGS) 262AC_SUBST(AM_CFLAGS) 263AC_SUBST(AM_LDFLAGS) 264AC_SUBST(libelf_LD_LIBRARY_PATH) 265AC_SUBST(libunwind_LD_LIBRARY_PATH) 266 267AC_CONFIG_FILES([ 268 Makefile 269 sysdeps/Makefile 270 sysdeps/linux-gnu/Makefile 271 sysdeps/linux-gnu/alpha/Makefile 272 sysdeps/linux-gnu/arm/Makefile 273 sysdeps/linux-gnu/ia64/Makefile 274 sysdeps/linux-gnu/m68k/Makefile 275 sysdeps/linux-gnu/mipsel/Makefile 276 sysdeps/linux-gnu/ppc/Makefile 277 sysdeps/linux-gnu/s390/Makefile 278 sysdeps/linux-gnu/sparc/Makefile 279 sysdeps/linux-gnu/x86/Makefile 280 testsuite/Makefile 281 testsuite/ltrace.main/Makefile 282 testsuite/ltrace.minor/Makefile 283 testsuite/ltrace.torture/Makefile 284]) 285AC_OUTPUT 286