Index: m4/ax_codepatterns.m4
===================================================================
--- m4/ax_codepatterns.m4	(revision ad011c5ac0c9bfcf699f41ee11dd4a8aa0abb89a)
+++ m4/ax_codepatterns.m4	(revision dc031cb33b9d55462239994b557d00d9554e07f7)
@@ -1,4 +1,4 @@
 dnl
-dnl AM_PATH_CODEPATTERNS(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
+dnl AM_PATH_CODEPATTERNS(MINIMUM-VERSION, [HAVE_DEBUG=no,yes,full], [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
 dnl
 
@@ -15,4 +15,5 @@
 
   codepatterns_version_min=$1
+  codepatterns_debug=$2
 
   CodePatterns_CFLAGS=""
@@ -31,13 +32,15 @@
   fi
   # 1. test whether pkg-config works
-  CodePatterns_CONFIG=""
-  #AC_MSG_NOTICE([PKG_CONFIG_PATH is $PKG_CONFIG_PATH])
-  PKG_CHECK_MODULES([CodePatterns], [CodePatterns >= $codepatterns_version_min], [
+  CodePatterns_CONFIG="no"
+  #AC_MSG_NOTICE([PKG_CONFIG_PATH is $PKG_CONFIG_PATH.])
+  if test x$codepatterns_debug != xno; then
+    codepatterns_libname="CodePatterns-debug"
+    PKG_CHECK_MODULES([CodePatterns_debug], [CodePatterns >= $codepatterns_version_min], [
       codepatterns_pkgconfig=yes
-      CodePatterns_CONFIG="pkg-config CodePatterns"
+      CodePatterns_CONFIG="pkg-config $codepatterns_libname"
     ], [
     # 2. if failed, test for binary codepatterns-config
       AC_PATH_PROG(CodePatterns_CONFIG, codepatterns-config, no)
-      if test x$CodePatterns_CONFIG = xno && test x$codepatterns_prefix != x ; then
+      if test "x$CodePatterns_CONFIG" = xno && test x$codepatterns_prefix != x ; then
         AC_MSG_CHECKING([for alternative codepatterns-config location])
         if test -e $codepatterns_prefix/bin/codepatterns-config; then
@@ -51,6 +54,28 @@
     ])
 
+  else
+    codepatterns_libname="CodePatterns"
+    PKG_CHECK_MODULES([CodePatterns], [CodePatterns >= $codepatterns_version_min], [
+      codepatterns_pkgconfig=yes
+      CodePatterns_CONFIG="pkg-config $codepatterns_libname"
+    ], [
+    # 2. if failed, test for binary codepatterns-config
+      AC_PATH_PROG(CodePatterns_CONFIG, codepatterns-config, no)
+      if test "x$CodePatterns_CONFIG" = xno && test x$codepatterns_prefix != x ; then
+        AC_MSG_CHECKING([for alternative codepatterns-config location])
+        if test -e $codepatterns_prefix/bin/codepatterns-config; then
+          codepatterns_pkgconfig=no
+          CodePatterns_CONFIG="$codepatterns_prefix/bin/codepatterns-config"
+          AC_MSG_RESULT([yes])
+        else
+          AC_MSG_RESULT([no])
+        fi
+      fi
+    ])
+
+  fi
+
   # try to set values via CodePatterns_CONFIG
-  if test ! -z "$CodePatterns_CONFIG"; then 
+  if test "x$CodePatterns_CONFIG" != xno; then 
     CodePatterns_CFLAGS=`$CodePatterns_CONFIG --cflags`
     if test x$codepatterns_pkgconfig = xno; then
@@ -66,5 +91,5 @@
     if test -e $codepatterns_include_prefix/include; then
       CodePatterns_CFLAGS="$codepatterns_include_prefix/include"
-      AC_MSG_NOTICE([codepatterns include found and used.])
+      #AC_MSG_NOTICE([codepatterns include found and used.])
     else
       AC_MSG_WARN([codepatterns include not found at $codepatterns_include_prefix/include.])
@@ -72,7 +97,7 @@
   fi
   if test x$cp_cv_codepatterns_libs_prefix != x ; then
-    if test -e "$cp_cv_codepatterns_libs_prefix/lib/libCodePatterns.so"; then
-      CodePatterns_LIBS="-L$cp_cv_codepatterns_libs_prefix/lib -lCodePatterns"
-      AC_MSG_NOTICE([codepatterns libs found and used.])
+    if test -e "$cp_cv_codepatterns_libs_prefix/lib/lib$codepatterns_libname.so"; then
+      CodePatterns_LIBS="-L$cp_cv_codepatterns_libs_prefix/lib -l$codepatterns_libname"
+      #AC_MSG_NOTICE([codepatterns libs found and used.])
     else
       AC_MSG_WARN([codepatterns libs not found at $cp_cv_codepatterns_libs_prefix.])
@@ -93,6 +118,6 @@
     codepatterns_version=no
     if test x$codepatterns = xyes; then
-      AC_MSG_CHECKING(for CodePatterns - version >= $codepatterns_version_min)
-      if test "x$CodePatterns_CONFIG" != "x"; then
+      AC_MSG_CHECKING(for $codepatterns_libname - version >= $codepatterns_version_min)
+      if test "x$CodePatterns_CONFIG" != xno; then
         codepatterns_version=`$CodePatterns_CONFIG --version`
       else
@@ -157,16 +182,19 @@
       fi
     fi
-
-    # check presence of lib
-    SAVE_CPPFLAGS="$CPPFLAGS"
-    SAVE_LIBS="$LIBS"
-    CPPFLAGS="$CodePatterns_CFLAGS"
-    LIBS="$CodePatterns_LIBS -lboost_thread"
-    if test x$codepatterns_version = xyes; then
-      AC_CACHE_CHECK(for CodePatterns lib, cp_cv_codepatterns_lib, [
-        AC_LANG_PUSH([C++])
-        AC_LINK_IFELSE(
-          [
-            AC_LANG_PROGRAM([
+  else
+    # with pkg-config version is checked
+    codepatterns_version=yes
+  fi
+  # check presence of lib
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  SAVE_LIBS="$LIBS"
+  CPPFLAGS="$CodePatterns_CFLAGS"
+  LIBS="$CodePatterns_LIBS -lboost_thread"
+  if test x$codepatterns_version = xyes; then
+    AC_CACHE_CHECK(for $codepatterns_libname lib, cp_cv_codepatterns_lib, [
+      AC_LANG_PUSH([C++])
+      AC_LINK_IFELSE(
+        [
+          AC_LANG_PROGRAM([
 #include "CodePatterns/Singleton.hpp"
 #include "CodePatterns/Singleton_impl.hpp"
@@ -197,24 +225,23 @@
 SingletonStub::getInstance();
 ])
-          ],[
-            cp_cv_codepatterns_lib="yes"
-          ], [
-            cp_cv_codepatterns_lib="no"
-          ]
-        )
-        AC_LANG_POP([C++])
-      ])
-    fi
-    CPPFLAGS="$SAVE_CPPFLAGS"
-    LIBS="$SAVE_LIBS"
-
-    if test "x$cp_cv_codepatterns_lib" = xyes ; then
-       ifelse([$2], , :, [$2])     
-    else
-       CodePatterns_CFLAGS=""
-       CodePatterns_LDFLAGS=""
-       CodePatterns_LIBS=""
-       ifelse([$3], , :, [$3])
-    fi
+        ],[
+          cp_cv_codepatterns_lib="yes"
+        ], [
+          cp_cv_codepatterns_lib="no"
+        ]
+      )
+      AC_LANG_POP([C++])
+    ])
+  fi
+  CPPFLAGS="$SAVE_CPPFLAGS"
+  LIBS="$SAVE_LIBS"
+
+  if test "x$cp_cv_codepatterns_lib" = xyes ; then
+    ifelse([$3], , :, [$3])
+  else
+     CodePatterns_CFLAGS=""
+     CodePatterns_LDFLAGS=""
+     CodePatterns_LIBS=""
+     ifelse([$4], , :, [$4])
   fi
   
