Skip to content
Snippets Groups Projects
Forked from gmsh / gmsh
18531 commits behind the upstream repository.
configure.in 15.17 KiB
dnl $Id: configure.in,v 1.60 2005-01-21 17:29:27 geuzaine Exp $
dnl
dnl Copyright (C) 1997-2005 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],[FLTK_PREFIX="$FLTK_DIR"])
AC_ARG_WITH(gsl-prefix,
            AC_HELP_STRING([--with-gsl-prefix=PFX],
                           [prefix where GSL is installed]),
            [GSL_PREFIX=$withval],[GSL_PREFIX="$GSL_DIR"])
AC_ARG_WITH(jpeg-prefix,
            AC_HELP_STRING([--with-jpeg-prefix=PFX],
                           [prefix where the JPEG library and includes are installed]),
            [JPEG_PREFIX=$withval],[JPEG_PREFIX="$JPEG_DIR"])
AC_ARG_WITH(png-prefix,
            AC_HELP_STRING([--with-png-prefix=PFX],
                           [prefix where the PNG library and includes are installed]),
            [PNG_PREFIX=$withval],[PNG_PREFIX="$PNG_DIR"])
AC_ARG_WITH(z-prefix,
            AC_HELP_STRING([--with-z-prefix=PFX],
                           [prefix where the ZLIB library and includes are installed]),
            [Z_PREFIX=$withval],[Z_PREFIX="$Z_DIR"])

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(parallel,
              AC_HELP_STRING([--enable-parallel],
                             [enable parallel version (default=no)]))
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(matheval,
              AC_HELP_STRING([--enable-matheval],
                             [compile MathEval if available (default=yes)]))
AC_ARG_ENABLE(jpeg,
              AC_HELP_STRING([--enable-jpeg],
                             [enable JPEG support (default=yes)]))
AC_ARG_ENABLE(z,
              AC_HELP_STRING([--enable-z],
                             [enable ZLIB support (default=yes)]))
AC_ARG_ENABLE(png,
              AC_HELP_STRING([--enable-png],
                             [enable PNG support (default=yes)]))

dnl Get the operating system and version number
UNAME=`uname`
if test "x${UNAME}" = "xIRIX64"; then
  UNAME="IRIX"
fi

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

dnl Set default flags
FLAGS=""
INCLS=""
OPTIM="${CXXFLAGS}"

dnl Check for various programs
AC_PROG_CPP
AC_PROG_RANLIB

dnl How to build static libraries?
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"

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 See if we need a .exe extension on executables
AC_EXEEXT

dnl Set default subdirectories and libraries
GMSH_DIRS="Common DataStr Geo Mesh 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} -lGmshCommon -lGmshDataStr -lGmshPlugin -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"
    INCLS="${INCLS} -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

  GMSH_LIBS="${GMSH_LIBS} `$FLTKCONFIG --use-gl --use-images --ldflags`"
  INCLS="${INCLS} `$FLTKCONFIG --use-gl --use-images --cxxflags`"

  dnl Check for libjpeg
  if test "x$enable_jpeg" != "xno"; then
    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"
        INCLS="${INCLS} -I${JPEG_PREFIX} -I${JPEG_PREFIX}/include"
      fi
    fi 
  fi

  dnl Check for libz
  Z=""
  if test "x$enable_z" != "xno"; then
    if test "x${Z_PREFIX}" != "x"; then
      LDFLAGS="-L${Z_PREFIX} -L${Z_PREFIX}/lib ${LDFLAGS}"
    fi
    AC_CHECK_LIB(z,main,Z="yes",Z="no")
  fi

  dnl Check for libpng (only if libz is available)
  if test "x$enable_png" != "xno" -a "x${Z}" = "xyes"; then
    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 libjpeg is _not_ properly installed (ugly hack!)
        GMSH_LIBS="${GMSH_LIBS} -L${PNG_PREFIX} -L${PNG_PREFIX}/lib -lpng"
        INCLS="${INCLS} -I${PNG_PREFIX} -I${PNG_PREFIX}/include"
      fi
    fi 
  fi

  dnl Complete zlib link line (zlib must be linked in after libpng)
  if test "x${Z}" = "xyes"; then
    FLAGS="-DHAVE_LIBZ ${FLAGS}"
    if test "x${Z_PREFIX}" = "x"; then
      GMSH_LIBS="${GMSH_LIBS} -lz"
    else
      dnl Find the libs/includes even if libjpeg is _not_ properly installed (ugly hack!)
      GMSH_LIBS="${GMSH_LIBS} -L${Z_PREFIX} -L${Z_PREFIX}/lib -lz"
      INCLS="${INCLS} -I${Z_PREFIX} -I${Z_PREFIX}/include"
    fi
  fi 
