dnl Process this file with autoconf to produce a configure script.
AC_INIT(osb-jscore, 0.5.1)
AC_CONFIG_SRCDIR(kjs/internal.cpp)
AM_INIT_AUTOMAKE

AM_CONFIG_HEADER(config.h)
AC_PROG_LIBTOOL
AC_PROG_CC
AM_PROG_CC_STDC
AC_PROG_CXX
AC_PROG_YACC


dnl Check functions and headers
AC_HEADER_STDC
AC_CHECK_FUNCS(memcpy memmove)
AC_HEADER_TIME
AC_CHECK_HEADERS(string.h strings.h float.h)

AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test $PKG_CONFIG = no; then
   AC_MSG_ERROR([Cannot find pkg-config, make sure it is installed and in your PATH])
fi

PKG_CHECK_MODULES(PACKAGE, [glib-2.0 >= 2.2.0])

AC_CHECK_FUNCS(isnan,[
	AC_DEFINE(HAVE_FUNC_ISNAN,[],[Define to 1 if you have isnan function.])
	],)
AC_CHECK_FUNCS(isinf,[
        AC_DEFINE(HAVE_FUNC_ISINF,[],[Define to 1 if you have isinf function.])
	],)

AC_CHECK_FUNCS(infinite,[
	AC_DEFINE(HAVE_FUNC_INFINITE,[],[Define to 1 if you have isinfinite function.])
	],)

AC_CHECK_LIB(pthread, main)

CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -DKWIQ -DAPPLE_CHANGES -DHAVE_PCREPOSIX"

dnl debugging info commandline argument
use_debug=
AC_ARG_ENABLE([debug], 
  AC_HELP_STRING([--enable-debug], [enable debug mode (default:disabled)]),
  use_debug=true,,)

if test -n "$use_debug"; then 
   CPPFLAGS="$CPPFLAGS -DDEBUG" 
else
   CPPFLAGS="$CPPFLAGS -DNDEBUG"
fi  


dnl Use -Wall if we have gcc.
changequote(,)dnl
if test "x$GCC" = "xyes"; then
  case " $CFLAGS " in
  *[\ \	]-Wall[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac
fi
changequote([,])dnl

CXXFLAGS="$CXXFLAGS -fno-exceptions -fno-rtti -nostdinc++"
LDFLAGS="$LDFLAGS $PACKAGE_LIBS" #-nodefaultlibs -lgcc -lc -lm"

CPPFLAGS="$CPPFLAGS $PACKAGE_CFLAGS -I\$(top_srcdir)/kjs -I\$(top_srcdir)/pcre -I\$(top_srcdir)/" 


AC_OUTPUT([
Makefile
osb-jscore.pc
kjs/Makefile
pcre/Makefile
])

