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