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