dnl dnl Initialization part dnl AC_INIT(pfstools, 1.6.2) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(config.h) AC_LANG(C++) # perform tests in C++ language AC_PROG_CXX AC_PROG_RANLIB AC_PROG_LIBTOOL dnl dnl Templates for autoheader defines dnl AH_TEMPLATE([DEBUG], [Define as 1 when compiling in debug mode ]) dnl dnl Internal Debug dnl AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debug symbols and asserts]), [if test "$enable_debug" = "yes" ; then temp_CXXFLAGS=`echo $CXXFLAGS | sed "s/-O2//; s/-g//"` CXXFLAGS="-g $temp_CXXFLAGS" AC_DEFINE([DEBUG]) fi], [enable_debug="no" temp_CXXFLAGS=`echo $CXXFLAGS | sed "s/-O2//; s/-g//"` CXXFLAGS="-O2 $temp_CXXFLAGS" AC_DEFINE(NDEBUG, 1, [Disable assertion checks]) ]) ########################################################### # system detection and configuration dnl Compile ImageMagic++ code? AC_ARG_ENABLE(ppm, AC_HELP_STRING([--disable-ppm], [Do not compile programs that use PPM (NetPBM) library]), [if test "$enable_ppm" = "no" ; then do_ppm="no" else if test "$enable_ppm" = "yes" ; then do_ppm="yes" fi fi], [do_ppm="yes"]) dnl Compile ImageMagic++ code? AC_ARG_ENABLE(openexr, AC_HELP_STRING([--disable-openexr], [Do not compile programs that use OpenEXR library]), [if test "$enable_openexr" = "no" ; then do_openexr="no" else if test "$enable_openexr" = "yes" ; then do_openexr="yes" fi fi], [do_openexr="yes"]) dnl Compile ImageMagic++ code? AC_ARG_ENABLE(tiff, AC_HELP_STRING([--disable-tiff], [Do not compile programs that use TIFF library]), [if test "$enable_tiff" = "no" ; then do_tiff="no" else if test "$enable_tiff" = "yes" ; then do_tiff="yes" fi fi], [do_tiff="yes"]) dnl Compile ImageMagic++ code? AC_ARG_ENABLE(qt, AC_HELP_STRING([--disable-qt], [Do not compile programs that use QT library]), [if test "$enable_qt" = "no" ; then do_qt="no" else if test "$enable_qt" = "yes" ; then do_qt="yes" fi fi], [do_qt="yes"]) dnl Compile ImageMagic++ code? AC_ARG_ENABLE(jpeghdr, AC_HELP_STRING([--disable-jpeghdr], [Do not compile programs that use JPEGHDR library]), [if test "$enable_jpeghdr" = "no" ; then do_jpeghdr="no" else if test "$enable_jpeghdr" = "yes" ; then do_jpeghdr="yes" fi fi], [do_jpeghdr="yes"]) dnl Compile ImageMagic++ code? AC_ARG_ENABLE(imagemagick, AC_HELP_STRING([--disable-imagemagick], [Do not compile programs that use ImageMagick library]), [if test "$enable_imagemagick" = "no" ; then do_imagemagick="no" else if test "$enable_imagemagick" = "yes" ; then do_imagemagick="yes" fi fi], [do_imagemagick="yes"]) dnl Compile Octave code? AC_ARG_ENABLE(octave, AC_HELP_STRING([--disable-octave], [Do not compile octave interface functions]), [if test "$enable_octave" = "no" ; then do_octave="no" else if test "$enable_octave" = "yes" ; then do_octave="yes" fi fi], [do_octave="yes"]) dnl Compile Octave code? AC_ARG_ENABLE(opengl, AC_HELP_STRING([--disable-opengl], [Do not compile opengl code (pfsglview)]), [if test "$enable_opengl" = "no" ; then do_opengl="no" else if test "$enable_opengl" = "yes" ; then do_opengl="yes" fi fi], [do_opengl="yes"]) dnl Compile Matlab code? AC_ARG_ENABLE(matlab, AC_HELP_STRING([--disable-matlab], [Do not compile matlab files]), [if test "$enable_matlab" = "no" ; then do_matlab="no" else if test "$enable_matlab" = "yes" ; then do_matlab="yes" fi fi], [do_matlab="yes"]) dnl dnl Checking for libraries dnl dnl Check for libnetpbm-9 (Debian) if test "$do_ppm" = "yes"; then AC_CHECK_LIB(netppm, ppm_init, [AC_DEFINE( HAVE_LIBNETPPM,1, [Define this if you have the libnetpbm libraries]) NETPBM_LIBS="-lnetppm -lnetpgm -lnetpbm" ppm_support="yes"],[ppm_support="no"],-lnetpgm -lnetpbm) if test "$ppm_support" = "no"; then dnl Check for libnetpbm-10 (Debian) AC_CHECK_LIB(netpbm, pbm_init, [AC_DEFINE( HAVE_LIBNETPPM,1, [Define this if you have the libnetpbm libraries]) NETPBM_LIBS="-lnetpbm" ppm_support="yes"],[ppm_support="no"]) fi if test "$ppm_support" = "no"; then dnl Check for libppm (sf.net) AC_CHECK_LIB(ppm, ppm_init, [AC_DEFINE( HAVE_LIBNETPPM,1, [Define this if you have the libppm libraries]) NETPBM_LIBS="-lppm" ppm_support="yes"],[ppm_support="no"],) fi else ppm_support="no" fi dnl Check for ImageMagick++ if test "$do_imagemagick" = "yes"; then PKG_CHECK_MODULES(IMAGEMAGICK, ImageMagick++ >= 6.0, [AC_DEFINE( HAVE_LIBIMAGEMAGICK, 1, [ImageMagick library used for reading/writing images.]) imagemagick_support="yes"],[ imagemagick_support="no"]) else imagemagick_support="no" fi if test "$do_tiff" = "yes"; then AC_CHECK_LIB(tiff, TIFFOpen, [AC_DEFINE( HAVE_LIBTIFF,1, [Define this if you have the libtiff libraries]) TIFF_LIBS="-ltiff" tiff_support="yes"],[tiff_support="no"],) else tiff_support="no" fi if test "$do_jpeghdr" = "yes"; then AC_CHECK_LIB(jpeghdr, jpeghdr_CreateDecompress, [AC_DEFINE( HAVE_LIBJPEGHDR,1, [Define this if you have the libjpeghdr libraries]) JPEGHDR_LIBS="-lhdr -ljpeghdr -ljpeg -lm" jpeghdr_support="yes"],[jpeghdr_support="no"], -lhdr -ljpeg -lm) else jpeghdr_support="no" fi dnl Locate OpenEXR includes if test "$do_openexr" = "yes"; then if test -f "/usr/include/OpenEXR/ImfRgbaFile.h"; then openexr_incpath="/usr/include/OpenEXR" else openexr_incpath=`dirname \`locate ImfRgbaFile.h | head -n 1\`` fi AC_ARG_WITH(exrdir, [ --with-openexrdir path where exr include files are installed], openexr_incpath=$withval) #Check first using pkg-config PKG_CHECK_MODULES(OPENEXR, OpenEXR >= 1.0, [AC_DEFINE( HAVE_LIBOPENEXR, 1, [OpenEXR libraries, optional, used in io routines.]) openexr_support="yes"],[ AC_MSG_WARN( $OPENEXR_PKG_ERRORS ) #if not found TMP_LIBS="$LIBS" TMP_CXXFLAGS="$CXXFLAGS" OPENEXR_LIBS="-lImath -lIlmImf -lHalf -lIex -lz" OPENEXR_CFLAGS="-I$openexr_incpath" LIBS="$OPENEXR_LIBS $LIBS" CXXFLAGS="$CXXFLAGS $OPENEXR_CFLAGS" AC_TRY_LINK( [#include using namespace Imf; using namespace Imath;], [RgbaInputFile file("bzdet");], [AC_DEFINE( HAVE_LIBOPENEXR, 1, [OpenEXR libraries, optional, used in io routines.]) AC_MSG_RESULT([yes]); openexr_support="yes"], [AC_MSG_RESULT([no]); openexr_support="no"]) LIBS=$TMP_LIBS CXXFLAGS=$TMP_CXXFLAGS ]) #end of PKG_CHECK_MODULES else openexr_support="no" fi ## QT library check AC_ARG_WITH([qtdir], [ --with-qtdir=DIR Qt installation directory [default=$QTDIR]], QTDIR=$withval) AC_ARG_WITH([qtinclude], [ --with-qtinclude=DIR Qt include directory (overwrites qtdir)], QTINCLUDE=$withval) AC_ARG_WITH([qtlibs], [ --with-qtlibs=DIR Qt library directory (overwrites qtdir)], QTLIBS=$withval) if test "$do_qt" = "yes"; then ##If no QTDIR specified, try pkg-config #if test x"$QTDIR" = x && test x"$QTINCLUDE" = x && test x"$QTLIBS" = x ; then PKG_CHECK_MODULES(QT, qt-mt >= 3.0, [AC_DEFINE( HAVE_LIBQT, 1, [QT libraries, optional, used in pfsview.]) QT_SUPPORT="yes" ],[ #if pkg-config fails AC_MSG_WARN( $QT_PKG_ERRORS ) # pfs_CHECK_QT QT_SUPPORT="no" ]) #end of PKG_CHECK_MODULES #else ## Check QT using the specified QTDIR # pfs_CHECK_QT #fi ## Look for MOC if test -z "$QTDIR"; then MOC="moc" else MOC="$QTDIR/bin/moc" fi AC_ARG_WITH(moc, [ --with-moc Qt meta object compiler], [ MOC=$withval ]) AC_PATH_PROG(MOC, $MOC) test -z "$MOC" && ( AC_MSG_WARN([no QT meta object compiler (moc) found in the path]); QT_SUPPORT="no" ) else QT_SUPPORT="no" fi if test "$do_opengl" = "yes"; then # Checks for OpenGL under given operating system, # adds operating system specific flags and libs. case "$host_os" in [[cC]][[yY]][[gG]][[wW]][[iI]][[nN]]|mingw32|mks|cygwin) AC_DEFINE( WIN32, 1, [Windows compilation.]) AC_MSG_CHECKING([for OpenGL]) AC_COMPILE_IFELSE( AC_LANG_PROGRAM([[ #include #include ]],[[glEnd();]]), [AC_DEFINE( HAVE_LIBOPENGL, 1, [OpenGL libraries are required.]) GL_LIBS="-L/usr/local/lib -lglut32 -lglu32 -lopengl32 -lgdi32" GL_CFLAGS="-I/usr/local/include -DCYGWIN -DWIN32 -D_WIN32 -DGLEW_STATIC" gl_support="yes" AC_MSG_RESULT([yes])], [AC_MSG_WARN( [OpenGL test failed. pfsglview will not be compiled] ) gl_support="no" ]) ;; darwin*) AC_DEFINE( HAVE_LIBOPENGL, 1, [OpenGL libraries are required.]) GL_LIBS="$LIBS -framework GLUT -framework OpenGL -framework Cocoa" gl_support="yes" ;; *) AC_CHECK_LIB(GL, glDisable, [ AC_CHECK_LIB(glut, glutInit, AC_DEFINE( HAVE_LIBOPENGL, 1, [OpenGL libraries are required.]) GL_LIBS="$LIBS -lglut -lGLU -lGL -lpthread" gl_support="yes", AC_MSG_WARN( [GLUT library not found. pfsglview will not be compiled] ) gl_support="no" ) ], [AC_MSG_WARN( [OpenGL test failed. pfsglview will not be compiled] ) gl_support="no"] ,) ;; esac else gl_support="no" fi dnl Check for MATLAB MEX=mex AC_ARG_WITH(mex, [ --with-mex MATLAB compiler command], MEX=$withval) if test "${prefix}" = "NONE"; then MEX_DIR=`eval echo "/usr/local/share/${PACKAGE}/matlab"` else MEX_DIR=`eval echo "${datadir}/${PACKAGE}/matlab"` fi AC_DEFINE_UNQUOTED( [PCG_DATADIR], "$PCG_DATADIR", [Directory where data files are located.]) AC_ARG_WITH(mex-dir, [ --with-mex-dir path for MATLAB files], MEX_DIR=$withval) matlab_support="no"; if test "$do_matlab" = "yes"; then AC_PATH_PROG(MEX, $MEX) if test -n "$MEX" && $MEX -v 2>/dev/null | grep MATLAB >/dev/null; then matlab_support="yes"; else if test -n "$MEX"; then AC_MSG_WARN([mex script does not seem to come from matlab (could be Octave mex script). Pass the path to matlab mex using --with-mex option.]) else AC_MSG_WARN([no matlab mex found in the path]) fi fi fi dnl dnl Autoheader defines dnl AH_BOTTOM([/* Output stream for debug messages. */ #ifdef DEBUG #define DEBUG_STR cerr #else #define DEBUG_STR if(1); else cerr #endif /* Output stream for verbose messages */ #define VERBOSE_STR if(verbose) std::cerr << PROG_NAME << ": " ]) ## TODO: check by compiling a simple program if it is necessary AH_BOTTOM([/* On some systems iostream, string etc are in 'std' namespace */ using namespace std; ]) ##AC_PREFIX_DEFAULT("$HOME/local") AC_SUBST(NETPBM_LIBS) AC_SUBST(TIFF_LIBS) AC_SUBST(OPENEXR_LIBS) AC_SUBST(OPENEXR_CFLAGS) AC_SUBST(IMAGEMAGICK_LIBS) AC_SUBST(IMAGEMAGICK_CFLAGS) AC_SUBST(JPEGHDR_LIBS) AC_SUBST(QT_LIBS) AC_SUBST(QT_CFLAGS) AC_SUBST(GL_LIBS) AC_SUBST(GL_CFLAGS) AC_SUBST(MOC) AC_SUBST(CFLAGS) AC_SUBST(PACKAGE_VERSION) AC_SUBST(MEX) AC_SUBST(MEX_DIR) #QT_PATH=$qtpath #AC_SUBST(QT_PATH) if test "$do_octave" = "yes"; then #Check for octave #oct_version="2.1.35" oct_version="" AC_ARG_WITH(oct-version, [ --with-oct-version Octave version, default empty, example: '2.1.35'], [ oct_version=$withval ]) if test -n "$oct_version"; then oct_version="-${oct_version}"; fi OCTAVE_OCT_DIR=`octave-config${oct_version} --oct-site-dir` OCTAVE_OCT_DIR=${OCTAVE_OCT_DIR:+${OCTAVE_OCT_DIR}/pfstools} OCTAVE_M_DIR=`octave-config${oct_version} --m-site-dir` OCTAVE_M_DIR=${OCTAVE_M_DIR:+${OCTAVE_M_DIR}/pfstools} AC_ARG_WITH(octave-dir, [ --with-octave-dir where Octave's .oct and .m files should be installed], [ OCTAVE_OCT_DIR=$withval; OCTAVE_M_DIR=$withval ]) AC_ARG_WITH(octave-m-dir, [ --with-octave-m-dir where Octave's .m files should be installed], [ OCTAVE_M_DIR=$withval ]) AC_ARG_WITH(octave-oct-dir, [ --with-octave-oct-dir where Octave's .oct files should be installed], [ OCTAVE_OCT_DIR=$withval ]) test -z "$OCTAVE_OCT_DIR" && AC_MSG_WARN([no path for .oct files specified]) test -z "$OCTAVE_M_DIR" && AC_MSG_WARN([no path for .m files specified]) MKOCTFILE="mkoctfile${oct_version}" AC_ARG_WITH(mkoctfile, [ --with-mkoctfile mkoctfile command], [ MKOCTFILE=$withval ]) AC_PATH_PROG(MKOCTFILE, $MKOCTFILE) test -z "$MKOCTFILE" && AC_MSG_WARN([no mkoctfile found in the path]) if test -z "$MKOCTFILE" || test -z "$OCTAVE_OCT_DIR" || test -z "$OCTAVE_M_DIR"; then octave_support="no" AC_MSG_WARN([Octave support disabled]) else octave_support="yes" fi else # do_octave == yes octave_support="no" fi AC_PATH_PROG(PDFLATEX, [pdflatex]) test -z "$PDFLATEX" && AC_MSG_WARN([pdflatex not found in the path]) AM_CONDITIONAL(OCTAVE_SUPPORT, test "$octave_support" = "yes" ) AM_CONDITIONAL(PPM_SUPPORT, test "$ppm_support" = "yes" ) AM_CONDITIONAL(OPENEXR_SUPPORT, test "$openexr_support" = "yes" ) AM_CONDITIONAL(TIFF_SUPPORT, test "$tiff_support" = "yes" ) AM_CONDITIONAL(JPEGHDR_SUPPORT, test "$jpeghdr_support" = "yes" ) AM_CONDITIONAL(IMAGEMAGICK_SUPPORT, test "$imagemagick_support" = "yes" ) AM_CONDITIONAL(QT_SUPPORT, test "$QT_SUPPORT" = "yes" ) AM_CONDITIONAL(PDFLATEX_SUPPORT, test -n "$PDFLATEX" ) AM_CONDITIONAL(GL_SUPPORT, test "$gl_support" = "yes" ) AM_CONDITIONAL(MATLAB_SUPPORT, test "$matlab_support" = "yes" ) AC_SUBST(MKOCTFILE) AC_SUBST(OCTAVE_M_DIR) AC_SUBST(OCTAVE_OCT_DIR) AC_CONFIG_FILES([ Makefile ]) AC_CONFIG_FILES([ src/Makefile ]) AC_CONFIG_FILES([ src/pfs/Makefile ]) AC_CONFIG_FILES([ src/pfs/pfs.pc ]) AC_CONFIG_FILES([ src/fileformat/Makefile ]) AC_CONFIG_FILES([ src/filter/Makefile ]) AC_CONFIG_FILES([ src/octave/Makefile ]) AC_CONFIG_FILES([ src/pfsview/Makefile ]) AC_CONFIG_FILES([ src/pfsglview/Makefile ]) AC_CONFIG_FILES([ src/matlab/Makefile ]) AC_CONFIG_FILES([ doc/Makefile ]) AC_OUTPUT AC_MSG_RESULT([ pfstools is now configured for ${host} Source directory: $srcdir Installation prefix: $prefix C++ compiler: $CXX $XTRA_CXXFLAGS $WARN_CXXFLAGS $CXXFLAGS Octave $octave_support octave-m-dir: $OCTAVE_M_DIR octave-oct-dir: $OCTAVE_OCT_DIR mkoctfile: $MKOCTFILE Matlab $matlab_support matlab-dir: $MEX_DIR mex: $MEX PPM $ppm_support LIBS: $NETPBM_LIBS TIFF $tiff_support LIBS: $TIFF_LIBS OpenEXR $openexr_support CFLAGS: $OPENEXR_CFLAGS LIBS: $OPENEXR_LIBS ImageMagick++ $imagemagick_support CFLAGS: $IMAGEMAGICK_CFLAGS LIBS: $IMAGEMAGICK_LIBS JPEG-HDR $jpeghdr_support LIBS: $JPEGHDR_LIBS QT $QT_SUPPORT QTDIR: $QTDIR CFLAGS: $QT_CFLAGS LIBS: $QT_LIBS MOC: $MOC OpenGL $gl_support CFLAGS: $GL_CFLAGS LIBS: $GL_LIBS Debug mode $enable_debug $HINTS ]) if test "$QT_SUPPORT" = "no"; then AC_MSG_RESULT([ * To enable QT support, try specifying either --with-qtdir, or a triple --with-qtinclude, --with-qtlibs, --with-moc. ]) fi