dnl===========================================================================
dnl Copyright (c) 1998-2000 K.U.Leuven
dnl 
dnl This software is provided AS IS, without any express or implied
dnl warranty.  In no event will the authors or the K.U.Leuven be held
dnl liable for any damages or loss of profit arising from the use or
dnl non-fitness for a particular purpose of this software.
dnl 
dnl See file README in the home directory for details about
dnl copyrights and licensing.
dnl===========================================================================
dnl NAME:       configure
dnl TYPE:       m4 macro file
dnl PROJECT:    libvrml - An extensible VRML'97 parser
dnl CONTENT:    Input file for GNU autoconf
dnl===========================================================================
dnl AUTHORS:    jp      Jan Prikryl
dnl===========================================================================
dnl HISTORY:
dnl
dnl 31-Jan-00 20:21:36  jp      last modification
dnl 31-Jan-00 19:42:58  jp      optional compilation of NODEGEN
dnl 31-Jan-00 19:31:09  jp      C++ included for makedepend on SGI
dnl 28-Jan-00 17:51:39  jp      no autodeps changes, cleaned
dnl 05-Sep-99 13:40:03  jp      created
dnl===========================================================================
dnl
dnl Process this file with autoconf to produce the `configure' script.
dnl

dnl Starter
AC_INIT(BUGS)
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE(phbrml, 0.2.1a)
AM_CONFIG_HEADER(config.h)

dnl Checks for programs.
AC_PROG_CC
AM_PROG_CC_STDC
AC_PROG_CXX
AC_PROG_MAKE_SET
AM_PROG_LEX
AC_PROG_RANLIB

dnl yacc has to generate header file as well
AC_PROG_YACC
YACC="$YACC -d"

dnl Looks for `makedepend'
AC_CHECK_PROGS(MAKEDEPEND, makedepend)
if test x$MAKEDEPEND = x ; then
  AC_MSG_WARN(
        [Makedepend not found. You will not be able to
         update source file dependencies.])
fi

dnl "makedepend" searches only C include directories
dnl and fails in finding `iostream.'" and `strstream.h'.
dnl On IRIX with MIPSPro compilers, additional include files
dnl reside in `/usr/include/CC'
case "${host_os}" in
  irix*) MKDEP_XTRAINC="-I/usr/include/CC"
         AC_SUBST(MKDEP_XTRAINC)
         ;;
esac
dnl GNU c++ seems to need the following (overrides the IRIX
dnl settings, but they are MIPSPro-related anyway).
if test "x${CC}" = "xgcc" ; then
  MKDEP_XTRAINC="-I/usr/include/g++-2"
  AC_SUBST(MKDEP_XTRAINC)
fi

dnl Checks for GNU make
CHECK_GNU_MAKE
if test x$_cv_gnu_make_command = x ; then
  AC_MSG_ERROR([Sorry, RenderPark requires GNU make for buliding the binary])
fi

dnl Turn off shared libraries
AC_DISABLE_SHARED

dnl Integrate `libtool' support
AM_PROG_LIBTOOL

dnl Checks for libraries.
AC_CHECK_LIB(m, sin)
AC_PATH_XTRA
if test x$have_x = xno ; then
  AC_MSG_ERROR([X Window System libraries or header files are missing])
fi
AC_FIND_MOTIF
if test x$with_motif = xno ; then
  AC_MSG_ERROR([Motif libraries or header files are missing])
fi

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/time.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_HEADER_TIME

dnl Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(gettimeofday strdup)

dnl OpenGL
AC_FIND_OPENGL

dnl Conditional compilation of NODEGEN directory
AC_ARG_ENABLE(nodegen,
  [  --enable-nodegen        compile code from NODEGEN direcotry],
  [case "${enableval}" in
    yes) nodegen=true  ;;
    no)  nodegen=false ;;
    *)   AC_MSG_ERROR(bad value ${enableval} for --enable-nodegen) ;;
  esac],
  [nodegen=false])
AM_CONDITIONAL(AM_NODEGEN, test x$nodegen = xtrue)

dnl And create Makefiles
AC_OUTPUT(DOC/Makefile
          DOC/PhBRML/Makefile
          NODEGEN/Makefile
          POOLS/Makefile
          PROGS/Makefile
          PROGS/vrmldump/Makefile
          PROGS/vrmlint/Makefile
          PROGS/vrmlview/Makefile
          PROGS/vrml2mgf/Makefile
          TEST/Makefile
          VRML/Makefile
          VRML/NODES/Makefile
          VRML/PhBRML/Makefile
          Makefile)

dnl===========================================================================
dnl End of configure.in
dnl===========================================================================
