configure.ac revision 5f30bc318e430a7c4ea843edeff798e80b5629c9
1# -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3AC_PREREQ(2.59) 4 5AC_INIT([ltrace],[0.6.0],[ltrace-devel@lists.alioth.debian.org]) 6AC_CONFIG_HEADERS([config.h]) 7AC_CONFIG_SRCDIR(libltrace.c) 8#AC_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 31AC_PROG_LIBTOOL 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 85# HAVE_LIBUNWIND 86AC_ARG_WITH(libunwind, 87 AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]), 88 [case "${withval}" in 89 (yes|no) enable_libunwind=$withval;; 90 (*) enable_libunwind=yes 91 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include" 92 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib" 93 libunwind_LD_LIBRARY_PATH="${withval}/lib" 94 ;; 95esac],[enable_libunwind=maybe]) 96 97saved_CPPFLAGS="${CPPFLAGS}" 98CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" 99AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes]) 100AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes]) 101CPPFLAGS="${saved_CPPFLAGS}" 102 103AC_MSG_CHECKING([whether to use libunwind support]) 104case "${enable_libunwind}" in 105(yes|maybe) 106 if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then 107 enable_libunwind=yes 108 elif test $enable_libunwind = maybe; then 109 enable_libunwind=no 110 else 111 AC_MSG_RESULT([$enable_libunwind]) 112 AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found]) 113 fi 114 ;; 115(*) ;; 116esac 117AC_MSG_RESULT([$enable_libunwind]) 118 119if test x"$enable_libunwind" = xyes; then 120 saved_LDFLAGS="${LDFLAGS}" 121 LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" 122 AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=) 123 AC_SUBST(libunwind_LIBS) 124 AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=) 125 AC_SUBST(libunwind_ptrace_LIBS) 126 127 case "${host_cpu}" in 128 arm*|sa110) UNWIND_ARCH="arm" ;; 129 i?86) UNWIND_ARCH="x86" ;; 130 powerpc) UNWIND_ARCH="ppc32" ;; 131 ppc64) UNWIND_ARCH="ppc64" ;; 132 mips*) UNWIND_ARCH="mips" ;; 133 *) UNWIND_ARCH="${host_cpu}" ;; 134 esac 135 136 AC_CHECK_LIB(unwind-${UNWIND_ARCH}, _U${UNWIND_ARCH}_init_remote, libunwind_arch_LIBS=-lunwind-${UNWIND_ARCH}, libunwind_arch_LIBS=) 137 AC_SUBST(libunwind_arch_LIBS) 138 AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind]) 139 LDFLAGS="${saved_LDFLAGS}" 140fi 141 142 143saved_CPPFLAGS="${CPPFLAGS}" 144saved_LDFLAGS="${LDFLAGS}" 145CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" 146LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" 147# HAVE_ELF_C_READ_MMAP 148AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP]) 149AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[ 150int main () { 151 Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0); 152 return 0; 153} 154 ]])],[ 155 AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support]) 156 AC_MSG_RESULT([yes])],[ 157 AC_MSG_RESULT([no])]) 158 159saved_CFLAGS="${CFLAGS}" 160CFLAGS="${CFLAGS} -Wall -Werror" 161AC_MSG_CHECKING([whether elf_hash takes a signed char string]) 162AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[ 163 (void) elf_hash("name"); 164 ]])], 165 [AC_DEFINE([ELF_HASH_TAKES_SIGNED_CHAR], [1], 166 [elf_hash() takes signed char]) 167 AC_MSG_RESULT([yes])], 168 [AC_MSG_RESULT([no])]) 169CFLAGS="${saved_CFLAGS}" 170CPPFLAGS="${saved_CPPFLAGS}" 171LDFLAGS="${saved_LDFLAGS}" 172 173AM_CPPFLAGS=" \ 174 ${AM_CPPFLAGS} \ 175 -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \ 176 -I\$(top_srcdir)/sysdeps/${HOST_OS} \ 177 -I\$(top_srcdir)/sysdeps \ 178 -I\$(top_srcdir) \ 179" 180 181# Checks for header files. 182AC_CHECK_HEADERS([ \ 183 fcntl.h \ 184 limits.h \ 185 stddef.h \ 186 stdint.h \ 187 stdlib.h \ 188 string.h \ 189 sys/ioctl.h \ 190 sys/param.h \ 191 sys/time.h \ 192 unistd.h \ 193]) 194 195# Checks for typedefs, structures, and compiler characteristics. 196AC_TYPE_UID_T 197AC_C_INLINE 198AC_TYPE_PID_T 199AC_TYPE_SIZE_T 200AC_CHECK_SIZEOF([long]) 201 202 203# Checks for library functions. 204AC_FUNC_ERROR_AT_LINE 205AC_FUNC_FORK 206AC_CHECK_FUNCS([ \ 207 alarm \ 208 atexit \ 209 getcwd \ 210 gettimeofday \ 211 memset \ 212 mkdir \ 213 rmdir \ 214 strchr \ 215 strdup \ 216 strerror \ 217 strtol \ 218 strtoul \ 219]) 220 221 222# 223# Debugging 224# 225AC_MSG_CHECKING([whether to enable debugging]) 226AC_ARG_ENABLE(debug, 227 AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]), 228 [case "$enableval" in 229 y | yes) CONFIG_DEBUG=yes ;; 230 *) CONFIG_DEBUG=no ;; 231 esac], 232 [CONFIG_DEBUG=no]) 233AC_MSG_RESULT([${CONFIG_DEBUG}]) 234if test "${CONFIG_DEBUG}" = "yes"; then 235 AC_DEFINE(DEBUG, 1, [debugging]) 236fi 237 238# Ignore the compiler's warnings at your own risk. 239AM_CFLAGS="${AM_CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security" 240AC_ARG_ENABLE([werror], 241 AS_HELP_STRING([--disable-werror], [disable use of -Werror]), 242 [enable_werror=$enableval], [enable_werror=yes]) 243if test x$enable_werror = xyes; then 244 AM_CFLAGS="${AM_CFLAGS} -Werror" 245fi 246 247AC_SUBST(AM_CPPFLAGS) 248AC_SUBST(AM_CFLAGS) 249AC_SUBST(AM_LDFLAGS) 250AC_SUBST(libelf_LD_LIBRARY_PATH) 251AC_SUBST(libunwind_LD_LIBRARY_PATH) 252 253AC_CONFIG_FILES([ 254 Makefile 255 sysdeps/Makefile 256 sysdeps/linux-gnu/Makefile 257 sysdeps/linux-gnu/alpha/Makefile 258 sysdeps/linux-gnu/arm/Makefile 259 sysdeps/linux-gnu/i386/Makefile 260 sysdeps/linux-gnu/ia64/Makefile 261 sysdeps/linux-gnu/m68k/Makefile 262 sysdeps/linux-gnu/mipsel/Makefile 263 sysdeps/linux-gnu/ppc/Makefile 264 sysdeps/linux-gnu/s390/Makefile 265 sysdeps/linux-gnu/sparc/Makefile 266 sysdeps/linux-gnu/x86_64/Makefile 267 testsuite/Makefile 268 testsuite/ltrace.main/Makefile 269 testsuite/ltrace.minor/Makefile 270 testsuite/ltrace.torture/Makefile 271]) 272AC_OUTPUT 273