1 | dnl
|
---|
2 | dnl AM_PATH_JOBMARKET(MINIMUM-VERSION, [HAVE_DEBUG=no,yes,full], [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
|
---|
3 | dnl
|
---|
4 |
|
---|
5 | AC_DEFUN([AM_PATH_JOBMARKET],
|
---|
6 | [
|
---|
7 | AC_REQUIRE([AM_PATH_CODEPATTERNS])
|
---|
8 | AC_REQUIRE([BOOST_THREADS])
|
---|
9 |
|
---|
10 | AC_ARG_WITH(jobmarket,[ --with-jobmarket=PFX Prefix where JobMarket is installed (optional)],
|
---|
11 | jobmarket_prefix="$withval", jobmarket_prefix="")
|
---|
12 | AC_ARG_WITH(jobmarket_include,[ --with-jobmarket_include=INCLUDE Where JobMarket' includes are installed (optional)],
|
---|
13 | jobmarket_include_prefix="$withval", jobmarket_include_prefix="")
|
---|
14 | AC_ARG_WITH(cp_cv_jobmarket_libs,[ --with-cp_cv_jobmarket_libs=LIBPATH Where JobMarket' libs are installed (optional)],
|
---|
15 | cp_cv_jobmarket_libs_prefix="$withval", cp_cv_jobmarket_libs_prefix="")
|
---|
16 |
|
---|
17 | jobmarket_version_min=$1
|
---|
18 | jobmarket_debug=$2
|
---|
19 |
|
---|
20 | JobMarket_CFLAGS=""
|
---|
21 | JobMarket_LIBS=""
|
---|
22 | JobMarket_Controller_LIBS=""
|
---|
23 | JobMarket_PoolWorker_LIBS=""
|
---|
24 | JobMarket_Server_LIBS=""
|
---|
25 | JobMarket_LDFLAGS=""
|
---|
26 |
|
---|
27 |
|
---|
28 | jobmarket_pkgconfig=""
|
---|
29 | # try to set PKG_CONFIG_PATH
|
---|
30 | if test x$jobmarket_prefix != xno; then
|
---|
31 | if test -z $PKG_CONFIG_PATH; then
|
---|
32 | export PKG_CONFIG_PATH="$jobmarket_prefix/lib/pkgconfig/"
|
---|
33 | else
|
---|
34 | export PKG_CONFIG_PATH="$jobmarket_prefix/lib/pkgconfig/:$PKG_CONFIG_PATH"
|
---|
35 | fi
|
---|
36 | fi
|
---|
37 | # 1. test whether pkg-config works
|
---|
38 | JobMarket_CONFIG="no"
|
---|
39 | #AC_MSG_NOTICE([PKG_CONFIG_PATH is $PKG_CONFIG_PATH.])
|
---|
40 | jobmarket_libname="JobMarket"
|
---|
41 | if test x$jobmarket_debug != xno; then
|
---|
42 | PKG_CHECK_MODULES([JobMarket_debug], [JobMarket >= $jobmarket_version_min], [
|
---|
43 | jobmarket_pkgconfig=yes
|
---|
44 | JobMarket_CONFIG="pkg-config ${jobmarket_libname}-debug"
|
---|
45 | ], [
|
---|
46 | jobmarket_pkgconfig=no
|
---|
47 | ])
|
---|
48 | PKG_CHECK_MODULES([JobMarketController_debug], [JobMarketController >= $jobmarket_version_min], [
|
---|
49 | jobmarketcontroller_pkgconfig=yes
|
---|
50 | JobMarketController_CONFIG="pkg-config ${jobmarket_libname}Controller-debug"
|
---|
51 | ], [
|
---|
52 | jobmarketcontroller_pkgconfig=no
|
---|
53 | ])
|
---|
54 | PKG_CHECK_MODULES([JobMarketPoolWorker_debug], [JobMarketPoolWorker >= $jobmarket_version_min], [
|
---|
55 | jobmarketpoolworker_pkgconfig=yes
|
---|
56 | JobMarketPoolWorker_CONFIG="pkg-config ${jobmarket_libname}PoolWorker-debug"
|
---|
57 | ], [
|
---|
58 | jobmarketpoolworker_pkgconfig=no
|
---|
59 | ])
|
---|
60 | PKG_CHECK_MODULES([JobMarketServer_debug], [JobMarketServer >= $jobmarket_version_min], [
|
---|
61 | jobmarketserver_pkgconfig=yes
|
---|
62 | JobMarketServer_CONFIG="pkg-config ${jobmarket_libname}Server-debug"
|
---|
63 | ], [
|
---|
64 | jobmarketserver_pkgconfig=no
|
---|
65 | ])
|
---|
66 | else
|
---|
67 | PKG_CHECK_MODULES([JobMarket], [JobMarket >= $jobmarket_version_min], [
|
---|
68 | jobmarket_pkgconfig=yes
|
---|
69 | JobMarket_CONFIG="pkg-config $jobmarket_libname"
|
---|
70 | ], [
|
---|
71 | jobmarket_pkgconfig=no
|
---|
72 | ])
|
---|
73 | PKG_CHECK_MODULES([JobMarketController], [JobMarketController >= $jobmarket_version_min], [
|
---|
74 | jobmarketcontroller_pkgconfig=yes
|
---|
75 | JobMarketController_CONFIG="pkg-config ${jobmarket_libname}Controller"
|
---|
76 | ], [
|
---|
77 | jobmarketcontroller_pkgconfig=no
|
---|
78 | ])
|
---|
79 | PKG_CHECK_MODULES([JobMarketPoolWorker], [JobMarketPoolWorker >= $jobmarket_version_min], [
|
---|
80 | jobmarketpoolworker_pkgconfig=yes
|
---|
81 | JobMarketPoolWorker_CONFIG="pkg-config ${jobmarket_libname}PoolWorker"
|
---|
82 | ], [
|
---|
83 | jobmarketpoolworker_pkgconfig=no
|
---|
84 | ])
|
---|
85 | PKG_CHECK_MODULES([JobMarketServer], [JobMarketServer >= $jobmarket_version_min], [
|
---|
86 | jobmarketserver_pkgconfig=yes
|
---|
87 | JobMarketServer_CONFIG="pkg-config ${jobmarket_libname}Server"
|
---|
88 | ], [
|
---|
89 | jobmarketserver_pkgconfig=no
|
---|
90 | ])
|
---|
91 | fi
|
---|
92 |
|
---|
93 |
|
---|
94 | if test x$jobmarket_pkgconfig != xno; then
|
---|
95 | JobMarket_CFLAGS=`$JobMarket_CONFIG --cflags`
|
---|
96 | JobMarket_LIBS=`$JobMarket_CONFIG --libs`
|
---|
97 | fi
|
---|
98 | if test x$jobmarketcontroller_pkgconfig != xno; then
|
---|
99 | JobMarket_Controller_LIBS=`$JobMarketController_CONFIG --libs`
|
---|
100 | fi
|
---|
101 | if test x$jobmarketpoolworker_pkgconfig != xno; then
|
---|
102 | JobMarket_PoolWorker_LIBS=`$JobMarketPoolWorker_CONFIG --libs`
|
---|
103 | fi
|
---|
104 | if test x$jobmarketserver_pkgconfig != xno; then
|
---|
105 | JobMarket_Server_LIBS=`$JobMarketServer_CONFIG --libs`
|
---|
106 | fi
|
---|
107 |
|
---|
108 | # else set by hand (or rather by --with..)
|
---|
109 | if test x$jobmarket_include_prefix != x ; then
|
---|
110 | if test -e $jobmarket_include_prefix/include; then
|
---|
111 | JobMarket_CFLAGS="$jobmarket_include_prefix/include"
|
---|
112 | #AC_MSG_NOTICE([jobmarket include found and used.])
|
---|
113 | else
|
---|
114 | AC_MSG_WARN([jobmarket include not found at $jobmarket_include_prefix/include.])
|
---|
115 | fi
|
---|
116 | fi
|
---|
117 | if test x$cp_cv_jobmarket_libs_prefix != x ; then
|
---|
118 | if test -e "$cp_cv_jobmarket_libs_prefix/lib/lib$jobmarket_libname.so"; then
|
---|
119 | JobMarket_LDFLAGS="-L$cp_cv_jobmarket_libs_prefix/lib"
|
---|
120 | JobMarket_LIBS="-l$jobmarket_libname"
|
---|
121 | JobMarket_Controller_LIBS="-l${jobmarket_libname}Controller"
|
---|
122 | JobMarket_PoolWorker_LIBS="-l${jobmarket_libname}PoolWorker"
|
---|
123 | JobMarket_Server_LIBS="-l${jobmarket_libname}Server"
|
---|
124 | #AC_MSG_NOTICE([jobmarket libs found and used.])
|
---|
125 | else
|
---|
126 | AC_MSG_WARN([jobmarket libs not found at $cp_cv_jobmarket_libs_prefix.])
|
---|
127 | fi
|
---|
128 | fi
|
---|
129 |
|
---|
130 | jobmarket="no"
|
---|
131 | if test "x$JobMarket_CFLAGS" != "x"; then
|
---|
132 | if test "x$JobMarket_LIBS" != "x"; then
|
---|
133 | jobmarket="yes"
|
---|
134 | fi
|
---|
135 | fi
|
---|
136 |
|
---|
137 |
|
---|
138 | if test x$jobmarket_pkgconfig != xyes; then
|
---|
139 | # check version of lib
|
---|
140 | no_jobmarket=""
|
---|
141 | jobmarket_version=no
|
---|
142 | if test x$jobmarket = xyes; then
|
---|
143 | AC_MSG_CHECKING(for $jobmarket_libname - version >= $jobmarket_version_min)
|
---|
144 | if test "x$JobMarket_CONFIG" != xno; then
|
---|
145 | jobmarket_version=`$JobMarket_CONFIG --version`
|
---|
146 | else
|
---|
147 | jobmarket_version=""
|
---|
148 | fi
|
---|
149 |
|
---|
150 | jobmarket_major_version=`echo $jobmarket_version | \
|
---|
151 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
---|
152 | jobmarket_minor_version=`echo $jobmarket_version | \
|
---|
153 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
---|
154 | jobmarket_micro_version=`echo $jobmarket_version | \
|
---|
155 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
---|
156 |
|
---|
157 | #AC_MSG_NOTICE([Version found is: $jobmarket_major_version.$jobmarket_minor_version.$jobmarket_micro_version])
|
---|
158 | #AC_MSG_NOTICE([Version required is: $jobmarket_version_min])
|
---|
159 |
|
---|
160 | jobmarket_major_min=`echo $jobmarket_version_min | \
|
---|
161 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
|
---|
162 | if test "x${jobmarket_major_min}" = "x" ; then
|
---|
163 | jobmarket_major_min=0
|
---|
164 | fi
|
---|
165 |
|
---|
166 | jobmarket_minor_min=`echo $jobmarket_version_min | \
|
---|
167 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
|
---|
168 | if test "x${jobmarket_minor_min}" = "x" ; then
|
---|
169 | jobmarket_minor_min=0
|
---|
170 | fi
|
---|
171 |
|
---|
172 | jobmarket_micro_min=`echo $jobmarket_version_min | \
|
---|
173 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
|
---|
174 | if test "x${jobmarket_micro_min}" = "x" ; then
|
---|
175 | jobmarket_micro_min=0
|
---|
176 | fi
|
---|
177 |
|
---|
178 | if test $jobmarket_major_version -lt $jobmarket_major_min; then
|
---|
179 | jobmarket_version_proper=0
|
---|
180 | fi
|
---|
181 | if test $jobmarket_major_version -gt $jobmarket_major_min; then
|
---|
182 | jobmarket_version_proper=1
|
---|
183 | else
|
---|
184 | if test $jobmarket_minor_version -lt $jobmarket_minor_min; then
|
---|
185 | jobmarket_version_proper=0
|
---|
186 | fi
|
---|
187 | if test $jobmarket_minor_version -gt $jobmarket_minor_min; then
|
---|
188 | jobmarket_version_proper=1
|
---|
189 | else
|
---|
190 | if test $jobmarket_micro_version -ge $jobmarket_micro_min; then
|
---|
191 | jobmarket_version_proper=1
|
---|
192 | else
|
---|
193 | jobmarket_version_proper=0
|
---|
194 | fi
|
---|
195 | fi
|
---|
196 | fi
|
---|
197 | #AC_MSG_NOTICE([$jobmarket_version_proper])
|
---|
198 |
|
---|
199 | if test $jobmarket_version_proper = 1 ; then
|
---|
200 | jobmarket_version=yes
|
---|
201 | AC_MSG_RESULT([$jobmarket_major_version.$jobmarket_minor_version.$jobmarket_micro_version])
|
---|
202 | else
|
---|
203 | AC_MSG_RESULT(no)
|
---|
204 | jobmarket_version=no
|
---|
205 | fi
|
---|
206 | fi
|
---|
207 | else
|
---|
208 | # with pkg-config version is checked
|
---|
209 | jobmarket_version=yes
|
---|
210 | fi
|
---|
211 | # check presence of lib
|
---|
212 | SAVE_CPPFLAGS="$CPPFLAGS"
|
---|
213 | SAVE_LIBS="$LIBS"
|
---|
214 | CPPFLAGS="$JobMarket_CFLAGS $CodePatterns_CFLAGS $BOOST_CPPFLAGS"
|
---|
215 | LIBS="$JobMarket_LIBS $CodePatterns_LIBS $BOOST_THREAD_LDFLAGS $BOOST_THREAD_LIBS"
|
---|
216 | if test x$jobmarket_version = xyes; then
|
---|
217 | AC_CACHE_CHECK(for $jobmarket_libname lib, cp_cv_jobmarket_lib, [
|
---|
218 | AC_LANG_PUSH([C++])
|
---|
219 | AC_LINK_IFELSE(
|
---|
220 | [
|
---|
221 | AC_LANG_PROGRAM([
|
---|
222 |
|
---|
223 | #include "CodePatterns/MemDebug.hpp"
|
---|
224 | #include "JobMarket/JobId.hpp"
|
---|
225 |
|
---|
226 | struct Test {
|
---|
227 | Test(size_t _id) :
|
---|
228 | id(_id)
|
---|
229 | {}
|
---|
230 |
|
---|
231 | size_t getId() const {
|
---|
232 | return id.getId();
|
---|
233 | }
|
---|
234 |
|
---|
235 | private:
|
---|
236 | JobId id;
|
---|
237 | } test(1);
|
---|
238 |
|
---|
239 | ], [
|
---|
240 | test.getId();
|
---|
241 | ])
|
---|
242 | ],[
|
---|
243 | cp_cv_jobmarket_lib="yes"
|
---|
244 | ], [
|
---|
245 | cp_cv_jobmarket_lib="no"
|
---|
246 | ]
|
---|
247 | )
|
---|
248 | AC_LANG_POP([C++])
|
---|
249 | ])
|
---|
250 | fi
|
---|
251 | CPPFLAGS="$SAVE_CPPFLAGS"
|
---|
252 | LIBS="$SAVE_LIBS"
|
---|
253 |
|
---|
254 | if test "x$cp_cv_jobmarket_lib" = xyes ; then
|
---|
255 | ifelse([$3], , :, [$3])
|
---|
256 | else
|
---|
257 | JobMarket_CFLAGS=""
|
---|
258 | JobMarket_LDFLAGS=""
|
---|
259 | JobMarket_LIBS=""
|
---|
260 | JobMarket_Controller_LIBS=""
|
---|
261 | JobMarket_PoolWorker_LIBS=""
|
---|
262 | JobMarket_Server_LIBS=""
|
---|
263 | ifelse([$4], , :, [$4])
|
---|
264 | fi
|
---|
265 |
|
---|
266 | AC_SUBST(JobMarket_CFLAGS)
|
---|
267 | AC_SUBST(JobMarket_LDFLAGS)
|
---|
268 | AC_SUBST(JobMarket_LIBS)
|
---|
269 | AC_SUBST(JobMarket_Controller_LIBS)
|
---|
270 | AC_SUBST(JobMarket_PoolWorker_LIBS)
|
---|
271 | AC_SUBST(JobMarket_Server_LIBS)
|
---|
272 | ])
|
---|
273 |
|
---|