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