Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
348 lines (280 sloc) 8.58 KB
dnl
dnl lmap -- configure script
dnl
dnl Copyright (C) 2001 ALoR <alor@antifork.org>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
dnl
AC_INIT(include/lmap.h)
dnl Force autoconf 2.50
AC_PREREQ(2.50)
VERSION=`grep LMAP_VERSION ./include/lmap_version.h | cut -f2 -d"\""`
AC_CONFIG_SRCDIR(src/missing)
AM_INIT_AUTOMAKE(lmap, $VERSION)
AM_CONFIG_HEADER(include/config.h)
SB=`./shtool echo -n -e %B`
EB=`./shtool echo -n -e %b`
AC_SUBST(SB)
AC_SUBST(EB)
AC_SUBST(VERSION)
LMAP_MESSAGE(Configuring lmap-$VERSION)
dnl ================
dnl Check the OS
dnl ================
AC_CANONICAL_HOST
AH_TEMPLATE(OS_LINUX, [compiling under linux])
AH_TEMPLATE(OS_BSD, [compiling under bsd])
dnl the subtype for BSD only used if there are significant differences
AH_TEMPLATE(OS_BSD_FREE, [compiling under free bsd])
AH_TEMPLATE(OS_BSD_OPEN, [compiling under open bsd])
AH_TEMPLATE(OS_BSD_NET, [compiling under net bsd])
AH_TEMPLATE(OS_MACOSX, [compiling under macosx])
AH_TEMPLATE(OS_SOLARIS, [compiling under solaris])
case "$host_os" in
*linux*)
AC_DEFINE(OS_LINUX)
PTHREADLIB="-lpthread"
;;
*freebsd*)
AC_DEFINE(OS_BSD)
AC_DEFINE(OS_BSD_FREE)
PTHREADLIB="-pthread"
;;
*openbsd*)
AC_DEFINE(OS_BSD)
AC_DEFINE(OS_BSD_OPEN)
PTHREADLIB="-pthread"
;;
*netbsd*)
AC_DEFINE(OS_BSD)
AC_DEFINE(OS_BSD_NET)
PTHREADLIB="-pthread"
;;
*darwin*)
AC_DEFINE(OS_MACOSX)
PTHREADLIB="-lpthread"
;;
*solaris*)
AC_DEFINE(OS_SOLARIS)
PTHREADLIB="-lpthread"
SOCKETLIB="-lsocket -lnsl"
;;
*)
echo
echo "NOT A SUPPORTED SYSTEM / OR SYSTEM NOT RECOGNIZED"
echo
exit 1
;;
esac
dnl ======================
dnl Initialize prefix.
dnl ======================
AC_PREFIX_DEFAULT(/usr/local)
if test "$prefix" = "NONE"; then
prefix="/usr/local"
fi
AH_TEMPLATE(INSTALL_PREFIX, [where can I find my conf file ?])
AC_DEFINE_UNQUOTED(INSTALL_PREFIX, "${prefix}")
dnl ========================
dnl Check the C compiler
dnl ========================
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_GCC_TRADITIONAL
dnl ======================
dnl Machine Endianness
dnl ======================
AC_C_BIGENDIAN
dnl =====================
dnl Check for headers
dnl =====================
AC_HEADER_STDC
AC_HEADER_TIME
dnl These are required !!
AC_CHECK_HEADERS(unistd.h stdlib.h signal.h stdarg.h sys/ioctl.h sys/types.h errno.h,,
AC_MSG_WARN(****************************************************);
AC_MSG_WARN(* REQUIRED !! I cant believe you don't have this !!*);
AC_MSG_WARN(****************************************************);
exit 1)
AC_CHECK_HEADERS(queue.h)
AC_CHECK_HEADERS(fcntl.h ctype.h)
AC_CHECK_HEADERS(sys/types.h stdint.h)
AC_CHECK_HEADERS(sys/time.h sys/utsname.h)
AC_CHECK_HEADERS(termios.h)
dnl ==================================================================
dnl Checks for typedefs, structures, and compiler characteristics.
dnl ==================================================================
AC_STRUCT_TM
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_C_CONST
dnl =====================
dnl Check for libs
dnl =====================
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
dnl ===============================
dnl Check for non standard libs
dnl ===============================
AC_CHECK_FUNCS([strlcpy], , AC_LIBOBJ(missing/strlcpy) )
AC_CHECK_FUNCS([strlcat], , AC_LIBOBJ(missing/strlcat) )
AC_CHECK_FUNCS([strsep], , AC_LIBOBJ(missing/strsep) )
AC_CHECK_FUNCS([memmem], , AC_LIBOBJ(missing/memmem) )
AC_CHECK_FUNCS([memcmp], , AC_LIBOBJ(missing/memcmp) )
AC_CHECK_FUNCS([getopt_long], , AC_LIBOBJ(missing/getopt) AC_LIBOBJ(missing/getopt_long) )
dnl =======================================
dnl Check user defined --enable-FEATURE
dnl =======================================
LMAP_MESSAGE(Checking user defined options)
dnl -----------
dnl -- DEBUG --
dnl -----------
AH_TEMPLATE(DEBUG, [debug support])
ac_cv_lmap_debug=no
AC_MSG_CHECKING([if --enable-debug option is specified])
AC_ARG_ENABLE(debug, [ --enable-debug create a file for debugging messages.],
[ case "$enableval" in
yes)
AC_DEFINE(DEBUG, 1)
CFLAGS="$CFLAGS -g -ggdb -Wmissing-prototypes -Werror -Wall"
AC_MSG_RESULT(yes)
ac_cv_lmap_debug=yes
;;
no) AC_MSG_RESULT(no.)
CFLAGS="$CFLAGS -O2 -funroll-loops -fomit-frame-pointer -Wall"
ac_cv_lmap_debug=no
;;
esac ],
AC_MSG_RESULT(no. disabled by default.)
CFLAGS="$CFLAGS -O2 -funroll-loops -fomit-frame-pointer -Wall"
ac_cv_lmap_debug=no
)
dnl ==================
dnl Check for libs
dnl ==================
ac_cv_lmap_libpcap=default
AC_MSG_CHECKING(for libpcap)
AC_ARG_WITH(libpcap,
[ --with-libpcap=DIR use libpcap in DIR],
[ case "$withval" in
yes|no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT($withval)
if test -f $withval/pcap.h -a -f $withval/libpcap.a; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
PCAPINC="-I$withval"
PCAPLIB="-L$withval -lpcap"
ac_cv_sad_libpcap=$withval
elif test -f $withval/include/pcap.h -a \
-f $withval/include/net/bpf.h -a \
-f $withval/lib/libpcap.a; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
PCAPINC="-I$withval/include"
PCAPLIB="-L$withval/lib -lpcap"
ac_cv_sad_libpcap=$withval
else
AC_ERROR(pcap.h, net/bpf.h, or libpcap.a not found in $withval)
fi
;;
esac ],
[ if test -f /usr/include/pcap/pcap.h; then
PCAPINC="-I/usr/include/pcap"
PCAPLIB="-lpcap"
elif test -f /usr/include/pcap.h; then
PCAPLIB="-lpcap"
elif test -f /usr/local/include/pcap.h; then
PCAPINC="-I/usr/local/include"
PCAPLIB="-lpcap"
else
AC_MSG_RESULT(no)
AC_ERROR(libpcap not found)
fi
AC_MSG_RESULT(yes) ]
)
AH_TEMPLATE(HAVE_NCURSES, [ncurses support])
ac_cv_lmap_libncurses=default
AC_MSG_CHECKING(for libncurses)
AC_ARG_WITH(libncurses,
[ --with-libncurses=DIR use libncurses in DIR],
[ case "$withval" in
yes|no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT($withval)
if test -f $withval/ncurses.h -a -f $withval/libncurses.a; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
NCURSINC="-I$withval"
NCURSLIB="-L$withval -lncurses"
AC_DEFINE(HAVE_NCURSES, 1)
ac_cv_lmap_libncurses=$withval
elif test -f $withval/include/ncurses.h -a \
-f $withval/lib/libncurses.a; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
NCURSINC="-I$withval/include"
NCURSLIB="-L$withval/lib -lncurses"
AC_DEFINE(HAVE_NCURSES, 1)
ac_cv_lmap_libncurses=$withval
else
AC_ERROR(ncurses.h or libncurses.a not found in $withval)
fi
;;
esac ],
[ if test -f /usr/include/ncurses/ncurses.h; then
NCURSINC="-I/usr/include/ncurses"
NCURSLIB="-lncurses"
AC_DEFINE(HAVE_NCURSES, 1)
elif test -f /usr/include/ncurses.h; then
NCURSLIB="-lncurses"
AC_DEFINE(HAVE_NCURSES, 1)
else
AC_MSG_RESULT(no)
AC_ERROR(libncurses not found)
fi
AC_MSG_RESULT(yes) ]
)
LMAP_CFLAGS="$PCAPINC $NCURSINC"
LMAP_LIBS="$LIBS $PCAPLIB $NCURSLIB $PTHREADLIB $SOCKETLIB"
AC_SUBST(LMAP_CFLAGS)
AC_SUBST(LMAP_LIBS)
dnl ===============
dnl FINISHED !!
dnl ===============
LMAP_MESSAGE(Writing output files)
AC_OUTPUT(man/lmap.8 Makefile man/Makefile src/Makefile include/Makefile)
dnl ===============
dnl THE SUMMARY
dnl ===============
LMAP_MESSAGE(lmap has been configured as follow)
echo "=================================================="
echo
LMAP_CHECK_OPTION(" Install directory: ",${prefix})
echo
echo
LMAP_CHECK_OPTION(" DEBUG mode ....... ",${ac_cv_lmap_debug})
LMAP_CHECK_OPTION(" LIBPCAP .......... ",${ac_cv_lmap_libpcap})
LMAP_CHECK_OPTION(" LIBNCURSES ....... ",${ac_cv_lmap_libncurses})
echo
echo "=================================================="
echo
dnl vim:ts=3:expandtab