source: m4/ax_codepatterns.m4@ 70672e3

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

Changes to allow for (re-)incorporation of CodePatterns into MoleCuilder.

library:

  • no more suffixed with version, this should be dealt by pkg-config (.pc) or a contained version information.
  • corrected and extended .pc file
  • m4 macro ax_codepatterns.m4 created to allow for easy checking with autotools

codepatterns-config:

  • if pkg-config fails there is a small tool that tells about necessary cflags and the likes to compile with CodePatterns library (this was developed before we noticed we had a (half-)working pkg-config present).

smaller changes:

  • moved all Helpers files to src/Helpers (again).
  • changed include paths for Assert.hpp, ... accordingly.
  • version is not prefixed with "v" anymore.
  • small stuff in fast_functions.hpp is absolete (stl::algorithms)
  • Helpers/enumeration.hpp contains enumeration class ("iterable enum")
  • Property mode set to 100644
File size: 7.1 KB
RevLine 
[115378]1dnl
2dnl AM_PATH_CODEPATTERNS(MINIMUM-VERSION, [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
18 CodePatterns_CFLAGS=""
19 CodePatterns_LIBS=""
20 CodePatterns_LDFLAGS=""
21
22
23 codepatterns_pkgconfig=""
24 # try to set PKG_CONFIG_PATH
25 if test x$codepatterns_prefix != xno; then
26 PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$codepatterns_prefix/lib/pkgconfig/"
27 fi
28 # 1. test whether pkg-config works
29 CodePatterns_CONFIG=""
30 #AC_MSG_NOTICE([PKG_CONFIG_PATH is $PKG_CONFIG_PATH])
31 PKG_CHECK_MODULES([CodePatterns], [CodePatterns >= $codepatterns_version_min], [
32 codepatterns_pkgconfig=yes
33 CodePatterns_CONFIG="pkg-config CodePatterns"
34 ], [
35 # 2. if failed, test for binary codepatterns-config
36 AC_PATH_PROG(CodePatterns_CONFIG, codepatterns-config, no)
37 if test x$CodePatterns_CONFIG = xno && test x$codepatterns_prefix != x ; then
38 if test -e $codepatterns_prefix/bin/codepatterns-config; then
39 codepatterns_pkgconfig=no
40 CodePatterns_CONFIG="$codepatterns_prefix/bin/codepatterns-config"
41 fi
42 fi
43 ]
44 )
45
46 # try to set values via CodePatterns_CONFIG
47 if test ! -z "$CodePatterns_CONFIG"; then
48 CodePatterns_CFLAGS=`$CodePatterns_CONFIG --cflags`
49 CodePatterns_LIBS=`$CodePatterns_CONFIG --libs`
50 AC_MSG_NOTICE([codepatterns-config found and used.])
51 fi
52
53 # else set by hand (or rather by --with..)
54 if test x$codepatterns_include_prefix != x ; then
55 if test -e $codepatterns_include_prefix/include; then
56 CodePatterns_CFLAGS="$codepatterns_include_prefix/include"
57 AC_MSG_NOTICE([codepatterns include found and used.])
58 else
59 AC_MSG_WARN([codepatterns include not found at $codepatterns_include_prefix/include.])
60 fi
61 fi
62 if test x$cp_cv_codepatterns_libs_prefix != x ; then
63 if test -e "$cp_cv_codepatterns_libs_prefix/lib/libCodePatterns.so"; then
64 CodePatterns_LIBS="-L$cp_cv_codepatterns_libs_prefix/lib -lCodePatterns"
65 AC_MSG_NOTICE([codepatterns libs found and used.])
66 else
67 AC_MSG_WARN([codepatterns libs not found at $cp_cv_codepatterns_libs_prefix.])
68 fi
69 fi
70
71 codepatterns="no"
72 if test "x$CodePatterns_CFLAGS" != "x"; then
73 if test "x$CodePatterns_LIBS" != "x"; then
74 codepatterns="yes"
75 fi
76 fi
77
78
79 if test x$codepatterns_pkgconfig != xyes; then
80 # check version of lib
81 no_codepatterns=""
82 codepatterns_version=no
83 if test x$codepatterns = xyes; then
84 AC_MSG_CHECKING(for CodePatterns - version >= $codepatterns_version_min)
85 if test "x$CodePatterns_CONFIG" != "x"; then
86 codepatterns_version=`$CodePatterns_CONFIG --version`
87 else
88 codepatterns_version=""
89 fi
90
91 codepatterns_major_version=`echo $codepatterns_version | \
92 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
93 codepatterns_minor_version=`echo $codepatterns_version | \
94 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
95 codepatterns_micro_version=`echo $codepatterns_version | \
96 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
97
98 #AC_MSG_NOTICE([Version found is: $codepatterns_major_version.$codepatterns_minor_version.$codepatterns_micro_version])
99 #AC_MSG_NOTICE([Version required is: $codepatterns_version_min])
100
101 codepatterns_major_min=`echo $codepatterns_version_min | \
102 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
103 if test "x${codepatterns_major_min}" = "x" ; then
104 codepatterns_major_min=0
105 fi
106
107 codepatterns_minor_min=`echo $codepatterns_version_min | \
108 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
109 if test "x${codepatterns_minor_min}" = "x" ; then
110 codepatterns_minor_min=0
111 fi
112
113 codepatterns_micro_min=`echo $codepatterns_version_min | \
114 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
115 if test "x${codepatterns_micro_min}" = "x" ; then
116 codepatterns_micro_min=0
117 fi
118
119 if test $codepatterns_major_version -lt $codepatterns_major_min; then
120 codepatterns_version_proper=0
121 fi
122 if test $codepatterns_major_version -gt $codepatterns_major_min; then
123 codepatterns_version_proper=1
124 else
125 if test $codepatterns_minor_version -lt $codepatterns_minor_min; then
126 codepatterns_version_proper=0
127 fi
128 if test $codepatterns_minor_version -gt $codepatterns_minor_min; then
129 codepatterns_version_proper=1
130 else
131 if test $codepatterns_micro_version -ge $codepatterns_micro_min; then
132 codepatterns_version_proper=1
133 else
134 codepatterns_version_proper=0
135 fi
136 fi
137 fi
138 #AC_MSG_NOTICE([$codepatterns_version_proper])
139
140 if test $codepatterns_version_proper = 1 ; then
141 codepatterns_version=yes
142 AC_MSG_RESULT([$codepatterns_major_version.$codepatterns_minor_version.$codepatterns_micro_version])
143 else
144 AC_MSG_RESULT(no)
145 codepatterns_version=no
146 fi
147 fi
148
149 # check presence of lib
150 SAVE_CPPFLAGS="$CPPFLAGS"
151 SAVE_LIBS="$LIBS"
152 CPPFLAGS="$CodePatterns_CFLAGS"
153 LIBS="$CodePatterns_LIBS -lboost_thread"
154 if test x$codepatterns_version = xyes; then
155 AC_CACHE_CHECK(for CodePatterns lib, cp_cv_codepatterns_lib, [
156 AC_LANG_PUSH([C++])
157 AC_LINK_IFELSE(
158 [
159 AC_LANG_PROGRAM([
160#include "Patterns/Singleton.hpp"
161#include "Patterns/Singleton_impl.hpp"
162
163// some necessary stubs
164class SingletonStub : public Singleton <SingletonStub>{
165 friend class Singleton<SingletonStub>;
166private:
167 SingletonStub(){
168 count1++;
169 }
170 // explicit copy constructor to catch if this is ever called
171 SingletonStub(const SingletonStub&){}
172 virtual ~SingletonStub(){
173 count2++;
174 }
175public:
176 static int count1;
177 static int count2;
178};
179
180int SingletonStub::count1 = 0;
181int SingletonStub::count2 = 0;
182
183CONSTRUCT_SINGLETON(SingletonStub);
184
185], [
186SingletonStub::getInstance();
187])
188 ],[
189 cp_cv_codepatterns_lib="yes"
190 ], [
191 cp_cv_codepatterns_lib="no"
192 ]
193 )
194 AC_LANG_POP([C++])
195 ])
196 fi
197 CPPFLAGS="$SAVE_CPPFLAGS"
198 LIBS="$SAVE_LIBS"
199
200 if test "x$cp_cv_codepatterns_lib" = xyes ; then
201 ifelse([$2], , :, [$2])
202 else
203 CodePatterns_CFLAGS=""
204 CodePatterns_LDFLAGS=""
205 CodePatterns_LIBS=""
206 ifelse([$3], , :, [$3])
207 fi
208 fi
209
210 AC_SUBST(CodePatterns_CFLAGS)
211 AC_SUBST(CodePatterns_LDFLAGS)
212 AC_SUBST(CodePatterns_LIBS)
213])
214
Note: See TracBrowser for help on using the repository browser.