| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 1 | # -*- Autoconf -*- |
| 2 | # Process this file with autoconf to produce a configure script. |
| Marc Kleine-Budde | 3a7d76d | 2010-02-04 18:54:58 +0100 | [diff] [blame] | 3 | AC_PREREQ(2.59) |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 4 | |
| 5 | AC_INIT([ltrace],[0.5.3],[ltrace-devel <ltrace-devel@lists.alioth.debian.org>]) |
| 6 | AC_CONFIG_HEADERS([config.h]) |
| 7 | AC_CONFIG_SRCDIR(libltrace.c) |
| 8 | #AC_CONFIG_MACRO_DIR([config/m4]) |
| 9 | AC_CONFIG_AUX_DIR([config/autoconf]) |
| 10 | AC_CANONICAL_BUILD |
| 11 | AC_CANONICAL_HOST |
| 12 | |
| 13 | case "${host_os}" in |
| 14 | linux-gnu*) HOST_OS="linux-gnu" ;; |
| 15 | *) AC_MSG_ERROR([unkown host-os ${host_osx}]) ;; |
| 16 | esac |
| 17 | AC_SUBST(HOST_OS) |
| 18 | |
| 19 | case "${host_cpu}" in |
| 20 | arm*|sa110) HOST_CPU="arm" ;; |
| 21 | i?86) HOST_CPU="i386" ;; |
| Petr Machata | 1906248 | 2010-11-01 16:06:12 +0100 | [diff] [blame^] | 22 | powerpc|powerpc64) HOST_CPU="ppc" ;; |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 23 | sun4u|sparc64) HOST_CPU="sparc" ;; |
| 24 | s390x) HOST_CPU="s390" ;; |
| 25 | *) HOST_CPU="${host_cpu}" ;; |
| 26 | esac |
| 27 | AC_SUBST(HOST_CPU) |
| 28 | |
| 29 | # Checks for programs. |
| 30 | AC_PROG_CC |
| Marc Kleine-Budde | 7cae4e0 | 2010-02-04 18:55:22 +0100 | [diff] [blame] | 31 | AC_PROG_LIBTOOL |
| 32 | # libtool-2: LT_INIT() |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 33 | AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2]) |
| Zachary T Welch | d915289 | 2010-11-05 15:02:57 -0700 | [diff] [blame] | 34 | AM_MAINTAINER_MODE |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 35 | |
| 36 | # Checks for libraries. |
| 37 | |
| 38 | # libelf |
| Petr Machata | 8c4aa1f | 2010-11-03 12:16:44 +0100 | [diff] [blame] | 39 | AC_CHECK_HEADERS([elf.h gelf.h],, |
| 40 | [AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])] |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 41 | ) |
| Petr Machata | 8c4aa1f | 2010-11-03 12:16:44 +0100 | [diff] [blame] | 42 | AC_CHECK_LIB([elf], [elf_begin],, |
| 43 | [AC_MSG_ERROR([*** libelf not found on your system])] |
| 44 | ) |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 45 | |
| 46 | |
| 47 | # HAVE_LIBIBERTY |
| 48 | AC_CHECK_LIB([iberty], [cplus_demangle], [ |
| 49 | AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty]) |
| 50 | liberty_LIBS="-liberty"], [ |
| 51 | liberty_LIBS=""]) |
| 52 | AC_SUBST(liberty_LIBS) |
| 53 | |
| 54 | |
| 55 | # HAVE_LIBSUPC__ |
| 56 | AC_CHECK_LIB([supc++], [__cxa_demangle], [ |
| 57 | AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++]) |
| 58 | libsupcxx_LIBS="-lsupc++"], [ |
| 59 | libsupcxx_LIBS=""]) |
| 60 | AC_SUBST(libsupcxx_LIBS) |
| 61 | |
| 62 | |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 63 | # HAVE_LIBUNWIND |
| 64 | AC_ARG_WITH(libunwind, |
| Zachary T Welch | bc7a4a9 | 2010-11-05 15:03:04 -0700 | [diff] [blame] | 65 | AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]), |
| 66 | [case "${withval}" in |
| 67 | (yes|no) enable_libunwind=$withval;; |
| 68 | (*) enable_libunwind=yes |
| 69 | CPPFLAGS="${CPPFLAGS} -I${withval}/include" |
| 70 | LDFLAGS="${LDFLAGS} -L${withval}/lib" |
| 71 | ;; |
| 72 | esac],[enable_libunwind=maybe]) |
| 73 | |
| 74 | AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes]) |
| 75 | AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes]) |
| 76 | |
| 77 | AC_MSG_CHECKING([whether to use libunwind support]) |
| 78 | case "${enable_libunwind}" in |
| 79 | (yes|maybe) |
| 80 | if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then |
| 81 | enable_libunwind=yes |
| 82 | elif test $enable_libunwind = maybe; then |
| 83 | enable_libunwind=no |
| 84 | else |
| 85 | AC_MSG_RESULT([$enable_libunwind]) |
| 86 | AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found]) |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 87 | fi |
| Zachary T Welch | bc7a4a9 | 2010-11-05 15:03:04 -0700 | [diff] [blame] | 88 | ;; |
| 89 | (*) ;; |
| 90 | esac |
| 91 | AC_MSG_RESULT([$enable_libunwind]) |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 92 | |
| 93 | if test x"$enable_libunwind" = xyes; then |
| 94 | AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=) |
| 95 | AC_SUBST(libunwind_LIBS) |
| 96 | AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=) |
| 97 | AC_SUBST(libunwind_ptrace_LIBS) |
| 98 | AC_CHECK_LIB(unwind-${HOST_CPU}, _U${HOST_CPU}_init_remote, libunwind_arch_LIBS=-lunwind-${HOST_CPU}, libunwind_arch_LIBS=) |
| 99 | AC_SUBST(libunwind_arch_LIBS) |
| 100 | AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind]) |
| 101 | fi |
| 102 | |
| 103 | |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 104 | # HAVE_ELF_C_READ_MMAP |
| 105 | AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP]) |
| 106 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[ |
| 107 | int main () { |
| 108 | Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0); |
| 109 | return 0; |
| 110 | } |
| 111 | ]])],[ |
| 112 | AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support]) |
| 113 | AC_MSG_RESULT([yes])],[ |
| 114 | AC_MSG_RESULT([no])]) |
| 115 | |
| 116 | |
| 117 | CPPFLAGS=" \ |
| 118 | ${CPPFLAGS} \ |
| 119 | -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \ |
| 120 | -I\$(top_srcdir)/sysdeps/${HOST_OS} \ |
| 121 | -I\$(top_srcdir)/sysdeps \ |
| 122 | -I\$(top_srcdir) \ |
| 123 | " |
| 124 | |
| 125 | CFLAGS="${CFLAGS} -Wall" |
| 126 | |
| 127 | # Checks for header files. |
| 128 | AC_CHECK_HEADERS([ \ |
| 129 | fcntl.h \ |
| 130 | limits.h \ |
| 131 | stddef.h \ |
| 132 | stdint.h \ |
| 133 | stdlib.h \ |
| 134 | string.h \ |
| 135 | sys/ioctl.h \ |
| 136 | sys/param.h \ |
| 137 | sys/time.h \ |
| 138 | unistd.h \ |
| 139 | ]) |
| 140 | |
| 141 | # Checks for typedefs, structures, and compiler characteristics. |
| 142 | AC_TYPE_UID_T |
| 143 | AC_C_INLINE |
| 144 | AC_TYPE_PID_T |
| 145 | AC_TYPE_SIZE_T |
| 146 | AC_CHECK_SIZEOF([long]) |
| 147 | |
| 148 | |
| 149 | # Checks for library functions. |
| 150 | AC_FUNC_ERROR_AT_LINE |
| 151 | AC_FUNC_FORK |
| 152 | AC_CHECK_FUNCS([ \ |
| 153 | alarm \ |
| 154 | atexit \ |
| 155 | getcwd \ |
| 156 | gettimeofday \ |
| 157 | memset \ |
| 158 | mkdir \ |
| 159 | rmdir \ |
| 160 | strchr \ |
| 161 | strdup \ |
| 162 | strerror \ |
| 163 | strtol \ |
| 164 | strtoul \ |
| 165 | ]) |
| 166 | |
| 167 | |
| 168 | # |
| 169 | # Debugging |
| 170 | # |
| 171 | AC_MSG_CHECKING([whether to enable debugging]) |
| 172 | AC_ARG_ENABLE(debug, |
| 173 | AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]), |
| 174 | [case "$enableval" in |
| 175 | y | yes) CONFIG_DEBUG=yes ;; |
| 176 | *) CONFIG_DEBUG=no ;; |
| 177 | esac], |
| 178 | [CONFIG_DEBUG=no]) |
| 179 | AC_MSG_RESULT([${CONFIG_DEBUG}]) |
| 180 | if test "${CONFIG_DEBUG}" = "yes"; then |
| 181 | CFLAGS="${CFLAGS} -Werror -Wsign-compare -Wfloat-equal -Wformat-security -g -O1" |
| 182 | AC_DEFINE(DEBUG, 1, [debugging]) |
| 183 | else |
| 184 | CFLAGS="${CFLAGS} -O2" |
| 185 | fi |
| 186 | |
| 187 | dnl testsuite/Makefile |
| 188 | dnl testsuite/ltrace.main/Makefile |
| 189 | dnl testsuite/ltrace.minor/Makefile |
| 190 | dnl testsuite/ltrace.torture/Makefile |
| 191 | |
| 192 | AC_CONFIG_FILES([ |
| 193 | Makefile |
| 194 | sysdeps/Makefile |
| 195 | sysdeps/linux-gnu/Makefile |
| 196 | sysdeps/linux-gnu/alpha/Makefile |
| 197 | sysdeps/linux-gnu/arm/Makefile |
| 198 | sysdeps/linux-gnu/i386/Makefile |
| 199 | sysdeps/linux-gnu/ia64/Makefile |
| 200 | sysdeps/linux-gnu/m68k/Makefile |
| 201 | sysdeps/linux-gnu/mipsel/Makefile |
| 202 | sysdeps/linux-gnu/ppc/Makefile |
| 203 | sysdeps/linux-gnu/s390/Makefile |
| 204 | sysdeps/linux-gnu/sparc/Makefile |
| 205 | sysdeps/linux-gnu/x86_64/Makefile |
| Zachary T Welch | 3a9d1e7 | 2010-11-05 15:03:00 -0700 | [diff] [blame] | 206 | testsuite/Makefile |
| 207 | testsuite/ltrace.main/Makefile |
| 208 | testsuite/ltrace.minor/Makefile |
| 209 | testsuite/ltrace.torture/Makefile |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 210 | ]) |
| 211 | AC_OUTPUT |