## $Id$ # # serial 9 (yat 0.11) # # see http://www.gnu.org/software/automake/manual/automake.html#Serials # # SYNOPSIS # # YAT_CHECK_YAT([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # DESCRIPTION # # Test yat library of a particular version # # This macro file can be used by applications to find and use the # yat library. # # Note: macros in this file assume that yat-config has been # installed. yat-config was introduced in yat 0.5 and # consequently these macros do not work with yat 0.4.x (or # older). # # This macro calls: # # AC_SUBST(YAT_CPPFLAGS) # AC_SUBST(YAT_CXXFLAGS) # AC_SUBST(YAT_LDFLAGS) # AC_SUBST(YAT_LIBS) # AC_SUBST(YAT_LA_FILE) # AC_SUBST(YAT_LT_ADD) # # defines: # # HAVE_YAT # # and sets the following variable: # # yat_config: If yat-config exists, $yat_config refers to it, # otherwise $yat_config is set to "no". # # # YAT_CHECK_YAT is split into sub-macros: # # YAT_FIND_YAT() # YAT_CHECK_VERSION([MINIMUM-VERSION]) # YAT_CHECK_HEADER() # YAT_CHECK_LIB() # # so when preferable, you can call any of these instead. # # # YAT_FIND_YAT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Finds the yat-config scripts. If there is no --with-yat # specified, it will look in the PATH. Sets a shell variable # $yat_config. $yat_config is required for the other macros and # therefore if YAT_FIND_YAT has not been called, they will call # YAT_FIND_YAT. If --without-yat (or equivalently --with-yat=no) # is given, all tests and actions are turned off. # # # YAT_CHECK_VERSION([MINIMUM-VERSION=0.5], # [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) # # If the version of yat is at least MINIMUM-VERSION, execute # ACTION-IF-FOUND, otherwise execute ACTION-IF-NOT-FOUND. # # # YAT_CHECK_HEADER([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # If yat headers are found and compilable, call # AC_SUBST(YAT_CPPFLAGS) and AC_SUBST(YAT_CXXFLAGS), define # HAVE_YAT, execute ACTION-IF-FOUND. If test compilation failed # execute ACTION-IF-NOT-FOUND. # # # YAT_CHECK_LIB([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Compile a small program and link it to yat. On success call # AC_SUBST(YAT_LDFLAGS), AC_SUBST(YAT_LIBS), AC_SUBST(YAT_LT_ADD), # and AC_SUBST(YAT_LA_FILE), and define HAVE_YAT, and execute # ACTION-IF-FOUND. On failure execute ACTION-IF-NOT-FOUND. # # YAT_CHECK_LIB_WITH_BAM([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Test if libyat has bam support. Compile a small program using # class omic::InBamFile and link it to libyat. On success execute # ACTION-IF-FOUND. On failure execute ACTION-IF-NOT-FOUND. Macro # requires that yat-config is available, see YAT_FIND_YAT above. # # # LAST MODIFICATION # # $Date$ # # COPYLEFT # # Copyright (C) 2008 Jari Häkkinen, Peter Johansson # Copyright (C) 2009, 2010, 2011, 2012, 2013 Peter Johansson # # This file is part of the yat library, http://dev.thep.lu.se/yat # # The yat library is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 3 of the # License, or (at your option) any later version. # # The yat library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with yat. If not, see . # AC_DEFUN([YAT_CHECK_YAT], [ AC_PREREQ([2.60]) dnl we use YAT_FIND_YAT ac_yat_check_yat_res="yes" AC_REQUIRE([YAT_FIND_YAT]) dnl YAT_CHECK_VERSION([$1],,[ac_yat_check_yat_res="no"]) AS_IF([test x$ac_yat_check_yat_res = xyes], [ YAT_CHECK_HEADER(,[ac_yat_check_yat_res="no"]) ]) AS_IF([test x$ac_yat_check_yat_res = xyes], [ YAT_CHECK_LIB(,[ac_yat_check_yat_res="no"]) ]) _YAT_ACTION([test "$ac_yat_check_yat_res" != "no"],[$2],[$3]) ]) # YAT_CHECK_YAT AC_DEFUN([YAT_FIND_YAT], [ AC_PREREQ([2.60]) dnl we use multi-arg AS_IF AC_ARG_WITH([yat], [AS_HELP_STRING([--with-yat=DIR], [prefix for installed yat library or full path to yat-config])], [], [with_yat=yes]) yat_config=no; yat_ac_want_yat=yes; AS_IF([test "x$with_yat" = "xno"], [yat_ac_want_yat=no], [test "x$with_yat" = "xyes"], [AC_PATH_PROG([yat_config], [yat-config], [no]) AS_IF([test "$yat_config" = "no"], [AC_MSG_WARN([ the yat-config script installed by yat could not be found. If yat was installed in PREFIX, make sure PREFIX/bin is in your path, or supply the appropriate --with-yat option]) ]) ], [AC_MSG_NOTICE([looking for yat-config]) for p in $with_yat $with_yat/yat-config $with_yat/bin/yat-config ; do AS_IF([test "x$yat_config" = "xno"], [AC_MSG_CHECKING([$p]); AS_IF([test -f "$p" && $p --help > /dev/null 2>&1], [yat_config=$p; AC_MSG_RESULT([yes]);], [AC_MSG_RESULT([no]);]) ]) done AS_IF([test "$yat_config" = "no"], [AC_MSG_WARN([ the --with-yat parameter is incorrect. It must specify an install prefix, or a yat-config file.]) ]) ]) _YAT_ACTION([test "$yat_config" != "no"],[$1],[$2]) ]) # YAT_FIND_YAT AC_DEFUN([YAT_CHECK_VERSION], [ AC_PREREQ([2.60]) dnl we use YAT_FIND_YAT AC_REQUIRE([YAT_FIND_YAT]) dnl if test "$yat_config" != "no"; then m4_pushdef([yat_min_version], [m4_default([$1], [0.5])]) dnl AC_MSG_CHECKING([if version of yat is at least yat_min_version]) if $yat_config --atleast-version=yat_min_version; then AC_MSG_RESULT([yes]) ac_yat_version_ok=yes; else AC_MSG_RESULT([no]) ac_yat_version=`$yat_config --version` AC_MSG_WARN([ '$yat_config --version' returned $ac_yat_version, but the minimum required version is yat_min_version.]) fi m4_popdef([yat_min_version]) dnl fi _YAT_ACTION([test "$ac_yat_version_ok" = "yes"],[$2],[$3]) ]) # YAT_CHECK_VERSION AC_DEFUN([YAT_CHECK_HEADER], [ AC_PREREQ([2.60]) dnl we use YAT_FIND_YAT AC_REQUIRE([YAT_FIND_YAT]) dnl if test "$yat_config" != "no"; then ac_yat_save_CPPFLAGS=$CPPFLAGS ac_yat_save_CXXFLAGS=$CXXFLAGS YAT_CPPFLAGS=`$yat_config --cppflags` YAT_CXXFLAGS=`$yat_config --cxxflags` CPPFLAGS="$CPPFLAGS $YAT_CPPFLAGS" CXXFLAGS="$CXXFLAGS $YAT_CXXFLAGS" AC_LANG_ASSERT([C++]) # checking for Vector, which uses both GSL and Boost AC_CHECK_HEADER([yat/utility/Vector.h], [ac_yat_ok="yes"], [ac_yat_ok="no"]) # checking that version in yat-config and version.h agree AC_MSG_CHECKING([version in $yat_config]) yat_config_version=`$yat_config --version` AC_MSG_RESULT([$yat_config_version]) AC_CACHE_CHECK([version in 'yat/utility/version.h'], [yat_cv_header_version_equal_yat_config], [yat_cv_header_version_equal_yat_config=no AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([@%:@include ], [ @%:@if YAT_VERSION_AT_LEAST(`$yat_config --version-major`,\ `$yat_config --version-minor`,\ `$yat_config --version-patch`) // Versions agree @%:@else @%:@ error yat versions disagree @%:@endif ]) ], [yat_cv_header_version_equal_yat_config=yes], [yat_cv_header_version_equal_yat_config=no]) ]) AS_IF([test x$yat_cv_header_version_equal_yat_config = xyes], [ ac_yat_ok=yes; AC_SUBST(YAT_CPPFLAGS) AC_SUBST(YAT_CXXFLAGS) AC_DEFINE([HAVE_YAT],[1],[define if yat library is available]) ], [ AC_MSG_WARN([ version declared in included yat/utility/version.h is not equal to the one given from yat-config script: $yat_config.]) ac_yat_ok=no ]) # restore FLAGS CPPFLAGS=$ac_yat_save_CPPFLAGS CXXFLAGS=$ac_yat_save_CXXFLAGS fi _YAT_ACTION([test "$ac_yat_ok" = "yes"],[$1],[$2]) ]) # YAT_CHECK_HEADER AC_DEFUN([YAT_CHECK_LIB], [ AC_PREREQ([2.60]) dnl we use YAT_FIND_YAT AC_REQUIRE([YAT_FIND_YAT]) dnl if test "$yat_config" != "no"; then ac_yat_save_LDFLAGS=$LDFLAGS ac_yat_save_LIBS=$LIBS YAT_LDFLAGS=`$yat_config --ldflags` YAT_LIBS=`$yat_config --libs` LDFLAGS="$LDFLAGS $YAT_LDFLAGS" LIBS="$LIBS $YAT_LIBS" AC_LANG_ASSERT([C++]) AC_CACHE_CHECK([for utility::version(void) in yat], [yat_cv_lib_yat], [_YAT_CHECK_LIB_YAT([yat_cv_lib_yat=yes], [yat_cv_lib_yat=no])]) AS_IF([test x$yat_cv_lib_yat = xyes], [ ac_yat_ok="yes"; AC_SUBST(YAT_LDFLAGS) AC_SUBST(YAT_LIBS) # be compatible with yat-config 0.5.x AS_IF([$yat_config --atleast-version=0.6], [YAT_LA_FILE=`$yat_config --yat-la-file`;], [YAT_LA_FILE=`$yat_config --link-libtool`;]) AC_SUBST(YAT_LA_FILE) YAT_LT_ADD=`$yat_config --link-libtool`; AC_SUBST(YAT_LT_ADD)], [ac_yat_ok="no"; AC_MSG_RESULT([no]) AC_MSG_WARN([ the test program failed to link (or compile). See file config.log for details on what occured.]) ]) # restore FLAGS LDFLAGS=$ac_yat_save_LDFLAGS LIBS=$ac_yat_save_LIBS fi _YAT_ACTION([test "$ac_yat_ok" = "yes"],[$1],[$2]) ]) # YAT_CHECK_LIB # YAT_CHECK_LIB_WITH_BAM AC_DEFUN([YAT_CHECK_LIB_WITH_BAM], [ AC_PREREQ([2.60]) dnl we use YAT_FIND_YAT AC_REQUIRE([YAT_FIND_YAT]) dnl AS_IF([test x"$yat_config" = x""], [ yat_cv_lib_with_bam=no ],[ ac_yat_save_CPPFLAGS=$CPPFLAGS ac_yat_save_CXXFLAGS=$CXXFLAGS ac_yat_save_LDFLAGS=$LDFLAGS ac_yat_save_LIBS=$LIBS CPPFLAGS="$CPPFLAGS `$yat_config --cppflags`" CXXFLAGS="$CXXFLAGS `$yat_config --cxxflags`" LDFLAGS="$LDFLAGS `$yat_config --ldflags`" LIBS="$LIBS `$yat_config --libs`" AC_LANG_ASSERT([C++]) AC_CACHE_CHECK([for class BamInFile], [yat_cv_lib_with_bam], [AC_LINK_IFELSE([ AC_LANG_PROGRAM([[@%:@include ]], [using namespace theplu::yat::omic; InBamFile is("myfile");]) ],[ yat_cv_lib_with_bam=yes ],[ yat_cv_lib_with_bam=no ]) ]) # restore FLAGS CPPFLAGS=$ac_yat_save_CPPFLAGS CXXFLAGS=$ac_yat_save_CXXFLAGS LDFLAGS=$ac_yat_save_LDFLAGS LIBS=$ac_yat_save_LIBS ]) AS_CASE([$yat_cv_lib_with_bam], [yes], [$1], [no], [$2]) ]) # YAT_CHECK_LIB_WITH_BAM # Private macros # # if yat_ac_want_yat = no do nothing # if $1 do $2 else do $3 # AC_DEFUN([_YAT_ACTION], [ AS_IF([test "x$yat_ac_want_yat" = "xno"],[], [$1],[m4_default([$2], [:])], [m4_default([$3], [:])]) ]) # _YAT_CHECK_LIB_YAT([ACTION-IF_FOUND], [ACTION-IF-NOT-FOUND]) # AC_DEFUN([_YAT_CHECK_LIB_YAT], [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include namespace theplu{ namespace yat{ namespace utility { std::string version(void); }}} ]], [using namespace theplu::yat::utility; std::string s=version();])], [$1], [$2]) ])