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