dnl dnl AM_PATH_MOLECUILDER(MINIMUM-VERSION, [HAVE_DEBUG=no,yes,full], [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) dnl AC_DEFUN([AM_PATH_MOLECUILDER], [ AC_REQUIRE([AX_BOOST_THREAD]) AC_ARG_WITH(molecuilder,[ --with-molecuilder=PFX Prefix where MoleCuilder is installed (optional)], molecuilder_prefix="$withval", molecuilder_prefix="") AC_ARG_WITH(molecuilder_include,[ --with-molecuilder_include=INCLUDE Where MoleCuilder' includes are installed (optional)], molecuilder_include_prefix="$withval", molecuilder_include_prefix="") AC_ARG_WITH(cp_cv_molecuilder_libs,[ --with-cp_cv_molecuilder_libs=LIBPATH Where MoleCuilder' libs are installed (optional)], cp_cv_molecuilder_libs_prefix="$withval", cp_cv_molecuilder_libs_prefix="") molecuilder_version_min=$1 molecuilder_debug=$2 MoleCuilder_CFLAGS="" MoleCuilder_LIBS="" MoleCuilder_LDFLAGS="" molecuilder_pkgconfig="" # try to set PKG_CONFIG_PATH if test x$molecuilder_prefix != xno; then if test -z $PKG_CONFIG_PATH; then export PKG_CONFIG_PATH="$molecuilder_prefix/lib/pkgconfig/" else export PKG_CONFIG_PATH="$molecuilder_prefix/lib/pkgconfig/:$PKG_CONFIG_PATH" fi fi # 1. test whether pkg-config works MoleCuilder_CONFIG="no" #AC_MSG_NOTICE([PKG_CONFIG_PATH is $PKG_CONFIG_PATH.]) if test x$molecuilder_debug != xno; then molecuilder_libname="MoleCuilder-debug" PKG_CHECK_MODULES([MoleCuilder_debug], [MoleCuilder >= $molecuilder_version_min], [ molecuilder_pkgconfig=yes MoleCuilder_CONFIG="pkg-config $molecuilder_libname" ], [ # 2. if failed, test for binary molecuilder-config AC_PATH_PROG(MoleCuilder_CONFIG, molecuilder-config, no) if test "x$MoleCuilder_CONFIG" = xno && test x$molecuilder_prefix != x ; then AC_MSG_CHECKING([for alternative molecuilder-config location]) if test -e $molecuilder_prefix/bin/molecuilder-config; then molecuilder_pkgconfig=no MoleCuilder_CONFIG="$molecuilder_prefix/bin/molecuilder-config" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi fi ]) else molecuilder_libname="MoleCuilder" PKG_CHECK_MODULES([MoleCuilder], [MoleCuilder >= $molecuilder_version_min], [ molecuilder_pkgconfig=yes MoleCuilder_CONFIG="pkg-config $molecuilder_libname" ], [ # 2. if failed, test for binary molecuilder-config AC_PATH_PROG(MoleCuilder_CONFIG, molecuilder-config, no) if test "x$MoleCuilder_CONFIG" = xno && test x$molecuilder_prefix != x ; then AC_MSG_CHECKING([for alternative molecuilder-config location]) if test -e $molecuilder_prefix/bin/molecuilder-config; then molecuilder_pkgconfig=no MoleCuilder_CONFIG="$molecuilder_prefix/bin/molecuilder-config" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi fi ]) fi # try to set values via MoleCuilder_CONFIG if test "x$MoleCuilder_CONFIG" != xno; then MoleCuilder_CFLAGS=`$MoleCuilder_CONFIG --cflags` if test x$molecuilder_pkgconfig = xno; then MoleCuilder_LIBS=`$MoleCuilder_CONFIG --ldflags --libs` else MoleCuilder_LIBS=`$MoleCuilder_CONFIG --libs` fi #AC_MSG_NOTICE([molecuilder-config found and used.]) fi # else set by hand (or rather by --with..) if test x$molecuilder_include_prefix != x ; then if test -e $molecuilder_include_prefix/include; then MoleCuilder_CFLAGS="$molecuilder_include_prefix/include" #AC_MSG_NOTICE([molecuilder include found and used.]) else AC_MSG_WARN([molecuilder include not found at $molecuilder_include_prefix/include.]) fi fi if test x$cp_cv_molecuilder_libs_prefix != x ; then if test -e "$cp_cv_molecuilder_libs_prefix/lib/lib$molecuilder_libname.so"; then MoleCuilder_LIBS="-L$cp_cv_molecuilder_libs_prefix/lib -l$molecuilder_libname" #AC_MSG_NOTICE([molecuilder libs found and used.]) else AC_MSG_WARN([molecuilder libs not found at $cp_cv_molecuilder_libs_prefix.]) fi fi molecuilder="no" if test "x$MoleCuilder_CFLAGS" != "x"; then if test "x$MoleCuilder_LIBS" != "x"; then molecuilder="yes" fi fi if test x$molecuilder_pkgconfig != xyes; then # check version of lib no_molecuilder="" molecuilder_version=no if test x$molecuilder = xyes; then AC_MSG_CHECKING(for $molecuilder_libname - version >= $molecuilder_version_min) if test "x$MoleCuilder_CONFIG" != xno; then molecuilder_version=`$MoleCuilder_CONFIG --version` else molecuilder_version="" fi molecuilder_major_version=`echo $molecuilder_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` molecuilder_minor_version=`echo $molecuilder_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` molecuilder_micro_version=`echo $molecuilder_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` #AC_MSG_NOTICE([Version found is: $molecuilder_major_version.$molecuilder_minor_version.$molecuilder_micro_version]) #AC_MSG_NOTICE([Version required is: $molecuilder_version_min]) molecuilder_major_min=`echo $molecuilder_version_min | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` if test "x${molecuilder_major_min}" = "x" ; then molecuilder_major_min=0 fi molecuilder_minor_min=`echo $molecuilder_version_min | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` if test "x${molecuilder_minor_min}" = "x" ; then molecuilder_minor_min=0 fi molecuilder_micro_min=`echo $molecuilder_version_min | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x${molecuilder_micro_min}" = "x" ; then molecuilder_micro_min=0 fi if test $molecuilder_major_version -lt $molecuilder_major_min; then molecuilder_version_proper=0 fi if test $molecuilder_major_version -gt $molecuilder_major_min; then molecuilder_version_proper=1 else if test $molecuilder_minor_version -lt $molecuilder_minor_min; then molecuilder_version_proper=0 fi if test $molecuilder_minor_version -gt $molecuilder_minor_min; then molecuilder_version_proper=1 else if test $molecuilder_micro_version -ge $molecuilder_micro_min; then molecuilder_version_proper=1 else molecuilder_version_proper=0 fi fi fi #AC_MSG_NOTICE([$molecuilder_version_proper]) if test $molecuilder_version_proper = 1 ; then molecuilder_version=yes AC_MSG_RESULT([$molecuilder_major_version.$molecuilder_minor_version.$molecuilder_micro_version]) else AC_MSG_RESULT(no) molecuilder_version=no fi fi else # with pkg-config version is checked molecuilder_version=yes fi # check presence of lib SAVE_CPPFLAGS="$CPPFLAGS" SAVE_LIBS="$LIBS" CPPFLAGS="$MoleCuilder_CFLAGS" LIBS="$MoleCuilder_LIBS -lboost_thread" if test x$molecuilder_version = xyes; then AC_CACHE_CHECK(for $molecuilder_libname lib, cp_cv_molecuilder_lib, [ AC_LANG_PUSH([C++]) AC_LINK_IFELSE( [ AC_LANG_PROGRAM([ #include "LinearAlgebra/Vector.hpp" ], [ Vector test; test.Norm(); ]) ],[ cp_cv_molecuilder_lib="yes" ], [ cp_cv_molecuilder_lib="no" ] ) AC_LANG_POP([C++]) ]) fi CPPFLAGS="$SAVE_CPPFLAGS" LIBS="$SAVE_LIBS" if test "x$cp_cv_molecuilder_lib" = xyes ; then ifelse([$3], , :, [$3]) else MoleCuilder_CFLAGS="" MoleCuilder_LDFLAGS="" MoleCuilder_LIBS="" ifelse([$4], , :, [$4]) fi AC_SUBST(MoleCuilder_CFLAGS) AC_SUBST(MoleCuilder_LDFLAGS) AC_SUBST(MoleCuilder_LIBS) ])