#===========================================================================
#
#   configure.in 
#
#===========================================================================
# $Id: configure.in,v 1.32 2006/06/01 09:50:12 chris Exp $

#---------------------------------------------------------------------------
#   Init Auto Tools
#---------------------------------------------------------------------------

# autoconf

AC_PREREQ([2.69])
AC_INIT([graphlet], [5.0.1], [mooigraph@gmail.com], [graphlet-5.0.1.tar.gz], [https://sourceforge.net/projects/gml4gtk])
AC_CONFIG_SRCDIR([src/graphscript/graphscript.cpp])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_HEADERS([config.h])
AC_PROG_CC
AC_PROG_CXX([g++ clang++])
AC_LANG([C++])
AC_PROG_MAKE_SET
AC_PROG_RANLIB

CXX_FLAGS=${CXX_GLAGS:-""}


dnl get obscure info about the system
AC_CANONICAL_SYSTEM

dnl -----------------------------------------------
dnl Package name and version number (user defined)
dnl -----------------------------------------------

# release versioning
AC_DEFINE_UNQUOTED([GENERIC_MAJOR_VERSION],[5],[major])
AC_DEFINE_UNQUOTED([GENERIC_MINOR_VERSION],[0],[minor])
AC_DEFINE_UNQUOTED([GENERIC_MICRO_VERSION],[1],[micro])

AC_SUBST(GENERIC_MAJOR_VERSION)

dnl GT_ is used in the sources
AC_DEFINE_UNQUOTED([GT_MAJOR_VERSION],[5],[major])
AC_DEFINE_UNQUOTED([GT_MINOR_VERSION],[0],[minor])
AC_DEFINE_UNQUOTED([GT_MINI_VERSION],[1],[micro])

dnl --------------------------------
dnl Package name and version number
dnl --------------------------------


GENERIC_VERSION=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION.$GENERIC_MICRO_VERSION
GENERIC_RELEASE=$GENERIC_MAJOR_VERSION.$GENERIC_MINOR_VERSION
AC_SUBST(GENERIC_RELEASE)
AC_SUBST(GENERIC_VERSION)

VERSION=$GENERIC_VERSION

AM_INIT_AUTOMAKE([foreign])
AM_MAINTAINER_MODE

# libtool
AC_PROG_LIBTOOL

LIBTOOL="$LIBTOOL --silent"

CONFIG_DATE=`date +"%a %d %b %Y"`

AC_SUBST(CONFIG_DATE)

AC_DEFINE_UNQUOTED(COMPILE_DATE, ["$CONFIG_DATE"], [Year, month and day this program is compiled.])

# short system name in config.h
CONFIG_UNAME=`uname -s`

AC_SUBST(CONFIG_UNAME)

AC_DEFINE_UNQUOTED(COMPILE_UNAME, ["$CONFIG_UNAME"], [System where this is compiled.])

dnl check if tcl dev package is installed
AC_CHECK_LIB([tcl], [Tcl_Free],[have_tcl=yes],[have_tcl=no])

if test x"${have_tcl}" != xyes; then
   AC_MSG_FAILURE([configure-error: Install Tcl development libraries with include files for libtcl],[1])
fi

dnl check if tk dev package is installed
AC_CHECK_LIB([tk], [Tk_FreeFont],[have_tk=yes],[have_tk=no])

if test x"${have_tk}" != xyes; then
   AC_MSG_FAILURE([configure-error: Install Tk development libraries with include files for libtk],[1])
fi

TCLTK_CFLAGS="-I /usr/include/tk"

GTL_CFLAGS="-I.."

CXX_FLAGS="$CXX_FLAGS $GTL_CFLAGS"

CXX_FLAGS="$CXX_FLAGS $TCLTK_CFLAGS"

CFLAGS="$CFLAGS $CXX_FLAGS"

AC_CONFIG_FILES([Makefile \
	src/Makefile \
	src/graphscript/Makefile \
	src/gt_base/Makefile \
	src/gt_cfr_layout/Makefile \
	src/gt_icse_layout/Makefile \
	src/gt_lsd_gem/Makefile \
	src/gt_lsd_springembedder_kamada/Makefile \
	src/gt_lsd_springembedder_rf/Makefile \
	src/gt_lsd_sugiyama/Makefile \
	src/gt_lsd_tree_layout_walker/Makefile \
	src/gt_lsd_tunkelang/Makefile \
	src/gt_radial_tree_layout/Makefile \
	src/gt_tcl/Makefile \
	src/gt_tree_layout/Makefile \
	src/gt_xdag/Makefile])

AC_OUTPUT

echo "                     "
echo "                     "
echo "                     "
echo "   ,           ,     "
echo "  /             \    "
echo " ((__-^^-,-^^-__))   "
echo " '-__- -   '--__-    "
echo "    -O       O-      "
echo "      \     /        "
echo "       ): :(         "
echo "       :o_o:         "
echo "         -           "
echo "                     "
echo "                     "
echo "                     "

echo This system is `uname -a`;

cat <<EOF

$PACKAGE_STRING is configured to be compiled.

EOF

AC_MSG_NOTICE([

Configuration:
  Source code location	${srcdir}
  Build code location	${builddir}
  Destination prefix	${prefix}
  C++ Compiler		${CXX}
  C++ Flags		${CXX_FLAGS}
  CC For Build		${CC_FOR_BUILD}
  Cross-Compiling	${cross_compiling}
  Build			${build}
  Host			${host}
  Target		${target}
  Tk Libraries		${have_tk}
  Tcl Libraries		${have_tcl}
])

#---------------------------------------------------------------------------
#   end of file
#---------------------------------------------------------------------------
