###############################################################################
#   TinTin++                                                                  #
#   Copyright (C) 2006 (See CREDITS file)                                     #
#                                                                             #
#   This program is protected under the GNU GPL (See COPYING)                 #
#                                                                             #
#   This program is free software; you can redistribute it and/or modify      #
#   it under the terms of the GNU General Public License as published by      #
#   the Free Software Foundation; either version 2 of the License, or         #
#   (at your option) any later version.                                       #
#                                                                             #
#   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 #
###############################################################################

AM_INIT_AUTOMAKE

AC_INIT(tintin.h)
AC_CONFIG_HEADER(config.h)

AC_MSG_RESULT([Configuring TinTin++])


AC_SUBST(MYINCLUDE)
AC_SUBST(MYLIB)    
AC_SUBST(mybindir)
AC_SUBST(BIG5)

if [ test $bindir != "\${exec_prefix}/bin" ]
then
	mybindir="$bindir"
else
	mybindir="."
fi

if [ test $libdir != "\${exec_prefix}/lib" ]
then
	MYLIB="-L$libdir"
else
	MYLIB=""
fi

if [ test $includedir != "\${prefix}/include" ]
then
	MYINCLUDE="-I$includedir"
else
	MYINCLUDE=""
fi

AC_ARG_ENABLE(big5, [  --enable-big5           enable big5 support], BIG5="-DBIG5")


# Checks for programs.

AC_PROG_CC
AC_PROG_MAKE_SET


# Checks for header files.

AC_HEADER_STDC
AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h net/errno.h netdb.h netinet/in.h param.h pthread.h socks.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/ptem.h sys/socket.h sys/termio.h sys/time.h time.h unistd.h zlib.h util.h pty.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM


# Checks for library functions.

AC_FUNC_MEMCMP
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_STRFTIME
AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([gethostbyname gethostname gettimeofday inet_ntoa memset select socket strcasecmp strchr strdup strerror strftime strncasecmp strstr utime getaddrinfo forkpty popen])

# Checks libraries

AC_CHECK_LIB(z, inflate)
AC_CHECK_LIB(pthread, pthread_create)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(socket, rresvport)
AC_CHECK_LIB(util, forkpty)
AC_CHECK_LIB(pcre, pcre_compile)
AC_CHECK_PROGS(MAKE, gmake make)

AC_CHECK_FILES([/dev/ptmx])

AC_FUNC_GETMNTENT
AC_HEADER_DIRENT 

AC_OUTPUT(Makefile)

echo
echo "Configure has finished.  To compile, type: make"
echo