dnl Copyright (C) 2005-2006 EDF
dnl
dnl This file is part of the FVM software package.  For license
dnl information, see the COPYING file in the top level directory of the
dnl FVM source distribution.

# FVM_AC_TEST_CGNS
#-----------------
# modifies or sets have_cgns, CGNS_CPPFLAGS, CGNS_LDFLAGS, and CGNS_LIBS
# depending on libraries found

AC_DEFUN([FVM_AC_TEST_CGNS], [

AC_REQUIRE([FVM_AC_CONFIG_PUBL_INIT])dnl

have_cgns=no

AC_ARG_ENABLE(CGNS,
  [  --disable-cgns          Do not use CGNS when available],
  [
    case "${enableval}" in
      yes) cgns=true ;;
      no)  cgns=false ;;
      *)   AC_MSG_ERROR([bad value ${enableval} for --enable-cgns]) ;;
    esac
  ],
  [ cgns=true ]
)

AC_ARG_WITH(cgns-prefix,
  [  --with-cgns-prefix=DIR   CGNS format support],[
])
AC_ARG_WITH(cgns-exec-prefix,
  [  --with-cgns-exec-prefix=DIR   CGNS exec prefix]
)

if test "x$cgns" = "xtrue" ; then

  saved_CPPFLAGS="$CPPFLAGS"
  saved_LDFLAGS="$LDFLAGS"
  saved_LIBS="$LIBS"

  if test "x$with_cgns_prefix" != "x" ; then
    CGNS_CPPFLAGS="-I$with_cgns_prefix/include"
  fi
  if test "x$with_cgns_exec_prefix" != "x" ; then
    CGNS_LDFLAGS="-L$with_cgns_exec_prefix/lib"
  elif test "x$with_cgns_prefix" != "x" ; then
    CGNS_LDFLAGS="-L$with_cgns_prefix/lib"
  fi
  CGNS_LIBS="-lcgns"
  CPPFLAGS="${CPPFLAGS} ${CGNS_CPPFLAGS}"
  LDFLAGS="${LDFLAGS} ${CGNS_LDFLAGS}"
  LIBS="${LIBS} ${CGNS_LIBS}"

  AC_CHECK_LIB(cgns, cg_coord_partial_write, 
               [ AC_DEFINE([HAVE_CGNS], 1, [CGNS file support])
                 have_cgns=yes
               ], 
               [ AC_MSG_WARN([no CGNS file support (requires CGNS >= 2.4)])
               ],
               )

  if test "x$have_cgns" != "xyes"; then
    CGNS_CPPFLAGS=""
    CGNS_LDFLAGS=""
    CGNS_LIBS=""
  fi

fi

AM_CONDITIONAL(HAVE_CGNS, test x$have_cgns = xyes)

CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS"

unset saved_CPPFLAGS
unset saved_LDFLAGS
unset saved_LIBS

AC_SUBST(CGNS_CPPFLAGS)
AC_SUBST(CGNS_LDFLAGS)
AC_SUBST(CGNS_LIBS)

])dnl



syntax highlighted by Code2HTML, v. 0.9.1