##
##  OSSP asgui - Accounting system graphical user interface
##  Copyright (c) 2002-2008 The OSSP Project (http://www.ossp.org/)
##  Copyright (c) 2002-2008 Ralf S. Engelschall <rse@engelschall.com>
##  Copyright (c) 2002-2008 Michael Schloh von Bennewitz <michael@schloh.com>
##  Copyright (c) 2002-2008 Cable & Wireless Telecommunications Services GmbH
##
##  This file is part of OSSP asgui, an accounting system graphical user
##  interface which can be found at http://asgui.europalab.com/.
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##
##  configure.in: Autoconf configure template
##

dnl Version requirement and information
AC_PREREQ(2.53)
AC_REVISION(1.0)
AC_INIT

ASGUI_VERSION_STR=`./shtool version -l c -d long as_version.cpp`
./shtool echo -e "Configuring %BOSSP as-gui%b, version %B${ASGUI_VERSION_STR}%b"
AC_SUBST(ASGUI_VERSION_STR)

dnl Process this file with autoconf
AC_CONFIG_HEADERS(ac_config.h)
AC_LANG_CPLUSPLUS

dnl Checks basic requirements
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL

AC_PROG_CC
AC_PROG_CPP
AC_PROG_CC_STDC

dnl Checks header requirements
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(sys/sockio.h net/if.h netinet/in.h)

dnl Portable thread conf from acx_pthread.m4 autoconf macro
ACX_PTHREAD
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
LIBS="`echo $PTHREAD_CFLAGS | sed -e 's;.*\(-[[pmk]]thread[[s]]*\).*;\1;'` $LIBS"

dnl Do Qt checks
PKG_CHECK_MODULES(QT, Qt3Support, have_qt=true, AC_MSG_ERROR([No qt installation found]))
    AC_SUBST(QT_LIBS)
    AC_SUBST(QT_CFLAGS)

dnl Find Qt locations
AC_CHECK_QT
AC_SUBST(QTBASE)
AC_CHECK_UIC
AC_SUBST(UIC)
AC_CHECK_MOC
AC_SUBST(MOC)

dnl Check generic libraries
AC_CHECK_LIB(dl, dlopen, [LIBS="$LIBS -ldl"])
AC_CHECK_LIB(rt, sched_get_priority_min, [LIBS="$LIBS -lrt"])

dnl Check other requirements
AC_PROG_MAKE_SET
AC_CHECK_DEBUGGING

dnl Check low level network device necessities
# AC_CHECK_SIOCGIFHWADDR
# AC_CHECK_SIOGHWADDR
# AC_CHECK_SIOCGIFCONF
# AC_CHECK_SIOCGENADDR
# AC_STRUCT_SA_LEN

dnl Check for Dmalloc library
AC_CHECK_EXTLIB([Dmalloc],
                dmalloc, dmalloc_debug, dmalloc.h,
                [AC_DEFINE(WITH_DMALLOC, 1, [Define to 1 if building with Dmalloc])])

dnl Test for the local CORBA implementation
AC_TEST_MICO
AC_SUBST(CORBABASE)

dnl Test for the local SOAP implementation
AC_TEST_ESOAP
AC_SUBST(SOAPBASE)

dnl Check data type sizes of particular architecture
dnl Hack: We're really interested in the unsigned types,
dnl       but they're the same size according to ISO C++
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)

enable_shared=no
export enable_shared
enable_headline=no
export enable_headline

dnl Make all the necessary Makefiles
AC_OUTPUT(Makefile)
