[b40080] | 1 | dnl
|
---|
| 2 | dnl AM_PATH_MOLECUILDER(MINIMUM-VERSION, [HAVE_DEBUG=no,yes,full], [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
---|
| 3 | dnl
|
---|
| 4 |
|
---|
| 5 | AC_DEFUN([AM_PATH_MOLECUILDER],
|
---|
| 6 | [
|
---|
| 7 | AC_REQUIRE([AX_BOOST_THREAD])
|
---|
| 8 |
|
---|
| 9 | AC_ARG_WITH(molecuilder,[ --with-molecuilder=PFX Prefix where MoleCuilder is installed (optional)],
|
---|
| 10 | molecuilder_prefix="$withval", molecuilder_prefix="")
|
---|
| 11 | AC_ARG_WITH(molecuilder_include,[ --with-molecuilder_include=INCLUDE Where MoleCuilder' includes are installed (optional)],
|
---|
| 12 | molecuilder_include_prefix="$withval", molecuilder_include_prefix="")
|
---|
| 13 | AC_ARG_WITH(cp_cv_molecuilder_libs,[ --with-cp_cv_molecuilder_libs=LIBPATH Where MoleCuilder' libs are installed (optional)],
|
---|
| 14 | cp_cv_molecuilder_libs_prefix="$withval", cp_cv_molecuilder_libs_prefix="")
|
---|
| 15 |
|
---|
| 16 | molecuilder_version_min=$1
|
---|
| 17 | molecuilder_debug=$2
|
---|
| 18 |
|
---|
| 19 | MoleCuilder_CFLAGS=""
|
---|
| 20 | MoleCuilder_LIBS=""
|
---|
| 21 | MoleCuilder_LDFLAGS=""
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | molecuilder_pkgconfig=""
|
---|
| 25 | # try to set PKG_CONFIG_PATH
|
---|
| 26 | if test x$molecuilder_prefix != xno; then
|
---|
| 27 | if test -z $PKG_CONFIG_PATH; then
|
---|
| 28 | export PKG_CONFIG_PATH="$molecuilder_prefix/lib/pkgconfig/"
|
---|
| 29 | else
|
---|
| 30 | export PKG_CONFIG_PATH="$molecuilder_prefix/lib/pkgconfig/:$PKG_CONFIG_PATH"
|
---|
| 31 | fi
|
---|
| 32 | fi
|
---|
| 33 | # 1. test whether pkg-config works
|
---|
| 34 | MoleCuilder_CONFIG="no"
|
---|
| 35 | #AC_MSG_NOTICE([PKG_CONFIG_PATH is $PKG_CONFIG_PATH.])
|
---|
| 36 | if test x$molecuilder_debug != xno; then
|
---|
| 37 | molecuilder_libname="MoleCuilder-debug"
|
---|
| 38 | PKG_CHECK_MODULES([MoleCuilder_debug], [MoleCuilder >= $molecuilder_version_min], [
|
---|
| 39 | molecuilder_pkgconfig=yes
|
---|
| 40 | MoleCuilder_CONFIG="pkg-config $molecuilder_libname"
|
---|
| 41 | ], [
|
---|
| 42 | # 2. if failed, test for binary molecuilder-config
|
---|
| 43 | AC_PATH_PROG(MoleCuilder_CONFIG, molecuilder-config, no)
|
---|
| 44 | if test "x$MoleCuilder_CONFIG" = xno && test x$molecuilder_prefix != x ; then
|
---|
| 45 | AC_MSG_CHECKING([for alternative molecuilder-config location])
|
---|
| 46 | if test -e $molecuilder_prefix/bin/molecuilder-config; then
|
---|
| 47 | molecuilder_pkgconfig=no
|
---|
| 48 | MoleCuilder_CONFIG="$molecuilder_prefix/bin/molecuilder-config"
|
---|
| 49 | AC_MSG_RESULT([yes])
|
---|
| 50 | else
|
---|
| 51 | AC_MSG_RESULT([no])
|
---|
| 52 | fi
|
---|
| 53 | fi
|
---|
| 54 | ])
|
---|
| 55 |
|
---|
| 56 | else
|
---|
| 57 | molecuilder_libname="MoleCuilder"
|
---|
| 58 | PKG_CHECK_MODULES([MoleCuilder], [MoleCuilder >= $molecuilder_version_min], [
|
---|
| 59 | molecuilder_pkgconfig=yes
|
---|
| 60 | MoleCuilder_CONFIG="pkg-config $molecuilder_libname"
|
---|
| 61 | ], [
|
---|
| 62 | # 2. if failed, test for binary molecuilder-config
|
---|
| 63 | AC_PATH_PROG(MoleCuilder_CONFIG, molecuilder-config, no)
|
---|
| 64 | if test "x$MoleCuilder_CONFIG" = xno && test x$molecuilder_prefix != x ; then
|
---|
| 65 | AC_MSG_CHECKING([for alternative molecuilder-config location])
|
---|
| 66 | if test -e $molecuilder_prefix/bin/molecuilder-config; then
|
---|
| 67 | molecuilder_pkgconfig=no
|
---|
| 68 | MoleCuilder_CONFIG="$molecuilder_prefix/bin/molecuilder-config"
|
---|
| 69 | AC_MSG_RESULT([yes])
|
---|
| 70 | else
|
---|
| 71 | AC_MSG_RESULT([no])
|
---|
| 72 | fi
|
---|
| 73 | fi
|
---|
| 74 | ])
|
---|
| 75 |
|
---|
| 76 | fi
|
---|
| 77 |
|
---|
| 78 | # try to set values via MoleCuilder_CONFIG
|
---|
| 79 | if test "x$MoleCuilder_CONFIG" != xno; then
|
---|
| 80 | MoleCuilder_CFLAGS=`$MoleCuilder_CONFIG --cflags`
|
---|
| 81 | if test x$molecuilder_pkgconfig = xno; then
|
---|
| 82 | MoleCuilder_LIBS=`$MoleCuilder_CONFIG --ldflags --libs`
|
---|
| 83 | else
|
---|
| 84 | MoleCuilder_LIBS=`$MoleCuilder_CONFIG --libs`
|
---|
| 85 | fi
|
---|
| 86 | #AC_MSG_NOTICE([molecuilder-config found and used.])
|
---|
| 87 | fi
|
---|
| 88 |
|
---|
| 89 | # else set by hand (or rather by --with..)
|
---|
| 90 | if test x$molecuilder_include_prefix != x ; then
|
---|
| 91 | if test -e $molecuilder_include_prefix/include; then
|
---|
| 92 | MoleCuilder_CFLAGS="$molecuilder_include_prefix/include"
|
---|
| 93 | #AC_MSG_NOTICE([molecuilder include found and used.])
|
---|
| 94 | else
|
---|
| 95 | AC_MSG_WARN([molecuilder include not found at $molecuilder_include_prefix/include.])
|
---|
| 96 | fi
|
---|
| 97 | fi
|
---|
| 98 | if test x$cp_cv_molecuilder_libs_prefix != x ; then
|
---|
| 99 | if test -e "$cp_cv_molecuilder_libs_prefix/lib/lib$molecuilder_libname.so"; then
|
---|
| 100 | MoleCuilder_LIBS="-L$cp_cv_molecuilder_libs_prefix/lib -l$molecuilder_libname"
|
---|
| 101 | #AC_MSG_NOTICE([molecuilder libs found and used.])
|
---|
| 102 | else
|
---|
| 103 | AC_MSG_WARN([molecuilder libs not found at $cp_cv_molecuilder_libs_prefix.])
|
---|
| 104 | fi
|
---|
| 105 | fi
|
---|
| 106 |
|
---|
| 107 | molecuilder="no"
|
---|
| 108 | if test "x$MoleCuilder_CFLAGS" != "x"; then
|
---|
| 109 | if test "x$MoleCuilder_LIBS" != "x"; then
|
---|
| 110 | molecuilder="yes"
|
---|
| 111 | fi
|
---|
| 112 | fi
|
---|
| 113 |
|
---|
| 114 |
|
---|
| 115 | if test x$molecuilder_pkgconfig != xyes; then
|
---|
| 116 | # check version of lib
|
---|
| 117 | no_molecuilder=""
|
---|
| 118 | molecuilder_version=no
|
---|
| 119 | if test x$molecuilder = xyes; then
|
---|
| 120 | AC_MSG_CHECKING(for $molecuilder_libname - version >= $molecuilder_version_min)
|
---|
| 121 | if test "x$MoleCuilder_CONFIG" != xno; then
|
---|
| 122 | molecuilder_version=`$MoleCuilder_CONFIG --version`
|
---|
| 123 | else
|
---|
| 124 | molecuilder_version=""
|
---|
| 125 | fi
|
---|
| 126 |
|
---|
| 127 | molecuilder_major_version=`echo $molecuilder_version | \
|
---|
| 128 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
---|
| 129 | molecuilder_minor_version=`echo $molecuilder_version | \
|
---|
| 130 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
---|
| 131 | molecuilder_micro_version=`echo $molecuilder_version | \
|
---|
| 132 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
---|
| 133 |
|
---|
| 134 | #AC_MSG_NOTICE([Version found is: $molecuilder_major_version.$molecuilder_minor_version.$molecuilder_micro_version])
|
---|
| 135 | #AC_MSG_NOTICE([Version required is: $molecuilder_version_min])
|
---|
| 136 |
|
---|
| 137 | molecuilder_major_min=`echo $molecuilder_version_min | \
|
---|
| 138 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
---|
| 139 | if test "x${molecuilder_major_min}" = "x" ; then
|
---|
| 140 | molecuilder_major_min=0
|
---|
| 141 | fi
|
---|
| 142 |
|
---|
| 143 | molecuilder_minor_min=`echo $molecuilder_version_min | \
|
---|
| 144 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
---|
| 145 | if test "x${molecuilder_minor_min}" = "x" ; then
|
---|
| 146 | molecuilder_minor_min=0
|
---|
| 147 | fi
|
---|
| 148 |
|
---|
| 149 | molecuilder_micro_min=`echo $molecuilder_version_min | \
|
---|
| 150 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
---|
| 151 | if test "x${molecuilder_micro_min}" = "x" ; then
|
---|
| 152 | molecuilder_micro_min=0
|
---|
| 153 | fi
|
---|
| 154 |
|
---|
| 155 | if test $molecuilder_major_version -lt $molecuilder_major_min; then
|
---|
| 156 | molecuilder_version_proper=0
|
---|
| 157 | fi
|
---|
| 158 | if test $molecuilder_major_version -gt $molecuilder_major_min; then
|
---|
| 159 | molecuilder_version_proper=1
|
---|
| 160 | else
|
---|
| 161 | if test $molecuilder_minor_version -lt $molecuilder_minor_min; then
|
---|
| 162 | molecuilder_version_proper=0
|
---|
| 163 | fi
|
---|
| 164 | if test $molecuilder_minor_version -gt $molecuilder_minor_min; then
|
---|
| 165 | molecuilder_version_proper=1
|
---|
| 166 | else
|
---|
| 167 | if test $molecuilder_micro_version -ge $molecuilder_micro_min; then
|
---|
| 168 | molecuilder_version_proper=1
|
---|
| 169 | else
|
---|
| 170 | molecuilder_version_proper=0
|
---|
| 171 | fi
|
---|
| 172 | fi
|
---|
| 173 | fi
|
---|
| 174 | #AC_MSG_NOTICE([$molecuilder_version_proper])
|
---|
| 175 |
|
---|
| 176 | if test $molecuilder_version_proper = 1 ; then
|
---|
| 177 | molecuilder_version=yes
|
---|
| 178 | AC_MSG_RESULT([$molecuilder_major_version.$molecuilder_minor_version.$molecuilder_micro_version])
|
---|
| 179 | else
|
---|
| 180 | AC_MSG_RESULT(no)
|
---|
| 181 | molecuilder_version=no
|
---|
| 182 | fi
|
---|
| 183 | fi
|
---|
| 184 | else
|
---|
| 185 | # with pkg-config version is checked
|
---|
| 186 | molecuilder_version=yes
|
---|
| 187 | fi
|
---|
| 188 | # check presence of lib
|
---|
| 189 | SAVE_CPPFLAGS="$CPPFLAGS"
|
---|
| 190 | SAVE_LIBS="$LIBS"
|
---|
| 191 | CPPFLAGS="$MoleCuilder_CFLAGS"
|
---|
| 192 | LIBS="$MoleCuilder_LIBS -lboost_thread"
|
---|
| 193 | if test x$molecuilder_version = xyes; then
|
---|
| 194 | AC_CACHE_CHECK(for $molecuilder_libname lib, cp_cv_molecuilder_lib, [
|
---|
| 195 | AC_LANG_PUSH([C++])
|
---|
| 196 | AC_LINK_IFELSE(
|
---|
| 197 | [
|
---|
| 198 | AC_LANG_PROGRAM([
|
---|
| 199 | #include "LinearAlgebra/Vector.hpp"
|
---|
| 200 | ], [
|
---|
| 201 | Vector test;
|
---|
| 202 | test.Norm();
|
---|
| 203 | ])
|
---|
| 204 | ],[
|
---|
| 205 | cp_cv_molecuilder_lib="yes"
|
---|
| 206 | ], [
|
---|
| 207 | cp_cv_molecuilder_lib="no"
|
---|
| 208 | ]
|
---|
| 209 | )
|
---|
| 210 | AC_LANG_POP([C++])
|
---|
| 211 | ])
|
---|
| 212 | fi
|
---|
| 213 | CPPFLAGS="$SAVE_CPPFLAGS"
|
---|
| 214 | LIBS="$SAVE_LIBS"
|
---|
| 215 |
|
---|
| 216 | if test "x$cp_cv_molecuilder_lib" = xyes ; then
|
---|
| 217 | ifelse([$3], , :, [$3])
|
---|
| 218 | else
|
---|
| 219 | MoleCuilder_CFLAGS=""
|
---|
| 220 | MoleCuilder_LDFLAGS=""
|
---|
| 221 | MoleCuilder_LIBS=""
|
---|
| 222 | ifelse([$4], , :, [$4])
|
---|
| 223 | fi
|
---|
| 224 |
|
---|
| 225 | AC_SUBST(MoleCuilder_CFLAGS)
|
---|
| 226 | AC_SUBST(MoleCuilder_LDFLAGS)
|
---|
| 227 | AC_SUBST(MoleCuilder_LIBS)
|
---|
| 228 | ])
|
---|
| 229 |
|
---|