[a0064e] | 1 | dnl
|
---|
| 2 | dnl AM_PATH_CODEPATTERNS(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
---|
| 3 | dnl
|
---|
| 4 |
|
---|
| 5 | AC_DEFUN([AM_PATH_CODEPATTERNS],
|
---|
| 6 | [
|
---|
| 7 | AC_REQUIRE([AX_BOOST_THREAD])
|
---|
| 8 |
|
---|
| 9 | AC_ARG_WITH(codepatterns,[ --with-codepatterns=PFX Prefix where CodePatterns is installed (optional)],
|
---|
| 10 | codepatterns_prefix="$withval", codepatterns_prefix="")
|
---|
| 11 | AC_ARG_WITH(codepatterns_include,[ --with-codepatterns_include=INCLUDE Where CodePatterns' includes are installed (optional)],
|
---|
| 12 | codepatterns_include_prefix="$withval", codepatterns_include_prefix="")
|
---|
| 13 | AC_ARG_WITH(cp_cv_codepatterns_libs,[ --with-cp_cv_codepatterns_libs=LIBPATH Where CodePatterns' libs are installed (optional)],
|
---|
| 14 | cp_cv_codepatterns_libs_prefix="$withval", cp_cv_codepatterns_libs_prefix="")
|
---|
| 15 |
|
---|
| 16 | codepatterns_version_min=$1
|
---|
| 17 |
|
---|
| 18 | CodePatterns_CFLAGS=""
|
---|
| 19 | CodePatterns_LIBS=""
|
---|
| 20 | CodePatterns_LDFLAGS=""
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | codepatterns_pkgconfig=""
|
---|
| 24 | # try to set PKG_CONFIG_PATH
|
---|
| 25 | if test x$codepatterns_prefix != xno; then
|
---|
| 26 | if test -z $PKG_CONFIG_PATH; then
|
---|
| 27 | export PKG_CONFIG_PATH="$codepatterns_prefix/lib/pkgconfig/"
|
---|
| 28 | else
|
---|
| 29 | export PKG_CONFIG_PATH="$codepatterns_prefix/lib/pkgconfig/:$PKG_CONFIG_PATH"
|
---|
| 30 | fi
|
---|
| 31 | fi
|
---|
| 32 | # 1. test whether pkg-config works
|
---|
| 33 | CodePatterns_CONFIG=""
|
---|
| 34 | #AC_MSG_NOTICE([PKG_CONFIG_PATH is $PKG_CONFIG_PATH])
|
---|
| 35 | PKG_CHECK_MODULES([CodePatterns], [CodePatterns >= $codepatterns_version_min], [
|
---|
| 36 | codepatterns_pkgconfig=yes
|
---|
| 37 | CodePatterns_CONFIG="pkg-config CodePatterns"
|
---|
| 38 | ], [
|
---|
| 39 | # 2. if failed, test for binary codepatterns-config
|
---|
| 40 | AC_PATH_PROG(CodePatterns_CONFIG, codepatterns-config, no)
|
---|
| 41 | if test x$CodePatterns_CONFIG = xno && test x$codepatterns_prefix != x ; then
|
---|
| 42 | AC_MSG_CHECKING([for alternative codepatterns-config location])
|
---|
| 43 | if test -e $codepatterns_prefix/bin/codepatterns-config; then
|
---|
| 44 | codepatterns_pkgconfig=no
|
---|
| 45 | CodePatterns_CONFIG="$codepatterns_prefix/bin/codepatterns-config"
|
---|
| 46 | AC_MSG_RESULT([yes])
|
---|
| 47 | else
|
---|
| 48 | AC_MSG_RESULT([no])
|
---|
| 49 | fi
|
---|
| 50 | fi
|
---|
| 51 | ])
|
---|
| 52 |
|
---|
| 53 | # try to set values via CodePatterns_CONFIG
|
---|
| 54 | if test ! -z "$CodePatterns_CONFIG"; then
|
---|
| 55 | CodePatterns_CFLAGS=`$CodePatterns_CONFIG --cflags`
|
---|
| 56 | if test x$codepatterns_pkgconfig = xno; then
|
---|
| 57 | CodePatterns_LIBS=`$CodePatterns_CONFIG --ldflags --libs`
|
---|
| 58 | else
|
---|
| 59 | CodePatterns_LIBS=`$CodePatterns_CONFIG --libs`
|
---|
| 60 | fi
|
---|
| 61 | #AC_MSG_NOTICE([codepatterns-config found and used.])
|
---|
| 62 | fi
|
---|
| 63 |
|
---|
| 64 | # else set by hand (or rather by --with..)
|
---|
| 65 | if test x$codepatterns_include_prefix != x ; then
|
---|
| 66 | if test -e $codepatterns_include_prefix/include; then
|
---|
| 67 | CodePatterns_CFLAGS="$codepatterns_include_prefix/include"
|
---|
| 68 | AC_MSG_NOTICE([codepatterns include found and used.])
|
---|
| 69 | else
|
---|
| 70 | AC_MSG_WARN([codepatterns include not found at $codepatterns_include_prefix/include.])
|
---|
| 71 | fi
|
---|
| 72 | fi
|
---|
| 73 | if test x$cp_cv_codepatterns_libs_prefix != x ; then
|
---|
| 74 | if test -e "$cp_cv_codepatterns_libs_prefix/lib/libCodePatterns.so"; then
|
---|
| 75 | CodePatterns_LIBS="-L$cp_cv_codepatterns_libs_prefix/lib -lCodePatterns"
|
---|
| 76 | AC_MSG_NOTICE([codepatterns libs found and used.])
|
---|
| 77 | else
|
---|
| 78 | AC_MSG_WARN([codepatterns libs not found at $cp_cv_codepatterns_libs_prefix.])
|
---|
| 79 | fi
|
---|
| 80 | fi
|
---|
| 81 |
|
---|
| 82 | codepatterns="no"
|
---|
| 83 | if test "x$CodePatterns_CFLAGS" != "x"; then
|
---|
| 84 | if test "x$CodePatterns_LIBS" != "x"; then
|
---|
| 85 | codepatterns="yes"
|
---|
| 86 | fi
|
---|
| 87 | fi
|
---|
| 88 |
|
---|
| 89 |
|
---|
| 90 | if test x$codepatterns_pkgconfig != xyes; then
|
---|
| 91 | # check version of lib
|
---|
| 92 | no_codepatterns=""
|
---|
| 93 | codepatterns_version=no
|
---|
| 94 | if test x$codepatterns = xyes; then
|
---|
| 95 | AC_MSG_CHECKING(for CodePatterns - version >= $codepatterns_version_min)
|
---|
| 96 | if test "x$CodePatterns_CONFIG" != "x"; then
|
---|
| 97 | codepatterns_version=`$CodePatterns_CONFIG --version`
|
---|
| 98 | else
|
---|
| 99 | codepatterns_version=""
|
---|
| 100 | fi
|
---|
| 101 |
|
---|
| 102 | codepatterns_major_version=`echo $codepatterns_version | \
|
---|
| 103 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
---|
| 104 | codepatterns_minor_version=`echo $codepatterns_version | \
|
---|
| 105 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
---|
| 106 | codepatterns_micro_version=`echo $codepatterns_version | \
|
---|
| 107 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
---|
| 108 |
|
---|
| 109 | #AC_MSG_NOTICE([Version found is: $codepatterns_major_version.$codepatterns_minor_version.$codepatterns_micro_version])
|
---|
| 110 | #AC_MSG_NOTICE([Version required is: $codepatterns_version_min])
|
---|
| 111 |
|
---|
| 112 | codepatterns_major_min=`echo $codepatterns_version_min | \
|
---|
| 113 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
---|
| 114 | if test "x${codepatterns_major_min}" = "x" ; then
|
---|
| 115 | codepatterns_major_min=0
|
---|
| 116 | fi
|
---|
| 117 |
|
---|
| 118 | codepatterns_minor_min=`echo $codepatterns_version_min | \
|
---|
| 119 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
---|
| 120 | if test "x${codepatterns_minor_min}" = "x" ; then
|
---|
| 121 | codepatterns_minor_min=0
|
---|
| 122 | fi
|
---|
| 123 |
|
---|
| 124 | codepatterns_micro_min=`echo $codepatterns_version_min | \
|
---|
| 125 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
---|
| 126 | if test "x${codepatterns_micro_min}" = "x" ; then
|
---|
| 127 | codepatterns_micro_min=0
|
---|
| 128 | fi
|
---|
| 129 |
|
---|
| 130 | if test $codepatterns_major_version -lt $codepatterns_major_min; then
|
---|
| 131 | codepatterns_version_proper=0
|
---|
| 132 | fi
|
---|
| 133 | if test $codepatterns_major_version -gt $codepatterns_major_min; then
|
---|
| 134 | codepatterns_version_proper=1
|
---|
| 135 | else
|
---|
| 136 | if test $codepatterns_minor_version -lt $codepatterns_minor_min; then
|
---|
| 137 | codepatterns_version_proper=0
|
---|
| 138 | fi
|
---|
| 139 | if test $codepatterns_minor_version -gt $codepatterns_minor_min; then
|
---|
| 140 | codepatterns_version_proper=1
|
---|
| 141 | else
|
---|
| 142 | if test $codepatterns_micro_version -ge $codepatterns_micro_min; then
|
---|
| 143 | codepatterns_version_proper=1
|
---|
| 144 | else
|
---|
| 145 | codepatterns_version_proper=0
|
---|
| 146 | fi
|
---|
| 147 | fi
|
---|
| 148 | fi
|
---|
| 149 | #AC_MSG_NOTICE([$codepatterns_version_proper])
|
---|
| 150 |
|
---|
| 151 | if test $codepatterns_version_proper = 1 ; then
|
---|
| 152 | codepatterns_version=yes
|
---|
| 153 | AC_MSG_RESULT([$codepatterns_major_version.$codepatterns_minor_version.$codepatterns_micro_version])
|
---|
| 154 | else
|
---|
| 155 | AC_MSG_RESULT(no)
|
---|
| 156 | codepatterns_version=no
|
---|
| 157 | fi
|
---|
| 158 | fi
|
---|
| 159 |
|
---|
| 160 | # check presence of lib
|
---|
| 161 | SAVE_CPPFLAGS="$CPPFLAGS"
|
---|
| 162 | SAVE_LIBS="$LIBS"
|
---|
| 163 | CPPFLAGS="$CodePatterns_CFLAGS"
|
---|
| 164 | LIBS="$CodePatterns_LIBS -lboost_thread"
|
---|
| 165 | if test x$codepatterns_version = xyes; then
|
---|
| 166 | AC_CACHE_CHECK(for CodePatterns lib, cp_cv_codepatterns_lib, [
|
---|
| 167 | AC_LANG_PUSH([C++])
|
---|
| 168 | AC_LINK_IFELSE(
|
---|
| 169 | [
|
---|
| 170 | AC_LANG_PROGRAM([
|
---|
[ad011c] | 171 | #include "CodePatterns/Singleton.hpp"
|
---|
| 172 | #include "CodePatterns/Singleton_impl.hpp"
|
---|
[a0064e] | 173 |
|
---|
| 174 | // some necessary stubs
|
---|
| 175 | class SingletonStub : public Singleton <SingletonStub>{
|
---|
| 176 | friend class Singleton<SingletonStub>;
|
---|
| 177 | private:
|
---|
| 178 | SingletonStub(){
|
---|
| 179 | count1++;
|
---|
| 180 | }
|
---|
| 181 | // explicit copy constructor to catch if this is ever called
|
---|
| 182 | SingletonStub(const SingletonStub&){}
|
---|
| 183 | virtual ~SingletonStub(){
|
---|
| 184 | count2++;
|
---|
| 185 | }
|
---|
| 186 | public:
|
---|
| 187 | static int count1;
|
---|
| 188 | static int count2;
|
---|
| 189 | };
|
---|
| 190 |
|
---|
| 191 | int SingletonStub::count1 = 0;
|
---|
| 192 | int SingletonStub::count2 = 0;
|
---|
| 193 |
|
---|
| 194 | CONSTRUCT_SINGLETON(SingletonStub);
|
---|
| 195 |
|
---|
| 196 | ], [
|
---|
| 197 | SingletonStub::getInstance();
|
---|
| 198 | ])
|
---|
| 199 | ],[
|
---|
| 200 | cp_cv_codepatterns_lib="yes"
|
---|
| 201 | ], [
|
---|
| 202 | cp_cv_codepatterns_lib="no"
|
---|
| 203 | ]
|
---|
| 204 | )
|
---|
| 205 | AC_LANG_POP([C++])
|
---|
| 206 | ])
|
---|
| 207 | fi
|
---|
| 208 | CPPFLAGS="$SAVE_CPPFLAGS"
|
---|
| 209 | LIBS="$SAVE_LIBS"
|
---|
| 210 |
|
---|
| 211 | if test "x$cp_cv_codepatterns_lib" = xyes ; then
|
---|
| 212 | ifelse([$2], , :, [$2])
|
---|
| 213 | else
|
---|
| 214 | CodePatterns_CFLAGS=""
|
---|
| 215 | CodePatterns_LDFLAGS=""
|
---|
| 216 | CodePatterns_LIBS=""
|
---|
| 217 | ifelse([$3], , :, [$3])
|
---|
| 218 | fi
|
---|
| 219 | fi
|
---|
| 220 |
|
---|
| 221 | AC_SUBST(CodePatterns_CFLAGS)
|
---|
| 222 | AC_SUBST(CodePatterns_LDFLAGS)
|
---|
| 223 | AC_SUBST(CodePatterns_LIBS)
|
---|
| 224 | ])
|
---|
| 225 |
|
---|