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