configure.ac revision d15283b6f07ac022cee18e0d3198b23f132e609d
1# -*- Autoconf -*- 2# This file is part of ltrace. 3# Copyright (C) 2010,2012 Petr Machata, Red Hat Inc. 4# Copyright (C) 2010,2011 Joe Damato 5# Copyright (C) 2010 Marc Kleine-Budde 6# Copyright (C) 2010 Zachary T Welch 7# 8# This program is free software; you can redistribute it and/or 9# modify it under the terms of the GNU General Public License as 10# published by the Free Software Foundation; either version 2 of the 11# License, or (at your option) any later version. 12# 13# This program is distributed in the hope that it will be useful, but 14# WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16# General Public License for more details. 17# 18# You should have received a copy of the GNU General Public License 19# along with this program; if not, write to the Free Software 20# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 21# 02110-1301 USA 22 23# Process this file with autoconf to produce a configure script. 24AC_PREREQ([2.65]) 25 26AC_INIT([ltrace],[0.7.90-git],[ltrace-devel@lists.alioth.debian.org]) 27AC_CONFIG_HEADERS([config.h]) 28AC_CONFIG_SRCDIR(libltrace.c) 29AC_CONFIG_MACRO_DIR([config/m4]) 30AC_CONFIG_AUX_DIR([config/autoconf]) 31AC_CANONICAL_BUILD 32AC_CANONICAL_HOST 33 34case "${host_os}" in 35 linux-gnu*) HOST_OS="linux-gnu" ;; 36 linux-uclibc*) HOST_OS="linux-gnu" ;; 37 *) AC_MSG_ERROR([unkown host-os ${host_os}]) ;; 38esac 39AC_SUBST(HOST_OS) 40 41case "${host_cpu}" in 42 arm*|sa110) HOST_CPU="arm" ;; 43 cris*) HOST_CPU="cris" ;; 44 mips*el) HOST_CPU="mipsel" ;; 45 mips*) HOST_CPU="mips" ;; 46 powerpc|powerpc64) HOST_CPU="ppc" ;; 47 sun4u|sparc64) HOST_CPU="sparc" ;; 48 s390x) HOST_CPU="s390" ;; 49 i?86|x86_64) HOST_CPU="x86" ;; 50 *) HOST_CPU="${host_cpu}" ;; 51esac 52AC_SUBST(HOST_CPU) 53 54# Checks for programs. 55AC_PROG_CC 56LT_INIT 57# libtool-2: LT_INIT() 58AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2]) 59AM_MAINTAINER_MODE 60 61AC_ARG_WITH([libelf], 62 AS_HELP_STRING([--with-libelf], [Prefix of libelf headers/library]), 63 [case "${withval}" in 64 (no) 65 AC_MSG_ERROR([*** libelf is a required dependency]) 66 ;; 67 (yes) 68 AC_MSG_ERROR([*** --with-libelf requires you to specify a path]) 69 ;; 70 (*) 71 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include" 72 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib" 73 libelf_LD_LIBRARY_PATH="${withval}/lib" 74 ;; 75esac],[]) 76 77# Checks for libraries. 78 79saved_CPPFLAGS="${CPPFLAGS}" 80saved_LDFLAGS="${LDFLAGS}" 81CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" 82LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" 83# libelf 84AC_CHECK_HEADERS([elf.h gelf.h],, 85 [AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])] 86) 87AC_CHECK_LIB([elf], [elf_begin],, 88 [AC_MSG_ERROR([*** libelf not found on your system])] 89) 90CPPFLAGS="${saved_CPPFLAGS}" 91LDFLAGS="${saved_LDFLAGS}" 92 93 94# HAVE_LIBIBERTY 95AC_CHECK_LIB([iberty], [cplus_demangle], [ 96 AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty]) 97 liberty_LIBS="-liberty"], [ 98 liberty_LIBS=""]) 99AC_SUBST(liberty_LIBS) 100 101 102# HAVE_LIBSUPC__ 103AC_CHECK_LIB([supc++], [__cxa_demangle], [ 104 AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++]) 105 libsupcxx_LIBS="-lsupc++"], [ 106 libsupcxx_LIBS=""]) 107AC_SUBST(libsupcxx_LIBS) 108 109 110# HAVE_LIBSTDC__ 111AC_CHECK_LIB([stdc++], [__cxa_demangle], [ 112 AC_DEFINE([HAVE_LIBSTDC__], [1], [we have libstdc++]) 113 libstdcxx_LIBS="-lstdc++"], [ 114 libstdcxx_LIBS=""]) 115AC_SUBST(libstdcxx_LIBS) 116 117 118dnl Check security_get_boolean_active availability. 119AC_CHECK_HEADERS(selinux/selinux.h) 120AC_CHECK_LIB(selinux, security_get_boolean_active) 121 122 123# HAVE_LIBUNWIND 124AC_ARG_WITH(libunwind, 125 AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]), 126 [case "${withval}" in 127 (yes|no) enable_libunwind=$withval;; 128 (*) enable_libunwind=yes 129 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include" 130 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib" 131 libunwind_LD_LIBRARY_PATH="${withval}/lib" 132 ;; 133esac],[enable_libunwind=maybe]) 134 135saved_CPPFLAGS="${CPPFLAGS}" 136CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" 137AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes]) 138AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes]) 139CPPFLAGS="${saved_CPPFLAGS}" 140 141AC_MSG_CHECKING([whether to use libunwind support]) 142case "${enable_libunwind}" in 143(yes|maybe) 144 if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then 145 enable_libunwind=yes 146 elif test $enable_libunwind = maybe; then 147 enable_libunwind=no 148 else 149 AC_MSG_RESULT([$enable_libunwind]) 150 AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found]) 151 fi 152 ;; 153(*) ;; 154esac 155AC_MSG_RESULT([$enable_libunwind]) 156 157if test x"$enable_libunwind" = xyes; then 158 case "${host_cpu}" in 159 arm*|sa110) UNWIND_ARCH="arm" ;; 160 i?86) UNWIND_ARCH="x86" ;; 161 powerpc) UNWIND_ARCH="ppc32" ;; 162 powerpc64) UNWIND_ARCH="ppc64" ;; 163 mips*) UNWIND_ARCH="mips" ;; 164 *) UNWIND_ARCH="${host_cpu}" ;; 165 esac 166 167 saved_LDFLAGS="${LDFLAGS}" 168 LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" 169 AC_CHECK_LIB([unwind], [backtrace], [libunwind_LIBS=-lunwind], 170 [AC_MSG_ERROR([Couldn't find or use libunwind.])]) 171 172 AC_CHECK_LIB([unwind-${UNWIND_ARCH}], [_U${UNWIND_ARCH}_init_remote], 173 [libunwind_LIBS="-lunwind-${UNWIND_ARCH} $libunwind_LIBS"], 174 [AC_MSG_ERROR([Couldn't find or use libunwind-${UNWIND_ARCH}.])], 175 [$libunwind_LIBS]) 176 177 AC_CHECK_LIB([unwind-ptrace], [_UPT_create], 178 [libunwind_LIBS="-lunwind-ptrace $libunwind_LIBS"], 179 [AC_MSG_ERROR([Couldn't find or use libunwind-ptrace.])], 180 [$libunwind_LIBS]) 181 182 AC_SUBST(libunwind_LIBS) 183 AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind]) 184 LDFLAGS="${saved_LDFLAGS}" 185fi 186 187 188saved_CPPFLAGS="${CPPFLAGS}" 189saved_LDFLAGS="${LDFLAGS}" 190CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" 191LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" 192# HAVE_ELF_C_READ_MMAP 193AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP]) 194AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[ 195int main () { 196 Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0); 197 return 0; 198} 199 ]])],[ 200 AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support]) 201 AC_MSG_RESULT([yes])],[ 202 AC_MSG_RESULT([no])]) 203 204saved_CFLAGS="${CFLAGS}" 205CFLAGS="${CFLAGS} -Wall -Werror" 206AC_MSG_CHECKING([whether elf_hash takes a char* argument]) 207AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[ 208 (void) elf_hash("name"); 209 ]])], 210 [AC_DEFINE([ELF_HASH_TAKES_CHARP], [1], 211 [elf_hash() takes char* (as opposed to unsigned char *)]) 212 AC_MSG_RESULT([yes])], 213 [AC_MSG_RESULT([no])]) 214CFLAGS="${saved_CFLAGS}" 215CPPFLAGS="${saved_CPPFLAGS}" 216LDFLAGS="${saved_LDFLAGS}" 217 218AM_CPPFLAGS=" \ 219 ${AM_CPPFLAGS} \ 220 -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \ 221 -I\$(top_srcdir)/sysdeps/${HOST_OS} \ 222 -I\$(top_srcdir)/sysdeps \ 223 -I\$(top_srcdir) \ 224" 225 226# Checks for header files. 227AC_CHECK_HEADERS([ \ 228 fcntl.h \ 229 limits.h \ 230 stddef.h \ 231 stdint.h \ 232 stdlib.h \ 233 string.h \ 234 sys/ioctl.h \ 235 sys/param.h \ 236 sys/time.h \ 237 unistd.h \ 238]) 239 240# Checks for typedefs, structures, and compiler characteristics. 241AC_TYPE_UID_T 242AC_C_INLINE 243AC_TYPE_PID_T 244AC_TYPE_SIZE_T 245AC_CHECK_SIZEOF([long]) 246 247 248# Checks for library functions. 249AC_FUNC_FORK 250AC_CHECK_FUNCS([ \ 251 alarm \ 252 atexit \ 253 gettimeofday \ 254 memset \ 255 strchr \ 256 strdup \ 257 strerror \ 258 strsignal \ 259 strtol \ 260 strtoul \ 261]) 262 263# 264# Define HAVE_OPEN_MEMSTREAM if open_memstream is available. glibc 265# before 2.10, eglibc and uClibc all need _GNU_SOURCE defined for 266# open_memstream to become visible, so check for that as well. If 267# unavailable, require that tmpfile be present. There's no 268# HAVE_TMPFILE, as we plain require that to be present as a fallback. 269# 270AC_CHECK_FUNCS([open_memstream], [], 271 [AC_MSG_CHECKING([for open_memstream with _GNU_SOURCE]) 272 AC_LINK_IFELSE( 273 [AC_LANG_PROGRAM([[#define _GNU_SOURCE 1 274 #include <stdio.h>]], 275 [[char *buf; size_t sz; 276 return open_memstream(&buf, &sz) != 0;]])], 277 278 [AC_MSG_RESULT([yes]) 279 AC_DEFINE([HAVE_OPEN_MEMSTREAM], [1], 280 [Define if open_memstream exists.])], 281 282 [AC_MSG_RESULT([no]) 283 AC_CHECK_FUNC([tmpfile], [], 284 [AC_MSG_ERROR( 285 [Either open_memstream or tmpfile required.])])])]) 286 287# 288# Define HAVE_GETOPT_LONG if that is available. 289# 290AC_CHECK_HEADER([getopt.h], [AC_CHECK_FUNCS([getopt_long])]) 291 292# 293# Debugging 294# 295AC_MSG_CHECKING([whether to enable debugging]) 296AC_ARG_ENABLE(debug, 297 AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]), 298 [case "$enableval" in 299 y | yes) CONFIG_DEBUG=yes ;; 300 *) CONFIG_DEBUG=no ;; 301 esac], 302 [CONFIG_DEBUG=no]) 303AC_MSG_RESULT([${CONFIG_DEBUG}]) 304if test "${CONFIG_DEBUG}" = "yes"; then 305 AC_DEFINE(DEBUG, 1, [debugging]) 306fi 307 308# Ignore the compiler's warnings at your own risk. 309AM_CFLAGS="${AM_CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security" 310AC_ARG_ENABLE([werror], 311 AS_HELP_STRING([--disable-werror], [disable use of -Werror]), 312 [enable_werror=$enableval], [enable_werror=yes]) 313if test x$enable_werror = xyes; then 314 AM_CFLAGS="${AM_CFLAGS} -Werror" 315fi 316 317AC_ARG_ENABLE([valgrind], 318 AS_HELP_STRING([--enable-valgrind],[run all tests under valgrind]), 319 [use_valgrind=$enableval], [use_valgrind=no]) 320if test x$use_valgrind = xyes; then 321 AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no) 322 if test x$HAVE_VALGRIND = xno; then 323 AC_MSG_ERROR([valgrind not found]) 324 fi 325fi 326AM_CONDITIONAL(USE_VALGRIND, test "$use_valgrind" = yes) 327 328AC_SUBST(AM_CPPFLAGS) 329AC_SUBST(AM_CFLAGS) 330AC_SUBST(AM_LDFLAGS) 331AC_SUBST(libelf_LD_LIBRARY_PATH) 332AC_SUBST(libunwind_LD_LIBRARY_PATH) 333 334AC_CONFIG_FILES([ 335 Makefile 336 sysdeps/Makefile 337 sysdeps/linux-gnu/Makefile 338 sysdeps/linux-gnu/alpha/Makefile 339 sysdeps/linux-gnu/arm/Makefile 340 sysdeps/linux-gnu/cris/Makefile 341 sysdeps/linux-gnu/ia64/Makefile 342 sysdeps/linux-gnu/m68k/Makefile 343 sysdeps/linux-gnu/mipsel/Makefile 344 sysdeps/linux-gnu/ppc/Makefile 345 sysdeps/linux-gnu/s390/Makefile 346 sysdeps/linux-gnu/sparc/Makefile 347 sysdeps/linux-gnu/x86/Makefile 348 testsuite/Makefile 349 testsuite/ltrace.main/Makefile 350 testsuite/ltrace.minor/Makefile 351 testsuite/ltrace.torture/Makefile 352]) 353AC_OUTPUT 354