dnl Define the input and output configuration header file.
AC_CONFIG_HEADER([config.h])
-dnl Demand at least version 2.50 of autoconf
-AC_PREREQ(2.50)
+dnl Demand at least version 2.59 of autoconf (for AS_HELP_STRING)
+AC_PREREQ(2.59)
dnl Find out what type of system we are
AC_CANONICAL_HOST
dnl ANSIfy the C compiler whenever possible.
AM_PROG_CC_STDC
-dnl Use -O3 instead of -O2.
-if test x"$CFLAGS" != x; then
- CFLAGS=`echo "$CFLAGS" | sed -e 's/-O2/-O3/'`
+dnl Allow specification of optimization level.
+AC_ARG_WITH([optimization],
+ AS_HELP_STRING([--with-optimization=[-O2]], [Explicitly set the compiler optimization flags (default: -O3)]),
+ [unet_cv_optimization=$withval],
+ [unet_cv_optimization='-O3'])
+AC_CACHE_CHECK([optimization level], [unet_cv_optimization], [unet_cv_optimization='-O3'])
+if test "x$unet_cv_optimization" = "xno" ; then
+ unet_cv_optimization=""
fi
-dnl Remove -pipe during configure
if test x"$CFLAGS" != x; then
- CFLAGS=`echo "$CFLAGS" | sed -e 's/-pipe//g'`
+ CFLAGS=`echo "$CFLAGS" | sed -e s/-O2/$unet_cv_optimization/`
fi
dnl Notice the -g flag and deal accordingly
if test x"$CFLAGS" != x; then
dnl (F)LEX - needed for the new conf file parser
AC_PROG_LEX
dnl The autoconf docs say $LEX defaults to 'lex'. They lie.
-if [ "$LEX" eq ":" ] ; then
+if test "$LEX" = ":" ; then
AC_MSG_ERROR([Cannot find flex.])
elif echo "" | $LEX -V -v --version > /dev/null 2>&1 ; then
- AC_MSG_ERROR([Cannot find flex.])
+ :
+else
+ AC_MSG_ERROR([Cannot use $LEX as flex.])
fi
if test -z "$LEXLIB" ; then
AC_PROG_YACC
dnl The autoconf docs say $YACC defaults to 'yacc'. This seems to be true,
dnl but judging from AC_PROG_LEX, it may not stay true.
-if [ "$YACC" eq ":" ] ; then
+if test "$YACC" = ":" ; then
AC_MSG_ERROR([Cannot find yacc.])
elif echo "" | $YACC -V -v --version > /dev/null 2>&1 ; then
- AC_MSG_ERROR([Cannot find yacc.])
+ :
+else
+dnl byacc does not seem to have any way to test for workingness, so only warn.
+ AC_MSG_WARN([$YACC may not work as yacc.])
fi
-
unet_NONBLOCKING
unet_SIGNALS
-dnl Add -pipe when possible
-unet_PIPE_CFLAGS
-
dnl Check OS for os_dep files.
AC_MSG_CHECKING(for OS-dependent information)
case "$host" in
AC_MSG_RESULT([$unet_cv_enable_poll])
if test x"$unet_cv_enable_poll" = xyes; then
- AC_DEFINE([USE_POLL], , [Specify whether or not to use poll()])
+ AC_DEFINE([USE_POLL], 1, [Specify whether or not to use poll()])
ENGINE_C=engine_poll.c
else
ENGINE_C=engine_select.c
AC_MSG_RESULT([$unet_cv_enable_debug])
if test x"$unet_cv_enable_debug" = xyes; then
- AC_DEFINE([DEBUGMODE], , [Enable debugging code])
+ AC_DEFINE([DEBUGMODE], 1, [Enable debugging code])
fi
dnl Now look for --enable-leak-detect
[ac_cv_use_ipv6=$unet_have_sockaddr_in6])
AC_CACHE_CHECK([whether to use IPv6], [ac_cv_use_ipv6], [ac_cv_use_ipv6=no])
if test x"$ac_cv_use_ipv6" != "xno" ; then
- AC_DEFINE([IPV6], , [Enable IPv6 support])
+ AC_DEFINE([IPV6], 1, [Enable IPv6 support])
fi
dnl And now for --disable-asserts
AC_MSG_RESULT([$unet_cv_enable_asserts])
if test x"$unet_cv_enable_asserts" = xno; then
- AC_DEFINE([NDEBUG], , [Disable assertions])
+ AC_DEFINE([NDEBUG], 1, [Disable assertions])
fi
dnl Check for --enable-symbols
AC_MSG_RESULT([$unet_cv_enable_inlines])
if test x"$unet_cv_enable_inlines" = xyes; then
- AC_DEFINE([FORCEINLINE], , [Force inlining for a few critical functions])
+ AC_DEFINE([FORCEINLINE], 1, [Force inlining for a few critical functions])
fi
dnl --disable-devpoll check...
AC_MSG_RESULT([$unet_cv_enable_devpoll])
if test x"$unet_cv_enable_devpoll" != xno; then
- AC_DEFINE([USE_DEVPOLL], , [Define to enable the /dev/poll engine])
+ AC_DEFINE([USE_DEVPOLL], 1, [Define to enable the /dev/poll engine])
ENGINE_C="engine_devpoll.c $ENGINE_C"
fi
AC_MSG_RESULT([$unet_cv_enable_kqueue])
if test x"$unet_cv_enable_kqueue" != xno; then
- AC_DEFINE([USE_KQUEUE], , [Define to enable the kqueue engine])
+ AC_DEFINE([USE_KQUEUE], 1, [Define to enable the kqueue engine])
ENGINE_C="engine_kqueue.c $ENGINE_C"
fi
AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/epoll.h>], [epoll_create(10);])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
- AC_DEFINE([EPOLL_NEED_BODY],,[Define to implement epoll system calls])])
- AC_DEFINE([USE_EPOLL], , [Define to enable the epoll engine])
+ AC_DEFINE([EPOLL_NEED_BODY], 1, [Define to implement epoll system calls])])
+ AC_DEFINE([USE_EPOLL], 1, [Define to enable the epoll engine])
ENGINE_C="engine_epoll.c $ENGINE_C"
fi