source: m4/ax_codepatterns.m4@ d90061f

Last change on this file since d90061f was 451f17, checked in by Frederik Heber <heber@…>, 14 years ago

Fixing distcheck and some errors from boost.m4 switch-over.

  • all .m4 files are listed under EXTRA_DIST.
  • ax_codepatterns.m4 now requires BOOST_THREADS by Tsuna's boost.m4.
  • fixed some wrong shell variables with boost.m4' change: LIB -> LIBS
  • added so far missing cppunit.m4 to repository.
  • Property mode set to 100644
File size: 8.3 KB
RevLine 
[115378]1dnl
[392a79]2dnl AM_PATH_CODEPATTERNS(MINIMUM-VERSION, [HAVE_DEBUG=no,yes,full], [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
[115378]3dnl
4
5AC_DEFUN([AM_PATH_CODEPATTERNS],
6[
[451f17]7AC_REQUIRE([BOOST_THREADS])
[115378]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
[cdf2e4]17 codepatterns_debug=$2
[115378]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
[392a79]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
[115378]32 fi
33 # 1. test whether pkg-config works
[cdf2e4]34 CodePatterns_CONFIG="no"
[392a79]35 #AC_MSG_NOTICE([PKG_CONFIG_PATH is $PKG_CONFIG_PATH.])
36 if test x$codepatterns_debug != xno; then
[cdf2e4]37 codepatterns_libname="CodePatterns-debug"
38 PKG_CHECK_MODULES([CodePatterns_debug], [CodePatterns >= $codepatterns_version_min], [
[115378]39 codepatterns_pkgconfig=yes
[cdf2e4]40 CodePatterns_CONFIG="pkg-config $codepatterns_libname"
[115378]41 ], [
42 # 2. if failed, test for binary codepatterns-config
43 AC_PATH_PROG(CodePatterns_CONFIG, codepatterns-config, no)
[cdf2e4]44 if test "x$CodePatterns_CONFIG" = xno && test x$codepatterns_prefix != x ; then
[115378]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
[cdf2e4]50 ])
51
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
[392a79]61 AC_MSG_CHECKING([for alternative codepatterns-config location])
[cdf2e4]62 if test -e $codepatterns_prefix/bin/codepatterns-config; then
63 codepatterns_pkgconfig=no
64 CodePatterns_CONFIG="$codepatterns_prefix/bin/codepatterns-config"
[392a79]65 AC_MSG_RESULT([yes])
66 else
67 AC_MSG_RESULT([no])
[cdf2e4]68 fi
69 fi
70 ])
71
72 fi
[115378]73
74 # try to set values via CodePatterns_CONFIG
[cdf2e4]75 if test "x$CodePatterns_CONFIG" != xno; then
[115378]76 CodePatterns_CFLAGS=`$CodePatterns_CONFIG --cflags`
[392a79]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.])
[115378]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"
[392a79]89 #AC_MSG_NOTICE([codepatterns include found and used.])
[115378]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
[cdf2e4]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"
[392a79]97 #AC_MSG_NOTICE([codepatterns libs found and used.])
[115378]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
[cdf2e4]116 AC_MSG_CHECKING(for $codepatterns_libname - version >= $codepatterns_version_min)
117 if test "x$CodePatterns_CONFIG" != xno; then
[115378]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
[392a79]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"
187 CPPFLAGS="$CodePatterns_CFLAGS"
188 LIBS="$CodePatterns_LIBS -lboost_thread"
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([
195#include "CodePatterns/Singleton.hpp"
196#include "CodePatterns/Singleton_impl.hpp"
[115378]197
198// some necessary stubs
199class SingletonStub : public Singleton <SingletonStub>{
200 friend class Singleton<SingletonStub>;
201private:
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 }
210public:
211 static int count1;
212 static int count2;
213};
214
215int SingletonStub::count1 = 0;
216int SingletonStub::count2 = 0;
217
218CONSTRUCT_SINGLETON(SingletonStub);
219
220], [
221SingletonStub::getInstance();
222])
[392a79]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"
[115378]234
[392a79]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])
[115378]242 fi
243
244 AC_SUBST(CodePatterns_CFLAGS)
245 AC_SUBST(CodePatterns_LDFLAGS)
246 AC_SUBST(CodePatterns_LIBS)
247])
248
Note: See TracBrowser for help on using the repository browser.