source: m4/ax_codepatterns.m4@ cdf2e4

Last change on this file since cdf2e4 was cdf2e4, checked in by Frederik Heber <heber@…>, 15 years ago

From now on we create two libs, one with and one without debug.

  • We specifically create two libs, as the debug one is not just the old lib but with some debug symbols. MemDebug, Asserts and ObserverLog implementations are clearly missing in these. This justifies to have two distinct (in an odd way) libraries.
  • additional CodePattern-debug.pc file
  • extended ax_codepatterns.m4 macro to have debug as an extra argument
  • Property mode set to 100644
File size: 7.9 KB
Line 
1dnl
2dnl AM_PATH_CODEPATTERNS(MINIMUM-VERSION, [no]debug, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
3dnl
4
5AC_DEFUN([AM_PATH_CODEPATTERNS],
6[
7AC_REQUIRE([AX_BOOST_THREAD])
8
9AC_ARG_WITH(codepatterns,[ --with-codepatterns=PFX Prefix where CodePatterns is installed (optional)],
10 codepatterns_prefix="$withval", codepatterns_prefix="")
11AC_ARG_WITH(codepatterns_include,[ --with-codepatterns_include=INCLUDE Where CodePatterns' includes are installed (optional)],
12 codepatterns_include_prefix="$withval", codepatterns_include_prefix="")
13AC_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 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 PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$codepatterns_prefix/lib/pkgconfig/"
28 fi
29 # 1. test whether pkg-config works
30 CodePatterns_CONFIG="no"
31 #AC_MSG_NOTICE([PKG_CONFIG_PATH is $PKG_CONFIG_PATH])
32 if test x$codepatterns_debug != x0; then
33 codepatterns_libname="CodePatterns-debug"
34 PKG_CHECK_MODULES([CodePatterns_debug], [CodePatterns >= $codepatterns_version_min], [
35 codepatterns_pkgconfig=yes
36 CodePatterns_CONFIG="pkg-config $codepatterns_libname"
37 ], [
38 # 2. if failed, test for binary codepatterns-config
39 AC_PATH_PROG(CodePatterns_CONFIG, codepatterns-config, no)
40 if test "x$CodePatterns_CONFIG" = xno && test x$codepatterns_prefix != x ; then
41 if test -e $codepatterns_prefix/bin/codepatterns-config; then
42 codepatterns_pkgconfig=no
43 CodePatterns_CONFIG="$codepatterns_prefix/bin/codepatterns-config"
44 fi
45 fi
46 ])
47
48 else
49 codepatterns_libname="CodePatterns"
50 PKG_CHECK_MODULES([CodePatterns], [CodePatterns >= $codepatterns_version_min], [
51 codepatterns_pkgconfig=yes
52 CodePatterns_CONFIG="pkg-config $codepatterns_libname"
53 ], [
54 # 2. if failed, test for binary codepatterns-config
55 AC_PATH_PROG(CodePatterns_CONFIG, codepatterns-config, no)
56 if test "x$CodePatterns_CONFIG" = xno && test x$codepatterns_prefix != x ; then
57 if test -e $codepatterns_prefix/bin/codepatterns-config; then
58 codepatterns_pkgconfig=no
59 CodePatterns_CONFIG="$codepatterns_prefix/bin/codepatterns-config"
60 fi
61 fi
62 ])
63
64 fi
65
66 # try to set values via CodePatterns_CONFIG
67 if test "x$CodePatterns_CONFIG" != xno; then
68 CodePatterns_CFLAGS=`$CodePatterns_CONFIG --cflags`
69 CodePatterns_LIBS=`$CodePatterns_CONFIG --libs`
70 AC_MSG_NOTICE([codepatterns-config found and used.])
71 fi
72
73 # else set by hand (or rather by --with..)
74 if test x$codepatterns_include_prefix != x ; then
75 if test -e $codepatterns_include_prefix/include; then
76 CodePatterns_CFLAGS="$codepatterns_include_prefix/include"
77 AC_MSG_NOTICE([codepatterns include found and used.])
78 else
79 AC_MSG_WARN([codepatterns include not found at $codepatterns_include_prefix/include.])
80 fi
81 fi
82 if test x$cp_cv_codepatterns_libs_prefix != x ; then
83 if test -e "$cp_cv_codepatterns_libs_prefix/lib/lib$codepatterns_libname.so"; then
84 CodePatterns_LIBS="-L$cp_cv_codepatterns_libs_prefix/lib -l$codepatterns_libname"
85 AC_MSG_NOTICE([codepatterns libs found and used.])
86 else
87 AC_MSG_WARN([codepatterns libs not found at $cp_cv_codepatterns_libs_prefix.])
88 fi
89 fi
90
91 codepatterns="no"
92 if test "x$CodePatterns_CFLAGS" != "x"; then
93 if test "x$CodePatterns_LIBS" != "x"; then
94 codepatterns="yes"
95 fi
96 fi
97
98
99 if test x$codepatterns_pkgconfig != xyes; then
100 # check version of lib
101 no_codepatterns=""
102 codepatterns_version=no
103 if test x$codepatterns = xyes; then
104 AC_MSG_CHECKING(for $codepatterns_libname - version >= $codepatterns_version_min)
105 if test "x$CodePatterns_CONFIG" != xno; then
106 codepatterns_version=`$CodePatterns_CONFIG --version`
107 else
108 codepatterns_version=""
109 fi
110
111 codepatterns_major_version=`echo $codepatterns_version | \
112 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
113 codepatterns_minor_version=`echo $codepatterns_version | \
114 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
115 codepatterns_micro_version=`echo $codepatterns_version | \
116 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
117
118 #AC_MSG_NOTICE([Version found is: $codepatterns_major_version.$codepatterns_minor_version.$codepatterns_micro_version])
119 #AC_MSG_NOTICE([Version required is: $codepatterns_version_min])
120
121 codepatterns_major_min=`echo $codepatterns_version_min | \
122 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
123 if test "x${codepatterns_major_min}" = "x" ; then
124 codepatterns_major_min=0
125 fi
126
127 codepatterns_minor_min=`echo $codepatterns_version_min | \
128 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
129 if test "x${codepatterns_minor_min}" = "x" ; then
130 codepatterns_minor_min=0
131 fi
132
133 codepatterns_micro_min=`echo $codepatterns_version_min | \
134 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
135 if test "x${codepatterns_micro_min}" = "x" ; then
136 codepatterns_micro_min=0
137 fi
138
139 if test $codepatterns_major_version -lt $codepatterns_major_min; then
140 codepatterns_version_proper=0
141 fi
142 if test $codepatterns_major_version -gt $codepatterns_major_min; then
143 codepatterns_version_proper=1
144 else
145 if test $codepatterns_minor_version -lt $codepatterns_minor_min; then
146 codepatterns_version_proper=0
147 fi
148 if test $codepatterns_minor_version -gt $codepatterns_minor_min; then
149 codepatterns_version_proper=1
150 else
151 if test $codepatterns_micro_version -ge $codepatterns_micro_min; then
152 codepatterns_version_proper=1
153 else
154 codepatterns_version_proper=0
155 fi
156 fi
157 fi
158 #AC_MSG_NOTICE([$codepatterns_version_proper])
159
160 if test $codepatterns_version_proper = 1 ; then
161 codepatterns_version=yes
162 AC_MSG_RESULT([$codepatterns_major_version.$codepatterns_minor_version.$codepatterns_micro_version])
163 else
164 AC_MSG_RESULT(no)
165 codepatterns_version=no
166 fi
167 fi
168
169 # check presence of lib
170 SAVE_CPPFLAGS="$CPPFLAGS"
171 SAVE_LIBS="$LIBS"
172 CPPFLAGS="$CodePatterns_CFLAGS"
173 LIBS="$CodePatterns_LIBS -lboost_thread"
174 if test x$codepatterns_version = xyes; then
175 AC_CACHE_CHECK(for $codepatterns_libname lib, cp_cv_codepatterns_lib, [
176 AC_LANG_PUSH([C++])
177 AC_LINK_IFELSE(
178 [
179 AC_LANG_PROGRAM([
180#include "Patterns/Singleton.hpp"
181#include "Patterns/Singleton_impl.hpp"
182
183// some necessary stubs
184class SingletonStub : public Singleton <SingletonStub>{
185 friend class Singleton<SingletonStub>;
186private:
187 SingletonStub(){
188 count1++;
189 }
190 // explicit copy constructor to catch if this is ever called
191 SingletonStub(const SingletonStub&){}
192 virtual ~SingletonStub(){
193 count2++;
194 }
195public:
196 static int count1;
197 static int count2;
198};
199
200int SingletonStub::count1 = 0;
201int SingletonStub::count2 = 0;
202
203CONSTRUCT_SINGLETON(SingletonStub);
204
205], [
206SingletonStub::getInstance();
207])
208 ],[
209 cp_cv_codepatterns_lib="yes"
210 ], [
211 cp_cv_codepatterns_lib="no"
212 ]
213 )
214 AC_LANG_POP([C++])
215 ])
216 fi
217 CPPFLAGS="$SAVE_CPPFLAGS"
218 LIBS="$SAVE_LIBS"
219
220 if test "x$cp_cv_codepatterns_lib" = xyes ; then
221 ifelse([$3], , :, [$3])
222 else
223 CodePatterns_CFLAGS=""
224 CodePatterns_LDFLAGS=""
225 CodePatterns_LIBS=""
226 ifelse([$4], , :, [$4])
227 fi
228 fi
229
230 AC_SUBST(CodePatterns_CFLAGS)
231 AC_SUBST(CodePatterns_LDFLAGS)
232 AC_SUBST(CodePatterns_LIBS)
233])
234
Note: See TracBrowser for help on using the repository browser.