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