Skip to content
Snippets Groups Projects
Select Git revision
  • f923de31a7b7d1b93411c9f80e31bdac2133fdf5
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

configure.in

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    configure.in 29.51 KiB
    dnl $Id: configure.in,v 1.129 2007-08-02 22:28:05 geuzaine Exp $
    dnl
    dnl Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
    dnl
    dnl This program is free software; you can redistribute it and/or modify
    dnl it under the terms of the GNU General Public License as published by
    dnl the Free Software Foundation; either version 2 of the License, or
    dnl (at your option) any later version.
    dnl
    dnl This program is distributed in the hope that it will be useful,
    dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
    dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    dnl GNU General Public License for more details.
    dnl
    dnl You should have received a copy of the GNU General Public License
    dnl along with this program; if not, write to the Free Software
    dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
    dnl USA.
    dnl 
    dnl Please report all bugs and problems to <gmsh@geuz.org>.
    
    dnl Process this file with autoconf to produce the configure script.
    
    dnl Note: each CHECK_LIB adds the found library to LIBS, which serves
    dnl implicitly when checking for the next one. So one should check
    dnl in reverse order! (start with -lm, ...)
    
    dnl Check that this is the gmsh source tree
    AC_INIT(Parser/Gmsh.y)
    
    dnl Parse '--with' command-line options
    AC_ARG_WITH(fltk-prefix,
                AC_HELP_STRING([--with-fltk-prefix=PFX],
                               [prefix where FLTK is installed]),
                [FLTK_PREFIX=$withval])
    AC_ARG_WITH(gsl-prefix,
                AC_HELP_STRING([--with-gsl-prefix=PFX],
                               [prefix where GSL is installed]),
                [GSL_PREFIX=$withval])
    AC_ARG_WITH(jpeg-prefix,
                AC_HELP_STRING([--with-jpeg-prefix=PFX],
                               [prefix where the JPEG library and includes are installed]),
                [JPEG_PREFIX=$withval])
    AC_ARG_WITH(png-prefix,
                AC_HELP_STRING([--with-png-prefix=PFX],
                               [prefix where the PNG library and includes are installed]),
                [PNG_PREFIX=$withval])
    AC_ARG_WITH(zlib-prefix,
                AC_HELP_STRING([--with-zlib-prefix=PFX],
                               [prefix where the ZLIB library and includes are installed]),
                [ZLIB_PREFIX=$withval])
    AC_ARG_WITH(osmesa-prefix,
                AC_HELP_STRING([--with-osmesa-prefix=PFX],
                               [prefix where OSMesa is installed]),
                [OSMESA_PREFIX=$withval])
    AC_ARG_WITH(cgns-prefix,
                AC_HELP_STRING([--with-cgns-prefix=PFX],
                               [prefix where CGNS is installed]),
                [CGNS_PREFIX=$withval])
    AC_ARG_WITH(occ-prefix,
                AC_HELP_STRING([--with-occ-prefix=PFX],
                               [prefix where OpenCascade is installed]),
                [OCC_PREFIX=$withval])
    AC_ARG_WITH(hdf5-prefix,
                AC_HELP_STRING([--with-hdf5-prefix=PFX],
                               [prefix where OpenCascade is installed]),
                [HDF5_PREFIX=$withval])
    AC_ARG_WITH(med-prefix,
                AC_HELP_STRING([--with-med-prefix=PFX],
                               [prefix where OpenCascade is installed]),
                [MED_PREFIX=$withval])
    AC_ARG_WITH(fftw3-prefix,
                AC_HELP_STRING([--with-fftw3-prefix=PFX],
                               [prefix where FFTW3 is installed]),
                [FFTW3_PREFIX=$withval])
    
    dnl Parse '--enable' command line options
    AC_ARG_ENABLE(gsl,
                  AC_HELP_STRING([--enable-gsl],
                                 [use GSL as numerical toolkit (default=yes)]))
    AC_ARG_ENABLE(gui,
                  AC_HELP_STRING([--enable-gui],
                                 [build the graphical user interface (default=yes)]))
    AC_ARG_ENABLE(cygwin,
                  AC_HELP_STRING([--enable-cygwin],
                                 [use the Cygwin library on Windows (default=no)]))
    AC_ARG_ENABLE(parallel,
                  AC_HELP_STRING([--enable-parallel],
                                 [enable parallel version (default=no)]))
    AC_ARG_ENABLE(jpeg,
                  AC_HELP_STRING([--enable-jpeg],
                                 [enable JPEG support (default=yes)]))
    AC_ARG_ENABLE(zlib,
                  AC_HELP_STRING([--enable-zlib],
                                 [enable ZLIB support (default=yes)]))
    AC_ARG_ENABLE(png,
                  AC_HELP_STRING([--enable-png],
                                 [enable PNG support (default=yes)]))
    AC_ARG_ENABLE(contrib,
                  AC_HELP_STRING([--enable-contrib],
                                 [enable contrib packages (default=yes)]))
    AC_ARG_ENABLE(triangle,
                  AC_HELP_STRING([--enable-triangle],
                                 [compile Triangle if available (default=yes)]))
    AC_ARG_ENABLE(netgen,
                  AC_HELP_STRING([--enable-netgen],
                                 [compile Netgen if available (default=yes)]))
    AC_ARG_ENABLE(ann,
                  AC_HELP_STRING([--enable-ann],
                                 [compile ANN if available (default=yes)]))
    AC_ARG_ENABLE(metis,
                  AC_HELP_STRING([--enable-metis],
                                 [compile METIS if available (default=no)]))
    AC_ARG_ENABLE(tetgen,
                  AC_HELP_STRING([--enable-tetgen],
                                 [compile Tetgen if available (default=yes)]))
    AC_ARG_ENABLE(matheval,
                  AC_HELP_STRING([--enable-matheval],
                                 [compile MathEval if available (default=yes)]))
    AC_ARG_ENABLE(osmesa,
                  AC_HELP_STRING([--enable-osmesa],
                                 [use OSMesa for offscreen rendering (default=no)]))
    AC_ARG_ENABLE(cgns,
                  AC_HELP_STRING([--enable-cgns],
                                 [enable CGNS output (default=no)]))
    AC_ARG_ENABLE(occ,
                  AC_HELP_STRING([--enable-occ],
                                 [enable OpenCascade support (default=no)]))
    AC_ARG_ENABLE(med,
                  AC_HELP_STRING([--enable-med],
                                 [enable MED support (default=yes)]))
    AC_ARG_ENABLE(fm,
                  AC_HELP_STRING([--enable-fm],
                                 [enable support for Fourier models (default=yes)]))
    
    dnl Get the operating system name
    UNAME=`uname`
    
    dnl Check for default compilers
    AC_PROG_CC
    AC_PROG_CXX
    if test "x${CC}" = "x" -o "x${CXX}" = "x" ; then
      AC_MSG_ERROR([Could not find required compilers, aborting.])
    fi
    LINKER="${CXX}"
    POSTBUILD=""
    
    dnl Use c++ for all compilation tests
    AC_LANG(C++)
    
    dnl Take care of no-cygwin option before doing any other tests
    case "$UNAME" in
      CYGWIN*)
        if test "x$enable_cygwin" != "xyes"; then
          UNAME="${UNAME}-no-cygwin"
          CC="${CC} -mno-cygwin"
          CXX="${CXX} -mno-cygwin"
          dnl increase stack size to 16Mb to avoid stack overflows in
          dnl recursive tet classification for large 3D Delaunay grids
          LINKER="${LINKER} -mno-cygwin -Wl,--stack,16777216"
        fi
        ;;
    esac
    
    dnl Set default flags
    FLAGS=""
    OPTIM="${CXXFLAGS}"
    
    dnl Check for various programs
    AC_PROG_CPP
    
    dnl How to build static libraries?
    case "$UNAME" in
      Darwin*)
        RANLIB=true
        AR="libtool -o"
        ;;
      *)
        AC_PROG_RANLIB
        AC_PATH_PROG(AR, ar)
        if test "x${AR}" = "x:"; then
          AC_MSG_ERROR([Could not find the library archiver, aborting.])
        fi
        AR="${AR} ruvs"
        ;;
    esac
    
    dnl See if we need a .exe extension on executables
    AC_EXEEXT
    
    dnl Set default subdirectories and libraries
    GMSH_DIRS="Common DataStr Geo Mesh Post Numeric Parallel Parser Plugin"
    
    dnl Choose blackbox or GUI version
    if test "x$enable_gui" != "xno"; then
    
      GMSH_DIRS="${GMSH_DIRS} Graphics Fltk"
      GMSH_LIBS="-Llib -lGmshFltk -lGmshParser -lGmshGraphics -lGmshMesh -lGmshGeo"
      GMSH_LIBS="${GMSH_LIBS} -lGmshPlugin -lGmshPost -lGmshCommon -lGmshDataStr -lGmshNumeric"
      GMSH_LIBS="${GMSH_LIBS} -lGmshParallel"
      FLAGS="-DHAVE_FLTK ${FLAGS}"
    
      if test "x${FLTK_PREFIX}" != "x" ; then
        AC_PATH_PROG(FLTKCONFIG,fltk-config,"",[${FLTK_PREFIX}:${FLTK_PREFIX}/bin:$PATH])
        dnl Find the libs/includes even if fltk is _not_ properly installed (ugly hack!)
        GMSH_LIBS="${GMSH_LIBS} -L${FLTK_PREFIX}/lib"
        FLAGS="${FLAGS} -I${FLTK_PREFIX}"
      else
        AC_PATH_PROG(FLTKCONFIG,fltk-config)
      fi
      if test "x$FLTKCONFIG" = "x"; then
        AC_MSG_ERROR([Could not find fltk-config. Try --with-fltk-prefix?])
      fi
    
      dnl Check for offscreen rendering using OSMesa
      if test "x$enable_osmesa" = "xyes"; then
        if test "x${OSMESA_PREFIX}" != "x"; then
          LDFLAGS="-L${OSMESA_PREFIX} -L${OSMESA_PREFIX}/lib ${LDFLAGS}"
        fi
        AC_CHECK_LIB(OSMesa,main,OSMESA="yes",OSMESA="no")
      fi
    
      if test "x${OSMESA}" = "xyes"; then
        GMSH_LIBS="${GMSH_LIBS} `$FLTKCONFIG --use-images --ldflags` -lfltk_gl"
        FLAGS="${FLAGS} -DHAVE_OSMESA `$FLTKCONFIG --use-images --cxxflags`"
        if test "x${OSMESA_PREFIX}" = "x"; then
          GMSH_LIBS="${GMSH_LIBS} -lOSMesa -lGL -lGLU"
        else
          GMSH_LIBS="${GMSH_LIBS} -L${OSMESA_PREFIX} -L${OSMESA_PREFIX}/lib -lOSMesa -lGL -lGLU"
          FLAGS="${FLAGS} -I${OSMESA_PREFIX} -I${OSMESA_PREFIX}/include"
        fi
      else
        GMSH_LIBS="${GMSH_LIBS} `$FLTKCONFIG --use-gl --use-images --ldflags`"
        FLAGS="${FLAGS} `$FLTKCONFIG --use-gl --use-images --cxxflags`"
      fi
    
      FL_JPEG=""
      expr "x${GMSH_LIBS}" : 'x.*fltk_jpeg.*' >/dev/null && FL_JPEG="yes"
      FL_PNG=""
      expr "x${GMSH_LIBS}" : 'x.*fltk_png.*' >/dev/null && FL_PNG="yes"
      FL_ZLIB=""
      expr "x${GMSH_LIBS}" : 'x.*fltk_z.*' >/dev/null && FL_ZLIB="yes"
    
      dnl Check for libjpeg
      if test "x$enable_jpeg" != "xno"; then
        dnl If provided by FLTK, use that one; otherwise, look for it
        if test "x${FL_JPEG}" = "xyes"; then
          FLAGS="-DHAVE_LIBJPEG ${FLAGS}"
        else      
          if test "x${JPEG_PREFIX}" != "x"; then
            LDFLAGS="-L${JPEG_PREFIX} -L${JPEG_PREFIX}/lib ${LDFLAGS}"
          fi
          AC_CHECK_LIB(jpeg,main,JPEG="yes",JPEG="no")
          if test "x${JPEG}" = "xyes"; then
            FLAGS="-DHAVE_LIBJPEG ${FLAGS}"
            if test "x${JPEG_PREFIX}" = "x"; then
              GMSH_LIBS="${GMSH_LIBS} -ljpeg"
            else
              dnl Find the libs/includes even if libjpeg is _not_ properly installed (ugly hack!)
              GMSH_LIBS="${GMSH_LIBS} -L${JPEG_PREFIX} -L${JPEG_PREFIX}/lib -ljpeg"
              FLAGS="${FLAGS} -I${JPEG_PREFIX} -I${JPEG_PREFIX}/include"
            fi
          fi 
        fi
      fi
    
      dnl Check for libz
      ZLIB=""
      if test "x$enable_zlib" != "xno"; then
        dnl If provided by FLTK, use that one; otherwise, look for it
        if test "x${FL_ZLIB}" = "xyes"; then
          ZLIB="yes"
        else      
          if test "x${ZLIB_PREFIX}" != "x"; then
            LDFLAGS="-L${ZLIB_PREFIX} -L${ZLIB_PREFIX}/lib ${LDFLAGS}"
          fi
          AC_CHECK_LIB(z,main,ZLIB="yes",ZLIB="no")
        fi
      fi
    
      dnl Check for libpng (only if libz is available)
      if test "x$enable_png" != "xno" -a "x${ZLIB}" = "xyes"; then
        dnl If provided by FLTK, use that one; otherwise, look for it
        if test "x${FL_PNG}" = "xyes"; then
          FLAGS="-DHAVE_LIBPNG ${FLAGS}"
        else
          if test "x${PNG_PREFIX}" != "x"; then
            LDFLAGS="-L${PNG_PREFIX} -L${PNG_PREFIX}/lib ${LDFLAGS}"
          fi
          AC_CHECK_LIB(png,main,PNG="yes",PNG="no")
          if test "x${PNG}" = "xyes"; then
            FLAGS="-DHAVE_LIBPNG ${FLAGS}"
            if test "x${PNG_PREFIX}" = "x"; then
              GMSH_LIBS="${GMSH_LIBS} -lpng"
            else
              dnl Find the libs/includes even if libpng is _not_ properly installed (ugly hack!)
              GMSH_LIBS="${GMSH_LIBS} -L${PNG_PREFIX} -L${PNG_PREFIX}/lib -lpng"
              FLAGS="${FLAGS} -I${PNG_PREFIX} -I${PNG_PREFIX}/include"
            fi
          fi
        fi 
      fi
    
    else
    
      GMSH_DIRS="${GMSH_DIRS} Box"
      GMSH_LIBS="-Llib Box/Main.o -lGmshBox -lGmshParser -lGmshMesh -lGmshGeo"
      GMSH_LIBS="${GMSH_LIBS} -lGmshPlugin -lGmshPost -lGmshCommon -lGmshDataStr"
      GMSH_LIBS="${GMSH_LIBS} -lGmshNumeric -lGmshParallel"
    
      dnl Check for libz
      ZLIB=""
      if test "x$enable_zlib" != "xno"; then
        if test "x${ZLIB_PREFIX}" != "x"; then
          LDFLAGS="-L${ZLIB_PREFIX} -L${ZLIB_PREFIX}/lib ${LDFLAGS}"
        fi
        AC_CHECK_LIB(z,main,ZLIB="yes",ZLIB="no")
      fi
    
    fi
    
    dnl Check for standard math library
    AC_CHECK_LIB(m,main)
    
    dnl Check for various functions
    AC_CHECK_FUNC(vsnprintf,,FLAGS="-DHAVE_NO_VSNPRINTF ${FLAGS}")
    AC_CHECK_FUNC(snprintf,,FLAGS="-DHAVE_NO_SNPRINTF ${FLAGS}")
    
    dnl Check if Unix98 socklen_t type is available
    AC_TRY_COMPILE(
     [#include <sys/types.h>
      #include <sys/socket.h>],
     [socklen_t len = 42; return 0;],,FLAGS="-DHAVE_NO_SOCKLEN_T ${FLAGS}")
    
    dnl Check if we should consider the packages in contrib
    if test "x$enable_contrib" != "xno"; then
    
      dnl Check for Triangle
      AC_CHECK_FILE(./contrib/Triangle/triangle.c, TRIANGLE="yes", TRIANGLE="no")
      if test "x${TRIANGLE}" = "xyes"; then
        if test "x$enable_triangle" != "xno"; then
           GMSH_DIRS="${GMSH_DIRS} contrib/Triangle"
           GMSH_LIBS="${GMSH_LIBS} -lGmshTriangle"
           FLAGS="-DHAVE_TRIANGLE ${FLAGS}"
           echo "********************************************************************"
           echo "You are building a version of Gmsh that contains Jonathan"
           echo "Shewchuk's Triangle as an alternative isotropic 2D mesh generator."
           echo "Please note that by doing so, you agree with Triangle's licensing"
           echo "requirements stated in ./contrib/Triangle/README. (Most notably, you"
           echo "may then only redistribute Gmsh for non-commercial purposes.)"
           echo "To disable Triangle, run configure again with the --disable-triangle"
           echo "option."
           echo "********************************************************************"
        fi
      else
        if test "x$enable_triangle" != "xno"; then
           echo "********************************************************************"
           echo "If you want to use Jonathan Shewchuk's Triangle as an alternative"
           echo "isotropic 2D mesh generator, please download Triangle from the"
           echo "author's web site at http://www.cs.cmu.edu/~quake/triangle.html,"
           echo "unpack the archive and copy the two files 'triangle.c' and"
           echo "'triangle.h' in the ./contrib/Triangle subdirectory. Then run"
           echo "./configure again."
           echo "Please note that by doing so, you agree with Triangle's licensing"
           echo "requirements stated in ./contrib/Triangle/README. (Most notably, you"
           echo "may then only redistribute Gmsh if no compensation is received.)"
           echo "********************************************************************"
        fi
      fi
    
      dnl Check for ANN
      AC_CHECK_FILE(./contrib/ANN/include/ANN/ANN.h, ANN="yes", ANN="no")
      if test "x${ANN}" != "xno"; then
        if test "x$enable_ann" != "xno"; then
           GMSH_DIRS="${GMSH_DIRS} contrib/ANN"
           GMSH_LIBS="${GMSH_LIBS} -lGmshANN"
           FLAGS="-DHAVE_ANN_ ${FLAGS}"
           echo "********************************************************************"
           echo "You are building a version of Gmsh that contains ANN, the"
           echo "Approximate Nearest Neighbor library."
           echo "Please note that by doing so, you agree with ANN's licensing"
           echo "requirements stated in ./contrib/ANN/Copyright.txt."
           echo "To disable ANN, run configure again with the --disable-ann"
           echo "option."
           echo "********************************************************************"
        fi
      else
        if test "x$enable_ann" != "xno"; then
           echo "********************************************************************"
           echo "If you want to use ANN for doing fast geometrical searchs in the"
           echo "STL mesher, please download ANN from the author's web site at"
           echo "http://www.cs.umd.edu/~mount/ANN/, unpack the archive and copy both"
           echo "src and include directories in the /contrib/ANN subdirectory. Then"
           echo "run ./configure again."
           echo "********************************************************************"
        fi
      fi
    
      dnl Check for METIS
      AC_CHECK_FILE(./contrib/Metis/metis.h, METIS="yes", METIS="no")
      if test "x${METIS}" = "xyes"; then
        if test "x$enable_metis" = "xyes"; then
           GMSH_DIRS="${GMSH_DIRS} contrib/Metis"
           GMSH_LIBS="${GMSH_LIBS} -lGmshMetis"
           FLAGS="-DHAVE_METIS ${FLAGS}"
           echo "********************************************************************"
           echo "You are building a version of Gmsh that contains METIS, the"
           echo "Serial Graph Partitioner."
           echo "Please note that by doing so, you agree with METIS's licensing"
           echo "requirements stated in ./contrib/Metis/README."
           echo "To disable METIS, run configure again with the --disable-metis"
           echo "option."
           echo "********************************************************************"
        fi
      else
        if test "x$enable-metis" = "xyes"; then
           echo "********************************************************************"
           echo "If you want to use METIS for doing mesh partitioning, please"
           echo "download METIS from the author's web site at"
           echo "http://www-users.cs.umn.edu/~karypis/metis/, unpack the archive and"
           echo "copy the Lib Directory in the ./contrib/Metis subdirectory. Then"
           echo "run ./configure again."
           echo "********************************************************************"
        fi
      fi
    
      dnl Check for Netgen
      AC_CHECK_FILE(./contrib/Netgen/libsrc/meshing/meshclass.cpp, NETGEN="yes", NETGEN="no")
      if test "x${NETGEN}" = "xyes"; then
        if test "x$enable_netgen" != "xno"; then
           GMSH_DIRS="${GMSH_DIRS} contrib/Netgen"
           GMSH_LIBS="${GMSH_LIBS} -lGmshNetgen"
           FLAGS="-DHAVE_NETGEN ${FLAGS}"
           echo "********************************************************************"
           echo "You are building a version of Gmsh that contains Joachim Schoberl's"
           echo "Netgen as an alternative 3D mesh generator. Netgen is distributed"
           echo "under the GNU LGPL: see ./contrib/Netgen/COPYING.LIB for more info."
           echo "To disable Netgen, run configure again with the --disable-netgen"
           echo "option."
           echo "********************************************************************"
        fi
      else
        if test "x$enable_netgen" != "xno"; then
           echo "********************************************************************"
           echo "If you want to use Joachim Schoberl's Netgen as an alternative"
           echo "3D mesh generator, please download Netgen from the project's"
           echo "web site at http://www.hpfem.jku.at/netgen/, unpack the archive"
           echo "and move the libsrc subdirectory in the ./contrib/Netgen"
           echo "subdirectory. Then run ./configure again."
           echo "Please note that by doing so, you agree with Netgen's licensing"
           echo "requirements stated in ./contrib/Netgen/COPYING.LIB."
           echo "********************************************************************"
        fi
      fi
    
      dnl Check for Tetgen
      AC_CHECK_FILE(./contrib/Tetgen/tetgen.h, TETGEN="yes", TETGEN="no")
      if test "x${TETGEN}" = "xyes"; then
        if test "x$enable_tetgen" != "xno"; then
           GMSH_DIRS="${GMSH_DIRS} contrib/Tetgen"
           GMSH_LIBS="${GMSH_LIBS} -lGmshTetgen"
           FLAGS="-DHAVE_TETGEN ${FLAGS}"
           echo "********************************************************************"
           echo "You are building a version of Gmsh that contains Hang Si's"
           echo "Tetgen as an alternative 3D mesh generator."
           echo "Please note that by doing so, you agree with Tetgen's licensing"
           echo "requirements stated in ./contrib/Tetgen/LICENSE. (Most notably, you"
           echo "may then only redistribute Gmsh for non-commercial purposes.)"
           echo "To disable Tetgen, run configure again with the --disable-tetgen"
           echo "option."
           echo "********************************************************************"
        fi
      else
        if test "x$enable_tetgen" != "xno"; then
           echo "********************************************************************"
           echo "If you want to use Hang Si's Tetgen as an alternative"
           echo "3D mesh generator, please download Tetgen from the project's"
           echo "web site at http://www.tetgen.berlios.de, unpack the archive"
           echo "and move the files predicates.cxx, tetgen.cxx and tetgen.h in"
           echo "the ./contrib/Tetgen subdirectory. Then run ./configure again."
           echo "Please note that by doing so, you agree with Tetgen's licensing"
           echo "requirements stated in ./contrib/Tetgen/LICENSE. (Most notably, you"
           echo "may then only redistribute Gmsh if no compensation is received.)"
           echo "********************************************************************"
        fi
      fi
    
      dnl Check for MathEval
      if test "x$enable_matheval" != "xno"; then
        AC_CHECK_FILE(./contrib/MathEval/matheval.cpp, MATHEVAL="yes", MATHEVAL="no")
        if test "x${MATHEVAL}" = "xyes"; then
          GMSH_DIRS="${GMSH_DIRS} contrib/MathEval"
          GMSH_LIBS="${GMSH_LIBS} -lGmshMathEval"
          FLAGS="-DHAVE_MATH_EVAL ${FLAGS}"
        fi
      fi
    
      dnl Check for FourierModel
      if test "x$enable_fm" != "xno"; then
        AC_CHECK_FILE(./contrib/FourierModel/FM_Face.cpp, FOURIER="yes", FOURIER="no")
        if test "x${FOURIER}" = "xyes"; then
          dnl Check for lapack
          AC_CHECK_LIB(lapack,main,LAPACK="yes",LAPACK="no")
          if test "x${LAPACK}" != "xyes"; then
            AC_MSG_WARN([Could not find lapack: disabling FourierModel.])
          else
            dnl Check for FFTW3
            if test "x${FFTW3_PREFIX}" != "x"; then
              LDFLAGS="-L${FFTW3_PREFIX}/lib ${LDFLAGS}"
            fi
            AC_CHECK_LIB(fftw3,main,FFTW3="yes",FFTW3="no")
            if test "x${FFTW3}" != "xyes"; then
              AC_MSG_WARN([Could not find FFTW3: disabling FourierModel.])
            else
              GMSH_DIRS="${GMSH_DIRS} contrib/FourierModel"
              if test "x${FFTW3_PREFIX}" = "x"; then
                GMSH_LIBS="${GMSH_LIBS} -lGmshFourierModel -lfftw3"
                FLAGS="-DHAVE_FOURIER_MODEL ${FLAGS}"
              else
                GMSH_LIBS="${GMSH_LIBS} -lGmshFourierModel -L${FFTW3_PREFIX}/lib -lfftw3"
                FLAGS="-DHAVE_FOURIER_MODEL ${FLAGS} -I${FFTW3_PREFIX}/include"
              fi
              GMSH_LIBS="${GMSH_LIBS} -llapack"
            fi
          fi
        fi
      fi
    
    fi
    
    dnl Check for GSL
    if test "x$enable_gsl" != "xno"; then
      if test "x${GSL_PREFIX}" != "x"; then
        LDFLAGS="-L${GSL_PREFIX} -L${GSL_PREFIX}/lib ${LDFLAGS}"
      fi
      AC_CHECK_LIB(gslcblas,main)
      AC_CHECK_LIB(gsl,main,GSL="yes",GSL="no")
      if test "x${GSL}" = "xyes"; then
        FLAGS="-DHAVE_GSL ${FLAGS}"
        if test "x${GSL_PREFIX}" = "x"; then
          GMSH_LIBS="${GMSH_LIBS} -lgsl -lgslcblas"
        else
          GMSH_LIBS="${GMSH_LIBS} -L${GSL_PREFIX} -L${GSL_PREFIX}/lib -lgsl -lgslcblas"
          FLAGS="${FLAGS} -I${GSL_PREFIX} -I${GSL_PREFIX}/include"
        fi
      fi
    fi
    if test "x${GSL}" != "xyes"; then
      dnl Check if non-free numerical recipes routines are in the tree
      AC_CHECK_FILE(./contrib/NR/dsvdcmp.cpp,NR="yes",NR="no")
      if test "x${NR}" = "xyes"; then
        echo "********************************************************************"
        echo "You are building a non-free version of Gmsh, using code copyright"
        echo "(C) 1986-92 Numerical Recipes Software J!0."
        echo "To use the GSL instead, run configure again with the --enable-gsl"
        echo "option."
        echo "********************************************************************"
        GMSH_DIRS="${GMSH_DIRS} contrib/NR"
        GMSH_LIBS="${GMSH_LIBS} -lGmshNR"
      else
        echo "********************************************************************"
        echo "This is the free version of Gmsh and configure could not find"
        echo "the GNU Scientific Library (GSL) on your system:"
        echo "- if it is installed in a non-standard location, please run"
        echo "  configure again with the --with-gsl-prefix option"
        echo "- if it is not installed on your system, you can download it from"
        echo "  http://sources.redhat.com/gsl/"
        echo ""
        echo "IMPORTANT NOTE: You need to install GSL version 1.2 or above. All"
        echo "versions <= 1.1.1 have a bug in the singular value decomposition"
        echo "algorithm that will cause Gmsh to hang during mesh generation."
        echo "********************************************************************"
        AC_MSG_ERROR([Could not find GSL, aborting.])
      fi
    fi
    
    dnl Check for CGNS
    if test "x${CGNS_PREFIX}" != "x"; then
      if test "x$enable_cgns" != "xno"; then
        enable_cgns="yes"
      fi
    fi
    if test "x$enable_cgns" = "xyes"; then
      if test "x${CGNS_PREFIX}" != "x"; then
        LDFLAGS="-L${CGNS_PREFIX}/lib ${LDFLAGS}"
      fi
      AC_CHECK_LIB(cgns,main,CGNS="yes",CGNS="no")
      if test "x${CGNS}" = "xyes"; then
        if test "x${CGNS_PREFIX}" = "x"; then
          GMSH_LIBS="${GMSH_LIBS} -lcgns"
          FLAGS="${FLAGS} -DHAVE_LIBCGNS"
        else
          GMSH_LIBS="${GMSH_LIBS} -L${CGNS_PREFIX}/lib -lcgns"
          FLAGS="${FLAGS} -DHAVE_LIBCGNS -I${CGNS_PREFIX}/include"
        fi
      fi
    fi
    
    dnl Check for OpenCascade
    if test "x${OCC_PREFIX}" != "x"; then
      if test "x$enable_occ" != "xno"; then
        enable_occ="yes"
      fi
    fi
    if test "x$enable_occ" = "xyes"; then
      if test "x${OCC_PREFIX}" != "x"; then
        LDFLAGS="-L${OCC_PREFIX}/lib ${LDFLAGS}"
      fi
      AC_CHECK_LIB(TKernel,main,OCC="yes",OCC="no")
      if test "x${OCC}" = "xyes"; then
        # DataExchange (subset; see occ/ros/adm/make/Makefile for more info)
        OCC_LIBS="-lTKSTEP -lTKSTEP209 -lTKSTEPAttr -lTKSTEPBase -lTKIGES -lTKXSBase"
        # ModelingAlgorithms
        OCC_LIBS="${OCC_LIBS} -lTKOffset -lTKFeat -lTKFillet -lTKBool -lTKShHealing"
        OCC_LIBS="${OCC_LIBS} -lTKMesh -lTKHLR -lTKBO -lTKPrim -lTKTopAlgo -lTKGeomAlgo"
        # ModelingData
        OCC_LIBS="${OCC_LIBS} -lTKBRep -lTKGeomBase -lTKG3d -lTKG2d"
        # FoundationClasses
        OCC_LIBS="${OCC_LIBS} -lTKAdvTools -lTKMath -lTKernel"
        if test "x${OCC_PREFIX}" = "x"; then
          GMSH_LIBS="${GMSH_LIBS} ${OCC_LIBS}"
          FLAGS="${FLAGS} -DHAVE_OCC"
        else
          GMSH_LIBS="${GMSH_LIBS} -L${OCC_PREFIX}/lib ${OCC_LIBS}"
          FLAGS="${FLAGS} -DHAVE_OCC -I${OCC_PREFIX}/inc"
        fi
      fi
    fi
    
    dnl Check for HDF5 (required by MED, needs zlib)
    if test "x${ZLIB}" = "xyes"; then
      if test "x$enable_med" != "xno"; then
        if test "x${HDF5_PREFIX}" != "x"; then
          LDFLAGS="-L${HDF5_PREFIX}/lib ${LDFLAGS}"
        fi
        AC_CHECK_LIB(hdf5,main,HDF5="yes",HDF5="no")
        if test "x${HDF5}" = "xyes"; then
          if test "x${HDF5_PREFIX}" = "x"; then
            GMSH_LIBS="${GMSH_LIBS} -lhdf5"
          else
            GMSH_LIBS="${GMSH_LIBS} -L${HDF5_PREFIX}/lib -lhdf5"
            FLAGS="${FLAGS} -I${HDF5_PREFIX}/include"
          fi
        fi
      fi
    fi
    
    dnl Check for MED (needs hdf5)
    if test "x${HDF5}" = "xyes"; then
      if test "x$enable_med" != "xno"; then
        if test "x${MED_PREFIX}" != "x"; then
          LDFLAGS="-L${MED_PREFIX}/lib ${LDFLAGS}"
        fi
        AC_CHECK_LIB(med,main,MED="yes",MED="no")
        if test "x${MED}" = "xyes"; then
          if test "x${MED_PREFIX}" = "x"; then
            GMSH_LIBS="${GMSH_LIBS} -lmed"
            FLAGS="${FLAGS} -DHAVE_MED"
          else
            GMSH_LIBS="${GMSH_LIBS} -L${MED_PREFIX}/lib -lmed"
            FLAGS="${FLAGS} -DHAVE_MED -I${MED_PREFIX}/include"
          fi
        fi
      fi
    fi
    
    dnl Complete zlib link line (zlib must be linked in after libpng and libhdf5)
    if test "x${ZLIB}" = "xyes"; then
      dnl If provided by FLTK, use that one; otherwise, look for it
      if test "x${FL_ZLIB}" = "xyes"; then
        FLAGS="-DHAVE_LIBZ ${FLAGS}"
      else
        FLAGS="-DHAVE_LIBZ ${FLAGS}"
        if test "x${ZLIB_PREFIX}" = "x"; then
          GMSH_LIBS="${GMSH_LIBS} -lz"
        else
          dnl Find the libs/includes even if libz is _not_ properly installed (ugly hack!)
          GMSH_LIBS="${GMSH_LIBS} -L${ZLIB_PREFIX} -L${ZLIB_PREFIX}/lib -lz"
          FLAGS="${FLAGS} -I${ZLIB_PREFIX} -I${ZLIB_PREFIX}/include"
        fi
      fi
    fi 
    
    dnl Check if we should build the parallel version
    if test "x$enable_parallel" = "xyes"; then
      FLAGS="-DHAVE_PARALLEL ${FLAGS}"
    fi
    
    dnl Finish link line
    GMSH_LIBS="${GMSH_LIBS} -lm"
    
    dnl Modify defaults according to OS
    case "$UNAME" in
    
      CYGWIN* | MINGW*)
        LINKER="${LINKER} -mwindows"
        if test "x$enable_cygwin" != "xyes"; then
          FLAGS="${FLAGS} -DHAVE_NO_DLL"
        fi
        if test "x${OCC}" = "xyes"; then
          GMSH_LIBS="${GMSH_LIBS} -lwinspool -lws2_32"
        fi
        if test "x$enable_gui" != "xno"; then
          GMSH_LIBS="${GMSH_LIBS} Fltk/Win32Icon.res"
        fi
        ;;
    
      Darwin*)
        dnl to build a universal binary, add "-arch ppc -arch i686"
        FLAGS="-DHAVE_NO_DLL ${FLAGS}"
        if test "x$enable_gui" = "xno"; then
          GMSH_LIBS="${GMSH_LIBS} -framework ApplicationServices"
        fi
        dnl POSTBUILD="/Developer/Tools/Rez -t APPL -o bin/gmsh Fltk/MacRes.r"
        ;;
    
      AIX*)
        FLAGS="-D_BSD -DHAVE_NO_DLL ${FLAGS}"
        ;;
    
      IRIX*)
        dnl options for native SGI compiler
        case "${CXX}" in
          *CC*)
            dnl add "-mips3 -n32" to FLAGS, AR and LINKER for portable 32 bit exe
            dnl "-DOLDCINCLUDE" is for Netgen
            FLAGS="-LANG:std -OPT:Olimit=0 -DOLDCINCLUDE ${FLAGS}"
            AR="${CXX} -ar -o"
            LINKER="${CXX}"
            ;;
        esac
        ;;
    
      OSF1*)
        FLAGS="-DHAVE_NO_SOCKLEN_T ${FLAGS}"
        dnl options for native DEC compiler
        case "${CXX}" in
          *cxx*)
            FLAGS="-D__USE_STD_IOSTREAM ${FLAGS}"
            ;;
        esac
        ;;
    
      SunOS*)
        FLAGS="-DHAVE_NO_DLL ${FLAGS}"
        GMSH_LIBS="${GMSH_LIBS} -lsocket -lnsl -ldl"
        ;;
    
      HP-UX*)
        FLAGS="-DHAVE_NO_DLL ${FLAGS}"
        ;;
    
    esac
    
    dnl Compiler characteristics
    dnl Check sizeof size_t (flag as 64 if not 32)
    AC_CHECK_SIZEOF([size_t])
    if test $ac_cv_sizeof_size_t != 4; then
      if test $ac_cv_sizeof_size_t != 8; then
        AC_MSG_WARN([Unsupported size of size_t - this may affect FNV hashing.])
      else
        FLAGS="$FLAGS -DHAVE_64BIT_SIZE_T"
      fi
    fi
    
    dnl Write output
    AC_SUBST(UNAME)
    AC_SUBST(FLAGS)
    AC_SUBST(OPTIM)
    AC_SUBST(LINKER)
    AC_SUBST(GMSH_DIRS)
    AC_SUBST(GMSH_LIBS)
    AC_SUBST(POSTBUILD)
    AC_SUBST(AR)
    AC_OUTPUT(variables)
    
    dnl Print some information
    echo "********************************************************************"
    echo "Gmsh is configured for"
    echo "- OS           : $UNAME"
    echo "- C compiler   : $CC"
    echo "- C++ compiler : $CXX"
    echo "- Linker       : $LINKER"
    echo "- Optimization : $OPTIM"
    echo "- Options      : $FLAGS"
    echo "********************************************************************"
    echo "To fine-tune the configuration, edit the 'variables' file"
    echo "********************************************************************"