dnl -*- mode: shell-script -*-
dnl Process this file with autoconf to produce a configure script.

AC_INIT(IDL.h.new.in)

AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
#
# Making releases:
#   LIBIDL_MICRO_VERSION += 1;
#   LIBIDL_INTERFACE_AGE += 1;
#   LIBIDL_BINARY_AGE += 1;
# if any functions have been added, set LIBIDL_INTERFACE_AGE to 0.
# if backwards compatibility has been broken,
# set LIBIDL_BINARY_AGE and LIBIDL_INTERFACE_AGE to 0.
#
LIBIDL_MAJOR_VERSION=0
LIBIDL_MINOR_VERSION=6
LIBIDL_MICRO_VERSION=0
LIBIDL_INTERFACE_AGE=0
LIBIDL_BINARY_AGE=0
LIBIDL_LIBRARY_VERSION=$LIBIDL_MAJOR_VERSION.$LIBIDL_MINOR_VERSION.$LIBIDL_MICRO_VERSION
GLIB_VERSION_REQUIRED=1.1.4
AC_DIVERT_POP()dnl

AC_SUBST(LIBIDL_MAJOR_VERSION)
AC_SUBST(LIBIDL_MINOR_VERSION)
AC_SUBST(LIBIDL_MICRO_VERSION)
AC_SUBST(LIBIDL_LIBRARY_VERSION)

LT_RELEASE=$LIBIDL_MAJOR_VERSION.$LIBIDL_MINOR_VERSION
LT_CURRENT=`expr $LIBIDL_MICRO_VERSION - $LIBIDL_INTERFACE_AGE`
LT_REVISION=$LIBIDL_INTERFACE_AGE
LT_AGE=`expr $LIBIDL_BINARY_AGE - $LIBIDL_INTERFACE_AGE`
AC_SUBST(LT_RELEASE)
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

VERSION=$LIBIDL_LIBRARY_VERSION
PACKAGE=libIDL

AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)

AC_DEFINE_UNQUOTED(LIBIDL_INTERFACE_AGE, $LIBIDL_INTERFACE_AGE)
AC_DEFINE_UNQUOTED(LIBIDL_BINARY_AGE, $LIBIDL_BINARY_AGE)
AC_DEFINE_UNQUOTED(LIBIDL_LIBRARY_VERSION, "$LIBIDL_LIBRARY_VERSION")

LIBIDL_INCLUDEDIR='@GLIB_CFLAGS@ -I${includedir}'
LIBIDL_LIBDIR='-L${libdir}'
LIBIDL_LIBS="-lIDL @GLIB_LIBS@"
AC_SUBST(LIBIDL_LIBDIR)
AC_SUBST(LIBIDL_LIBS)
AC_SUBST(LIBIDL_INCLUDEDIR)

ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"

AC_ISC_POSIX

dnl Checks for programs.
AC_PROG_CC
AC_PROG_CPP
AC_CPP_ACCEPT_IDL
if [[ "$ac_cv_cpp_accept_idl" = "no" ]]; then
    AC_MSG_WARN(CPP does not accept IDL)
fi
AC_CPP_PIPE_STDIN
CPP_PROGRAM="$CPP"
AC_DEFINE_UNQUOTED(CPP_PROGRAM, "$CPP")

AM_PROG_LEX
if [[ "$LEX" = "flex" ]]; then
    LFLAGS="-8"
else
    LFLAGS=""
fi
AC_SUBST(LFLAGS)
AC_PROG_YACC
AM_PROG_LIBTOOL
AM_MAINTAINER_MODE

dnl Checks for libraries.
AC_CHECK_PROG(HAVE_GLIB_CONFIG, glib-config, yes, no)

AC_SUBST(GLIB_VERSION_REQUIRED)
AM_PATH_GLIB($GLIB_VERSION_REQUIRED)

AC_STDC_HEADERS
AC_CHECK_HEADERS(stddef.h wchar.h wcstr.h)

AC_OUTPUT([
Makefile
Makefile.msc
libIDL-config
libIDL.m4
libIDL.spec
IDL.h.new
],[
AC_UPDATE_IF_CHANGED(IDL.h, IDL.h.new)
])

echo
echo libIDL configuration complete
echo
echo "  C Preprocessor: \"$CPP_PROGRAM\""
if [[ "$ac_cv_cpp_pipe_stdin" = "yes" ]]; then
    echo "  Standard input supported."
else
    echo "  Using symlink method."
fi
echo
