#
#      configure.in from Wireless Access Point Utilites for Unix
#
#  Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License Version 2 from
#  June 1991 as published by the Free Software Foundation.
#
#  This program is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License along
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
AC_INIT([lib/snmp.c])
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE(ap-utils, 1.5)
AM_CONFIG_HEADER(config.h)

ac_aux_dir=config
ac_config_guess=config/config.guess
ac_config_sub=config/config.sub

# Checks for programs.
AC_PROG_CC
AC_PROG_RANLIB

# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([arpa/inet.h fcntl.h malloc.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h syslog.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_CHECK_MEMBER(struct sockaddr.sa_len,
		AC_DEFINE(HAVE_SA_LEN, 1,
		    Define if your (struct sockadr) has an sa_len member),,
		[
#include <sys/types.h>
#include <sys/socket.h>
])

# Checks for library functions.
AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([alarm inet_ntoa socket strtol sysinfo fork malloc free])

ALL_LINGUAS="uk fr pl ro nl tr"

AM_GNU_GETTEXT

aputils_save_LIBS="$LIBS"
AC_CHECK_LIB(ncurses, initscr, CURSESLIBS="-lncurses", NOCURSES=yes)
if test "$NOCURSES" = yes; then
	AC_CHECK_LIB(curses, initscr, CURSESLIBS="-lcurses", AC_MSG_ERROR([ap-utils requires installed ncurses or Sys V curses to build]))
fi
LIBS="$aputils_save_LIBS"

# Check for OS and make OS define OS specific variables
case "$host_os" in
 *bsd*|*darwin* )
	AC_DEFINE(OS_BSD, 1, Define if target OS is BSD)
	case "$host_os" in
    	 netbsd* )
	    ap_config_LDADD="-lncurses"
	    CC="$CC -R/usr/pkg/lib -L/usr/pkg/lib -I/usr/pkg/include"
	    ;;
	 openbsd* )
	    ;;
	 *darwin* )
	    AC_DEFINE(OS_X, 1, Define if target OS is MacOS X)
	    ;;
	esac
	;;
 *qnx )
	LIBS="$LIBS -lsocket"
	INSTALL="config/install-sh"
	;;
 aix4* )
    case "$CC" in
     cc* | xlc* )
	CC="$CC -qcpluscmt -qmaxmem=16384"
    esac
    ;;
 solaris* )
    	AC_DEFINE(OS_SOLARIS, 1, Define if target OS is Solaris)
	LIBS="$LIBS -lresolv -lnls"
    ;;
 gnu*|*linux* )
    	AC_DEFINE(OS_LINUX, 1, Define if target OS is Linux)
	CFLAGS="$CFLAGS -Wall -W"
    ;;
esac

AC_C_BIGENDIAN

AC_ARG_ENABLE(regdomain, [ --disable-regdomain     disable regulation domain channel restrictions],
  [ case "$enableval" in
no)
     AC_DEFINE(NO_REG_DOMAIN, 1, Define for no regulation domain restrictions)
 ;;
 esac     
])

AC_SUBST(CURSESLIBS)

AC_OUTPUT([Makefile src/Makefile ap-gl/Makefile lib/Makefile po/Makefile.in intl/Makefile Documentation/Makefile])

echo "

	Thank you for using ap-utils.

"
