dnl
dnl Process this file with autoconf to produce a configure script.
dnl
dnl $Id: configure.in,v 1.33 2008/02/08 15:10:17 adeniz Exp $
dnl
dnl autoconf input for the MicroNeil SNFServer distribution.
dnl
dnl Author: Alban Deniz
dnl
dnl Copyright (C) 2008 by MicroNeil Corporation. All rights reserved.
dnl See www.armresearch.com for the copyright terms.
dnl
dnl
AC_PREREQ(2.52)

AC_INIT(snf-server, 3.0.14)
AC_CONFIG_SRCDIR(SNFMulti/snfCFGmgr.cpp)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)

AM_CONFIG_HEADER(config.h)

AC_LANG(C++)

AC_PROG_LIBTOOL
AC_PROG_CXX
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET

dnl
dnl Check for programs.
dnl
AC_CHECK_PROG(haveCURL, curl, true, false)
if [[ $haveCURL == "false" ]]
then
        AC_MSG_ERROR([The CURL program was not found]);
fi

dnl
dnl Load the user-specified OS.
dnl
AC_ARG_ENABLE(os-type,
        [AS_HELP_STRING([--enable-os-type=TYPE],
        [where TYPE is OpenBSD, FreeBSD, RedHat, Suse, Ubuntu, or ArchLinux])],
        [SNF_OSTYPE="${enableval}" ])
case "$SNF_OSTYPE" in
OpenBSD|OpenBSD|FreeBSD|RedHat|Suse|Ubuntu|ArchLinux)
        :
	;;
*)
	AC_MSG_ERROR([Invalid OS type: "$SNF_OSTYPE".
You must specify a valid OS type with --enable-os-type=TYPE, where TYPE is one of:
  OpenBSD
  FreeBSD
  Suse
  RedHat
  Ubuntu
  ArchLinux])
	;;
esac
AM_CONDITIONAL([OpenBSD], [test x$SNF_OSTYPE = xOpenBSD])
AM_CONDITIONAL([FreeBSD], [test x$SNF_OSTYPE = xFreeBSD])
AM_CONDITIONAL([Suse], [test x$SNF_OSTYPE = xSuse])
AM_CONDITIONAL([RedHat], [test x$SNF_OSTYPE = xRedHat])
AM_CONDITIONAL([Ubuntu], [test x$SNF_OSTYPE = xUbuntu])
AM_CONDITIONAL([ArchLinux], [test x$SNF_OSTYPE = xArchLinux])

dnl
dnl Load whether this is for a package.
dnl
AC_ARG_ENABLE(for-package,
        [AS_HELP_STRING([--enable-for-package],
        [enable if building for a package])],
        [FOR_PACKAGE="${enableval}" ])
AM_CONDITIONAL([ForPackage], [test x$FOR_PACKAGE = xyes])

dnl
dnl Check libraries.
dnl

dnl
dnl pthread library.
dnl
AC_CHECK_LIB(pthread, pthread_create,,
	     AC_MSG_ERROR([libpthread is required to build AC_PACKAGE_NAME]))

dnl
dnl Additional compile-time and link-time flags.
dnl
OTHER_CXXFLAGS='-O3'
SNF_CXXFLAGS='$(OTHER_CXXFLAGS) -pthread'
SNF_LIBS=''

AC_SUBST(OTHER_CXXFLAGS)
AC_SUBST(SNF_CXXFLAGS)
AC_SUBST(SNF_LIBS)

dnl
dnl Output the makefiles.
dnl

AC_OUTPUT([Makefile
        CodeDweller/Makefile
        SNFMulti/Makefile
	SNFServer/Makefile
 	SNFClient/Makefile
        SNF2Check/Makefile
        Scripts/Makefile
        config_files/Makefile
        Docs/Makefile])

echo "
Type "make" to build the system using the default (optimized) parameters.

Type "make SNF_CXXFLAGS='-g -pthread'" to build the system for debugging.

Type "make OTHER_CXXFLAGS=flags" to build the system with compiler
flags 'flags'.

For example:

    Type "make OTHER_CXXFLAGS=-g" to build the system for debugging.

    Type "make OTHER_CXXFLAGS=-Wall" to enable all warnings.

    Type "make OTHER_CXXFLAGS=-Wall -O3" to enable warnings and O3
    optimizations.

Default value:  $OTHER_CXXFLAGS

OS type:  $SNF_OSTYPE

The software will be installed in $prefix.

Done
"
