1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
|
AC_PREREQ([2.59])
AC_INIT([mtr],
[m4_esyscmd([build-aux/git-version-gen .tarball-version])],
[R.E.Wolff@BitWizard.nl], [],
[http://www.BitWizard.nl/mtr/])
AC_CONFIG_SRCDIR([ui/mtr.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([
1.7.9
foreign
subdir-objects
])
# --enable-silent-rules
m4_ifdef([AM_SILENT_RULES],
[AM_SILENT_RULES([yes])],
[AC_SUBST([AM_DEFAULT_VERBOSITY], [1])])
AC_CANONICAL_HOST
AC_PROG_CC
# Check pkg-config availability.
m4_ifndef([PKG_CHECK_MODULES], [m4_defun([PKG_CHECK_MODULES], [AC_MSG_ERROR(
[Could not locate the pkg-config autoconf macros. These are usually located
in /usr/share/aclocal/pkg.m4. If your macros are in a different location,
try setting the environment variable ACLOCAL_OPTS="-I/other/macro/dir"
before running ./bootstrap.sh again, or configure --without-gtk ----without-jansson ])])
])
PKG_PROG_PKG_CONFIG
AM_CONDITIONAL([CYGWIN], [test "$host_os" = cygwin])
AM_COND_IF([CYGWIN],
[AC_DEFINE([USING_CYGWIN], [1], [Building Under Cygwin.])],
[])
# Check bytes in types.
AC_CHECK_SIZEOF([unsigned char], [1])
AC_CHECK_SIZEOF([unsigned short], [2])
AC_CHECK_SIZEOF([unsigned int], [4])
AC_CHECK_SIZEOF([unsigned long], [4])
# Check headers.
AC_CHECK_HEADERS([ \
arpa/nameser_compat.h \
curses.h \
cursesX.h \
error.h \
fcntl.h \
linux/icmp.h \
linux/errqueue.h \
ncurses.h \
ncurses/curses.h \
netinet/in.h \
socket.h \
sys/cdefs.h \
sys/limits.h \
sys/socket.h \
stdio_ext.h \
sys/types.h \
sys/xti.h \
values.h \
])
# Check functions.
AC_CHECK_FUNCS([ \
__fpending \
fcntl \
])
AC_CHECK_FUNC([error], [with_error=no],
[AC_CHECK_FUNCS([verr verrx vwarn vwarnx], [with_error=yes],
[AC_MSG_ERROR([cannot find working error printing function])
])
])
AM_CONDITIONAL([WITH_ERROR], [test "x$with_error" = "xyes"])
AC_CHECK_FUNC([getopt_long], [with_getopt=no], [with_getopt=yes])
AS_IF([test "x$with_getopt" = "xno"], [
AC_DEFINE([HAVE_GETOPT], [1], [Define if libc has getopt_long])
])
AM_CONDITIONAL([WITH_GETOPT], [test "x$with_getopt" = "xyes"])
AC_CHECK_LIB([m], [floor], [], [AC_MSG_ERROR([No math library found])])
# libasan
AC_ARG_WITH([libasan],
[AS_HELP_STRING([--with-libasan], [Build with AddressSanitizer])],
[with_libasan=yes], [])
AM_CONDITIONAL([WITH_LIBASAN], [test "x$with_libasan" = "xyes"])
# Find GTK
AC_ARG_WITH([gtk],
[AS_HELP_STRING([--without-gtk], [Build without the GTK+ interface])],
[], [with_gtk=yes])
AS_IF([test "x$with_gtk" = "xyes"],
[PKG_CHECK_MODULES([GTK], [gtk+-3.0],
[AC_DEFINE([HAVE_GTK], [1], [Define if gtk+ library available])]
[AC_DEFINE([HAVE_GTK3], [1], [Define if gtk+-3.0 library available])],
[PKG_CHECK_MODULES([GTK], [gtk+-2.0],
[AC_DEFINE([HAVE_GTK], [1], [Define if gtk+ library available])],
[with_gtk=no])])
])
AM_CONDITIONAL([WITH_GTK], [test "x$with_gtk" = xyes])
AC_ARG_WITH([jansson],
[AS_HELP_STRING([--without-jansson], [Build without JSON output])],
[], [with_jansson=yes])
AS_IF([test "x$with_jansson" = "xyes"],
[PKG_CHECK_MODULES([JANSSON], [jansson],
[AC_DEFINE([HAVE_JANSSON], [1], [Define if jansson library available])],
[with_jansson=no])
])
# Find ncurses
AC_ARG_WITH([ncurses],
[AS_HELP_STRING([--without-ncurses], [Build without the ncurses interface])],
[], [with_ncurses=yes])
AS_IF([test "x$with_ncurses" = "xyes"],
# Prefer ncurses over curses, if both are available.
# (On Solaris 11.3, ncurses builds and links for us, but curses does not.)
[AC_SEARCH_LIBS(
[initscr], [ncurses curses],
[AC_DEFINE([HAVE_CURSES], [1], [Define if a curses library available])],
[with_ncurses=no])
])
AM_CONDITIONAL([WITH_CURSES], [test "x$with_ncurses" = xyes])
AC_CHECK_LIB([cap], [cap_set_proc], [have_cap="yes"],
AS_IF([test "$host_os" = linux-gnu],
AC_MSG_WARN([Capabilities support is strongly recommended for increased security. See SECURITY for more information.])))
# Enable ipinfo
AC_ARG_WITH([ipinfo],
[AS_HELP_STRING([--without-ipinfo], [Do not try to use ipinfo lookup at all])],
[], [with_ipinfo=yes])
AM_CONDITIONAL([WITH_IPINFO], [test "x$with_ipinfo" = "xyes"])
AS_IF([test "x$with_ipinfo" = "xyes"], [
AC_DEFINE([HAVE_IPINFO], [1], [Define when ipinfo lookups are in use])
])
AC_ARG_ENABLE([ipv6],
[AS_HELP_STRING([--disable-ipv6], [Do not enable IPv6])],
[WANTS_IPV6=$enableval], [WANTS_IPV6=yes])
AS_IF([test "x$WANTS_IPV6" = "xyes"], [
AC_DEFINE([ENABLE_IPV6], [1], [Define to enable IPv6])
USES_IPV6=yes
])
AC_CHECK_FUNC([socket], [],
[AC_CHECK_LIB([socket], [socket], [], [AC_MSG_ERROR([No socket library found])])])
AC_CHECK_FUNC([gethostbyname], [],
[AC_CHECK_LIB([nsl], [gethostbyname], [], [AC_MSG_ERROR([No nameservice library found])])])
# Find resolver library.
AC_CHECK_FUNC([res_query], [RESOLV_LIBS=""], [
AC_CHECK_LIB([resolv], [__res_query], [RESOLV_LIBS="-lresolv"], [
AC_CHECK_LIB([resolv], [res_query], [RESOLV_LIBS="-lresolv"], [
AC_CHECK_LIB([bind], [res_query], [RESOLV_LIBS="-lbind"], [
AC_MSG_ERROR([No resolver library found])
])
])
])
])
dnl MacOS has res_query in libc, but needs libresolv for dn_expand().
AS_IF([test "x" = "x$RESOLV_LIBS"], [
AC_CHECK_LIB([resolv], [dn_expand], [RESOLV_LIBS="-lresolv"])
])
AC_SUBST([RESOLV_LIBS])
# Check errno and socket data types.
AC_CHECK_DECLS([errno], [], [], [[
#include <errno.h>
#include <sys/errno.h>
]])
AC_CHECK_TYPE([socklen_t],
[AC_DEFINE([HAVE_SOCKLEN_T], [], [Define if your system has socklen_t])], [],
[[#include <netinet/in.h>
#ifdef HAVE_SOCKET_H
#include <socket.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif]])
AC_CHECK_TYPES([time_t], [], [], [[
#include <time.h>
]])
# Add C flags to display more warnings
AC_MSG_CHECKING([for C flags to get more warnings])
ac_save_CFLAGS="$CFLAGS"
AS_IF([test "x$ac_cv_c_compiler_gnu" = "xyes"], [
dnl gcc is the easiest C compiler
warning_CFLAGS="-Wall"
# Check if compiler supports -Wno-pointer-sign and add it if supports
CFLAGS_saved="$CFLAGS"
CFLAGS="$CFLAGS -Wno-pointer-sign"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int foo;]])],
[warning_CFLAGS="${warning_CFLAGS} -Wno-pointer-sign"], [])
CFLAGS="$CFLAGS_saved"
], [
dnl Vendor supplied C compilers are a bit tricky
AS_CASE([$host_os],
dnl SGI IRIX with the MipsPRO C compiler
[irix*], [
CFLAGS="$CFLAGS -fullwarn"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[[#include <stdio.h>]],
[[printf("test");]])],
[warning_CFLAGS="-fullwarn"], []
)
],
dnl SunOS 4.x with the SparcWorks(?) acc compiler
[sunos*], [
AS_IF([test "$CC" = "acc"], [
CFLAGS="$CFLAGS -vc"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[[#include <stdio.h>]],
[[printf("test");]])],
[warning_CFLAGS="-vc"], []
)
])
]
dnl Unknown, do nothing
[*], [
warning_CFLAGS="none"
]
)
])
CFLAGS="$ac_save_CFLAGS"
AS_IF([test "$warning_CFLAGS" = "none"], [
AC_MSG_RESULT([none])
], [
CFLAGS="$CFLAGS $warning_CFLAGS"
AC_MSG_RESULT([$warning_CFLAGS])
])
# bash-completion
AC_ARG_WITH([bashcompletiondir],
AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]),
[],
[AS_IF([`$PKG_CONFIG --exists bash-completion`], [
with_bashcompletiondir=`$PKG_CONFIG --variable=completionsdir bash-completion`
], [
with_bashcompletiondir=${datadir}/bash-completion/completions
])
])
AC_SUBST([bashcompletiondir], [$with_bashcompletiondir])
AC_ARG_ENABLE([bash-completion],
AS_HELP_STRING([--disable-bash-completion], [do not install bash completion files]),
[], [enable_bash_completion=yes]
)
AM_CONDITIONAL([BUILD_BASH_COMPLETION], [test "x$enable_bash_completion" = xyes])
echo "build options:"
echo "--------------"
echo "libasan :$with_libasan"
echo "ipv6 :$USES_IPV6"
echo "ipinfo :$with_ipinfo"
echo "ncurses :$with_ncurses"
echo "gtk :$with_gtk"
echo "jansson :$with_jansson"
echo "cap :$have_cap"
echo "libs :$LIBS"
echo "cflags :$CFLAGS"
echo "--------------"
# Prepare config.h, Makefile, and output them.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
|