| 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 | |
| Zachary T Welch | ded5ea8 | 2010-12-06 23:20:58 -0800 | [diff] [blame] | 5 | AC_INIT([ltrace],[0.5.3],[ltrace-devel@lists.alioth.debian.org]) |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 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 | |
| Zachary T Welch | 6188614 | 2010-12-10 14:52:33 -0800 | [diff] [blame^] | 36 | AC_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 | ;; |
| 49 | esac],[]) |
| 50 | |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 51 | # Checks for libraries. |
| 52 | |
| Zachary T Welch | 6188614 | 2010-12-10 14:52:33 -0800 | [diff] [blame^] | 53 | saved_CPPFLAGS="${CPPFLAGS}" |
| 54 | saved_LDFLAGS="${LDFLAGS}" |
| 55 | CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" |
| 56 | LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 57 | # libelf |
| Petr Machata | 8c4aa1f | 2010-11-03 12:16:44 +0100 | [diff] [blame] | 58 | AC_CHECK_HEADERS([elf.h gelf.h],, |
| 59 | [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] | 60 | ) |
| Petr Machata | 8c4aa1f | 2010-11-03 12:16:44 +0100 | [diff] [blame] | 61 | AC_CHECK_LIB([elf], [elf_begin],, |
| 62 | [AC_MSG_ERROR([*** libelf not found on your system])] |
| 63 | ) |
| Zachary T Welch | 6188614 | 2010-12-10 14:52:33 -0800 | [diff] [blame^] | 64 | CPPFLAGS="${saved_CPPFLAGS}" |
| 65 | LDFLAGS="${saved_LDFLAGS}" |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 66 | |
| 67 | |
| 68 | # HAVE_LIBIBERTY |
| 69 | AC_CHECK_LIB([iberty], [cplus_demangle], [ |
| 70 | AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty]) |
| 71 | liberty_LIBS="-liberty"], [ |
| 72 | liberty_LIBS=""]) |
| 73 | AC_SUBST(liberty_LIBS) |
| 74 | |
| 75 | |
| 76 | # HAVE_LIBSUPC__ |
| 77 | AC_CHECK_LIB([supc++], [__cxa_demangle], [ |
| 78 | AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++]) |
| 79 | libsupcxx_LIBS="-lsupc++"], [ |
| 80 | libsupcxx_LIBS=""]) |
| 81 | AC_SUBST(libsupcxx_LIBS) |
| 82 | |
| 83 | |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 84 | # HAVE_LIBUNWIND |
| 85 | AC_ARG_WITH(libunwind, |
| Zachary T Welch | bc7a4a9 | 2010-11-05 15:03:04 -0700 | [diff] [blame] | 86 | AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]), |
| 87 | [case "${withval}" in |
| 88 | (yes|no) enable_libunwind=$withval;; |
| 89 | (*) enable_libunwind=yes |
| Zachary T Welch | d0fafff | 2010-12-08 18:55:13 -0800 | [diff] [blame] | 90 | AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include" |
| 91 | AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib" |
| Zachary T Welch | bc7a4a9 | 2010-11-05 15:03:04 -0700 | [diff] [blame] | 92 | ;; |
| 93 | esac],[enable_libunwind=maybe]) |
| 94 | |
| Zachary T Welch | d0fafff | 2010-12-08 18:55:13 -0800 | [diff] [blame] | 95 | saved_CPPFLAGS="${CPPFLAGS}" |
| 96 | CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" |
| Zachary T Welch | bc7a4a9 | 2010-11-05 15:03:04 -0700 | [diff] [blame] | 97 | AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes]) |
| 98 | AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes]) |
| Zachary T Welch | d0fafff | 2010-12-08 18:55:13 -0800 | [diff] [blame] | 99 | CPPFLAGS="${saved_CPPFLAGS}" |
| Zachary T Welch | bc7a4a9 | 2010-11-05 15:03:04 -0700 | [diff] [blame] | 100 | |
| 101 | AC_MSG_CHECKING([whether to use libunwind support]) |
| 102 | case "${enable_libunwind}" in |
| 103 | (yes|maybe) |
| 104 | if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then |
| 105 | enable_libunwind=yes |
| 106 | elif test $enable_libunwind = maybe; then |
| 107 | enable_libunwind=no |
| 108 | else |
| 109 | AC_MSG_RESULT([$enable_libunwind]) |
| 110 | AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found]) |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 111 | fi |
| Zachary T Welch | bc7a4a9 | 2010-11-05 15:03:04 -0700 | [diff] [blame] | 112 | ;; |
| 113 | (*) ;; |
| 114 | esac |
| 115 | AC_MSG_RESULT([$enable_libunwind]) |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 116 | |
| 117 | if test x"$enable_libunwind" = xyes; then |
| Zachary T Welch | d0fafff | 2010-12-08 18:55:13 -0800 | [diff] [blame] | 118 | saved_LDFLAGS="${LDFLAGS}" |
| 119 | LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 120 | AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=) |
| 121 | AC_SUBST(libunwind_LIBS) |
| 122 | AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=) |
| 123 | AC_SUBST(libunwind_ptrace_LIBS) |
| Joe Damato | afb4434 | 2010-11-07 15:33:36 -0800 | [diff] [blame] | 124 | |
| 125 | case "${host_cpu}" in |
| 126 | arm*|sa110) UNWIND_ARCH="arm" ;; |
| 127 | i?86) UNWIND_ARCH="x86" ;; |
| 128 | powerpc) UNWIND_ARCH="ppc32" ;; |
| 129 | ppc64) UNWIND_ARCH="ppc64" ;; |
| 130 | mips*) UNWIND_ARCH="mips" ;; |
| 131 | *) UNWIND_ARCH="${host_cpu}" ;; |
| 132 | esac |
| 133 | |
| 134 | AC_CHECK_LIB(unwind-${UNWIND_ARCH}, _U${UNWIND_ARCH}_init_remote, libunwind_arch_LIBS=-lunwind-${UNWIND_ARCH}, libunwind_arch_LIBS=) |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 135 | AC_SUBST(libunwind_arch_LIBS) |
| 136 | AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind]) |
| Zachary T Welch | d0fafff | 2010-12-08 18:55:13 -0800 | [diff] [blame] | 137 | LDFLAGS="${saved_LDFLAGS}" |
| Joe Damato | ab3b72c | 2010-10-31 00:21:53 -0700 | [diff] [blame] | 138 | fi |
| 139 | |
| 140 | |
| Zachary T Welch | 6188614 | 2010-12-10 14:52:33 -0800 | [diff] [blame^] | 141 | saved_CPPFLAGS="${CPPFLAGS}" |
| 142 | saved_LDFLAGS="${LDFLAGS}" |
| 143 | CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}" |
| 144 | LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}" |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 145 | # HAVE_ELF_C_READ_MMAP |
| 146 | AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP]) |
| 147 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[ |
| 148 | int main () { |
| 149 | Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0); |
| 150 | return 0; |
| 151 | } |
| 152 | ]])],[ |
| 153 | AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support]) |
| 154 | AC_MSG_RESULT([yes])],[ |
| 155 | AC_MSG_RESULT([no])]) |
| 156 | |
| Zachary T Welch | 0a43b32 | 2010-12-08 18:55:10 -0800 | [diff] [blame] | 157 | saved_CFLAGS="${CFLAGS}" |
| 158 | CFLAGS="${CFLAGS} -Wall -Werror" |
| 159 | AC_MSG_CHECKING([whether elf_hash takes a signed char string]) |
| 160 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[ |
| 161 | (void) elf_hash("name"); |
| 162 | ]])], |
| 163 | [AC_DEFINE([ELF_HASH_TAKES_SIGNED_CHAR], [1], |
| 164 | [elf_hash() takes signed char]) |
| 165 | AC_MSG_RESULT([yes])], |
| 166 | [AC_MSG_RESULT([no])]) |
| 167 | CFLAGS="${saved_CFLAGS}" |
| Zachary T Welch | 6188614 | 2010-12-10 14:52:33 -0800 | [diff] [blame^] | 168 | CPPFLAGS="${saved_CPPFLAGS}" |
| 169 | LDFLAGS="${saved_LDFLAGS}" |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 170 | |
| Zachary T Welch | d0fafff | 2010-12-08 18:55:13 -0800 | [diff] [blame] | 171 | AM_CPPFLAGS=" \ |
| 172 | ${AM_CPPFLAGS} \ |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 173 | -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \ |
| 174 | -I\$(top_srcdir)/sysdeps/${HOST_OS} \ |
| 175 | -I\$(top_srcdir)/sysdeps \ |
| 176 | -I\$(top_srcdir) \ |
| 177 | " |
| 178 | |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 179 | # Checks for header files. |
| 180 | AC_CHECK_HEADERS([ \ |
| 181 | fcntl.h \ |
| 182 | limits.h \ |
| 183 | stddef.h \ |
| 184 | stdint.h \ |
| 185 | stdlib.h \ |
| 186 | string.h \ |
| 187 | sys/ioctl.h \ |
| 188 | sys/param.h \ |
| 189 | sys/time.h \ |
| 190 | unistd.h \ |
| 191 | ]) |
| 192 | |
| 193 | # Checks for typedefs, structures, and compiler characteristics. |
| 194 | AC_TYPE_UID_T |
| 195 | AC_C_INLINE |
| 196 | AC_TYPE_PID_T |
| 197 | AC_TYPE_SIZE_T |
| 198 | AC_CHECK_SIZEOF([long]) |
| 199 | |
| 200 | |
| 201 | # Checks for library functions. |
| 202 | AC_FUNC_ERROR_AT_LINE |
| 203 | AC_FUNC_FORK |
| 204 | AC_CHECK_FUNCS([ \ |
| 205 | alarm \ |
| 206 | atexit \ |
| 207 | getcwd \ |
| 208 | gettimeofday \ |
| 209 | memset \ |
| 210 | mkdir \ |
| 211 | rmdir \ |
| 212 | strchr \ |
| 213 | strdup \ |
| 214 | strerror \ |
| 215 | strtol \ |
| 216 | strtoul \ |
| 217 | ]) |
| 218 | |
| 219 | |
| 220 | # |
| 221 | # Debugging |
| 222 | # |
| 223 | AC_MSG_CHECKING([whether to enable debugging]) |
| 224 | AC_ARG_ENABLE(debug, |
| 225 | AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]), |
| 226 | [case "$enableval" in |
| 227 | y | yes) CONFIG_DEBUG=yes ;; |
| 228 | *) CONFIG_DEBUG=no ;; |
| 229 | esac], |
| 230 | [CONFIG_DEBUG=no]) |
| 231 | AC_MSG_RESULT([${CONFIG_DEBUG}]) |
| 232 | if test "${CONFIG_DEBUG}" = "yes"; then |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 233 | AC_DEFINE(DEBUG, 1, [debugging]) |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 234 | fi |
| 235 | |
| Zachary T Welch | fe6c805 | 2010-12-08 18:55:11 -0800 | [diff] [blame] | 236 | # Ignore the compiler's warnings at your own risk. |
| 237 | AM_CFLAGS="${AM_CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security" |
| 238 | AC_ARG_ENABLE([werror], |
| 239 | AS_HELP_STRING([--disable-werror], [disable use of -Werror]), |
| 240 | [enable_werror=$enableval], [enable_werror=yes]) |
| 241 | if test x$enable_werror = xyes; then |
| 242 | AM_CFLAGS="${AM_CFLAGS} -Werror" |
| 243 | fi |
| 244 | |
| Zachary T Welch | d0fafff | 2010-12-08 18:55:13 -0800 | [diff] [blame] | 245 | AC_SUBST(AM_CPPFLAGS) |
| Zachary T Welch | fe6c805 | 2010-12-08 18:55:11 -0800 | [diff] [blame] | 246 | AC_SUBST(AM_CFLAGS) |
| Zachary T Welch | d0fafff | 2010-12-08 18:55:13 -0800 | [diff] [blame] | 247 | AC_SUBST(AM_LDFLAGS) |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 248 | |
| 249 | AC_CONFIG_FILES([ |
| 250 | Makefile |
| 251 | sysdeps/Makefile |
| 252 | sysdeps/linux-gnu/Makefile |
| 253 | sysdeps/linux-gnu/alpha/Makefile |
| 254 | sysdeps/linux-gnu/arm/Makefile |
| 255 | sysdeps/linux-gnu/i386/Makefile |
| 256 | sysdeps/linux-gnu/ia64/Makefile |
| 257 | sysdeps/linux-gnu/m68k/Makefile |
| 258 | sysdeps/linux-gnu/mipsel/Makefile |
| 259 | sysdeps/linux-gnu/ppc/Makefile |
| 260 | sysdeps/linux-gnu/s390/Makefile |
| 261 | sysdeps/linux-gnu/sparc/Makefile |
| 262 | sysdeps/linux-gnu/x86_64/Makefile |
| Zachary T Welch | 3a9d1e7 | 2010-11-05 15:03:00 -0700 | [diff] [blame] | 263 | testsuite/Makefile |
| 264 | testsuite/ltrace.main/Makefile |
| 265 | testsuite/ltrace.minor/Makefile |
| 266 | testsuite/ltrace.torture/Makefile |
| Marc Kleine-Budde | 584929c | 2010-02-03 20:24:13 +0100 | [diff] [blame] | 267 | ]) |
| 268 | AC_OUTPUT |