else

  GMSH_DIRS="${GMSH_DIRS} Box"
  GMSH_LIBS="-Llib -lGmshBox -lGmshParser -lGmshMesh -lGmshGeo -lGmshCommon"
  GMSH_LIBS="${GMSH_LIBS} -lGmshDataStr -lGmshPlugin -lGmshNumeric -lGmshParallel"

fi

dnl Check if Triangle is installed
AC_CHECK_FILE(./Triangle/triangle.c, TRIANGLE="yes", TRIANGLE="no")
if test "x${TRIANGLE}" = "xyes"; then
  if test "x$enable_triangle" != "xno"; then
     GMSH_DIRS="${GMSH_DIRS} 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 to Triangle's licensing"
     echo "requirements stated in ./Triangle/README. (Most notably, you can"
     echo "only redistribute Gmsh if no compensation is received.)"
     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 ./Triangle subdirectory. Then run ./configure"
     echo "again."
     echo "Please note that by doing so, you agree to Triangle's licensing"
     echo "requirements stated in ./Triangle/README. (Most notably, you may"
     echo "then only redistribute Gmsh if no compensation is received.)"
     echo "********************************************************************"
  fi
fi


dnl Check if Netgen is installed
AC_CHECK_FILE(./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} 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 ./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 ./Netgen subdirectory. Then"
     echo "run ./configure again."
     echo "Please note that by doing so, you agree with Netgen's licensing"
     echo "requirements stated in ./Netgen/COPYING.LIB."
     echo "********************************************************************"
  fi
fi


dnl Check for MathEval
AC_CHECK_FILE(./MathEval/matheval.cpp, MATHEVAL="yes", MATHEVAL="no")
if test "x${MATHEVAL}" = "xyes"; then
  if test "x$enable_matheval" != "xno"; then
     GMSH_DIRS="${GMSH_DIRS} MathEval"
     GMSH_LIBS="${GMSH_LIBS} -lGmshMathEval"
     FLAGS="-DHAVE_MATH_EVAL ${FLAGS}"
  fi
fi


dnl Check for GSL
if test "x$enable_gsl" != "xno"; then
  if test "x${GSL_PREFIX}" != "x"; then
    LDFLAGS="-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}/lib -lgsl -lgslcblas"
      INCLS="${INCLS} -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(./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} 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 if we should build the parallel version
if test "x$enable_parallel" = "xyes"; then
  FLAGS="-DHAVE_PARALLEL ${FLAGS}"
fi

dnl Set default linker and post build action
LINKER="${CXX}"
POSTBUILD=""

dnl Finish link line
GMSH_LIBS="${GMSH_LIBS} -lm"

dnl Modify defaults according to OS
case "$UNAME" in

  CYGWIN* | MINGW*)
    LINKER="${LINKER} -Wl,--subsystem,windows -mwindows"
    if test "x$enable_gui" != "xno"; then
      GMSH_LIBS="${GMSH_LIBS} Fltk/Win32Icon.res"
    fi
    ;;

  Darwin*)
    FLAGS="-DHAVE_NO_DLL ${FLAGS}"
    if test "x$enable_gui" = "xno"; then
      GMSH_LIBS="${GMSH_LIBS} -framework ApplicationServices"
    fi
    POSTBUILD="/Developer/Tools/Rez -t APPL -o bin/gmsh Fltk/MacRes.r"
    ;;

  AIX*)
    FLAGS="-D_BSD -DHAVE_NO_DLL ${FLAGS}"
    ;;

  IRIX*)
    CXX="CC"
    CC="cc"
    OPTIM="-O2"
    dnl -DOLDCINCLUDE is for Netgen
    FLAGS="-mips3 -n32 -LANG:std -OPT:Olimit=0 -DOLDCINCLUDE ${FLAGS}"
    AR="CC -mips3 -n32 -ar -o"
    LINKER="CC -O2 -mips3 -n32"
    ;;

  OSF1*)
    if test "x${CXX}" = "xcxx" ; then
      FLAGS="-D__USE_STD_IOSTREAM ${FLAGS}"
    fi
    ;;

  SunOS*)
    FLAGS="-DHAVE_NO_DLL ${FLAGS}"
    GMSH_LIBS="${GMSH_LIBS} -lsocket -lnsl -ldl"
    ;;

  HP-UX*)
    FLAGS="-DHAVE_NO_DLL ${FLAGS}"
    ;;

esac

dnl Is the machine big or little endian?
AC_C_BIGENDIAN(FLAGS="-DHAVE_BIG_ENDIAN ${FLAGS}")

dnl Check for header files
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/time.h sys/resource.h)

dnl Write output
AC_SUBST(UNAME)
AC_SUBST(FLAGS)
AC_SUBST(INCLS)
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 "- OPTIM : $OPTIM"
echo "- FLAGS : $FLAGS"
echo "********************************************************************"