1 | dnl synergy -- mouse and keyboard sharing utility
|
---|
2 | dnl Copyright (C) 2002 Chris Schoeneman
|
---|
3 | dnl
|
---|
4 | dnl This package is free software; you can redistribute it and/or
|
---|
5 | dnl modify it under the terms of the GNU General Public License
|
---|
6 | dnl found in the file COPYING that should have accompanied this file.
|
---|
7 | dnl
|
---|
8 | dnl This package is distributed in the hope that it will be useful,
|
---|
9 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
10 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
11 | dnl GNU General Public License for more details.
|
---|
12 |
|
---|
13 | AC_DEFUN([ACX_CHECK_SOCKLEN_T], [
|
---|
14 | AC_MSG_CHECKING([for socklen_t])
|
---|
15 | AC_TRY_COMPILE([
|
---|
16 | #include <unistd.h>
|
---|
17 | #include <sys/socket.h>
|
---|
18 | ],
|
---|
19 | [socklen_t len;],[acx_socklen_t_ok=yes],[acx_socklen_t_ok=no])
|
---|
20 | AC_MSG_RESULT($acx_socklen_t_ok)
|
---|
21 | if test x"$acx_socklen_t_ok" = xyes; then
|
---|
22 | ifelse([$1],,AC_DEFINE(HAVE_SOCKLEN_T,1,[Define if your compiler defines socklen_t.]),[$1])
|
---|
23 | :
|
---|
24 | else
|
---|
25 | acx_socklen_t_ok=no
|
---|
26 | $2
|
---|
27 | fi
|
---|
28 | ])dnl ACX_CHECK_SOCKLEN_T
|
---|
29 |
|
---|
30 | AC_DEFUN([ACX_CHECK_CXX], [
|
---|
31 | AC_MSG_CHECKING([if g++ defines correct C++ macro])
|
---|
32 | AC_TRY_COMPILE(, [
|
---|
33 | #if defined(_LANGUAGE_C) && !defined(_LANGUAGE_C_PLUS_PLUS)
|
---|
34 | #error wrong macro
|
---|
35 | #endif],[acx_cxx_macro_ok=yes],[acx_cxx_macro_ok=no])
|
---|
36 | AC_MSG_RESULT($acx_cxx_macro_ok)
|
---|
37 | if test x"$acx_cxx_macro_ok" = xyes; then
|
---|
38 | SYNERGY_CXXFLAGS=""
|
---|
39 | else
|
---|
40 | SYNERGY_CXXFLAGS="-U_LANGUAGE_C -D_LANGUAGE_C_PLUS_PLUS"
|
---|
41 | fi
|
---|
42 | ])dnl ACX_CHECK_CXX
|
---|
43 |
|
---|
44 | AC_DEFUN([ACX_CHECK_CXX_BOOL], [
|
---|
45 | AC_MSG_CHECKING([for bool support])
|
---|
46 | AC_TRY_COMPILE(, [bool t = true, f = false;],
|
---|
47 | [acx_cxx_bool_ok=yes],[acx_cxx_bool_ok=no])
|
---|
48 | AC_MSG_RESULT($acx_cxx_bool_ok)
|
---|
49 | if test x"$acx_cxx_bool_ok" = xyes; then
|
---|
50 | ifelse([$1],,AC_DEFINE(HAVE_CXX_BOOL,1,[Define if your compiler has bool support.]),[$1])
|
---|
51 | :
|
---|
52 | else
|
---|
53 | acx_cxx_bool_ok=no
|
---|
54 | $2
|
---|
55 | fi
|
---|
56 | ])dnl ACX_CHECK_CXX_BOOL
|
---|
57 |
|
---|
58 | AC_DEFUN([ACX_CHECK_CXX_EXCEPTIONS], [
|
---|
59 | AC_MSG_CHECKING([for exception support])
|
---|
60 | AC_TRY_COMPILE(, [try{throw int(4);}catch(int){throw;}catch(...){}],
|
---|
61 | [acx_cxx_exception_ok=yes],[acx_cxx_exception_ok=no])
|
---|
62 | AC_MSG_RESULT($acx_cxx_exception_ok)
|
---|
63 | if test x"$acx_cxx_exception_ok" = xyes; then
|
---|
64 | ifelse([$1],,AC_DEFINE(HAVE_CXX_EXCEPTIONS,1,[Define if your compiler has exceptions support.]),[$1])
|
---|
65 | :
|
---|
66 | else
|
---|
67 | acx_cxx_exception_ok=no
|
---|
68 | $2
|
---|
69 | fi
|
---|
70 | ])dnl ACX_CHECK_CXX_EXCEPTIONS
|
---|
71 |
|
---|
72 | AC_DEFUN([ACX_CHECK_CXX_CASTS], [
|
---|
73 | AC_MSG_CHECKING([for C++ cast support])
|
---|
74 | AC_TRY_COMPILE(, [const char* f="a";const_cast<char*>(f);
|
---|
75 | reinterpret_cast<const int*>(f);static_cast<int>(4.5);],
|
---|
76 | [acx_cxx_cast_ok=yes],[acx_cxx_cast_ok=no])
|
---|
77 | AC_MSG_RESULT($acx_cxx_cast_ok)
|
---|
78 | if test x"$acx_cxx_cast_ok" = xyes; then
|
---|
79 | ifelse([$1],,AC_DEFINE(HAVE_CXX_CASTS,1,[Define if your compiler has C++ cast support.]),[$1])
|
---|
80 | :
|
---|
81 | else
|
---|
82 | acx_cxx_cast_ok=no
|
---|
83 | $2
|
---|
84 | fi
|
---|
85 | ])dnl ACX_CHECK_CXX_CASTS
|
---|
86 |
|
---|
87 | AC_DEFUN([ACX_CHECK_CXX_MUTABLE], [
|
---|
88 | AC_MSG_CHECKING([for mutable support])
|
---|
89 | AC_TRY_COMPILE(, [struct A{mutable int b;void f() const {b=0;}};
|
---|
90 | A a;a.f();],[acx_cxx_mutable_ok=yes],[acx_cxx_mutable_ok=no])
|
---|
91 | AC_MSG_RESULT($acx_cxx_mutable_ok)
|
---|
92 | if test x"$acx_cxx_mutable_ok" = xyes; then
|
---|
93 | ifelse([$1],,AC_DEFINE(HAVE_CXX_MUTABLE,1,[Define if your compiler has mutable support.]),[$1])
|
---|
94 | :
|
---|
95 | else
|
---|
96 | acx_cxx_mutable_ok=no
|
---|
97 | $2
|
---|
98 | fi
|
---|
99 | ])dnl ACX_CHECK_CXX_MUTABLE
|
---|
100 |
|
---|
101 | AC_DEFUN([ACX_CHECK_CXX_STDLIB], [
|
---|
102 | AC_MSG_CHECKING([for C++ standard library])
|
---|
103 | AC_TRY_LINK([#include <set>], [std::set<int> a; a.insert(3);],
|
---|
104 | [acx_cxx_stdlib_ok=yes],[acx_cxx_stdlib_ok=no])
|
---|
105 | AC_MSG_RESULT($acx_cxx_stdlib_ok)
|
---|
106 | if test x"$acx_cxx_stdlib_ok" = xyes; then
|
---|
107 | ifelse([$1],,AC_DEFINE(HAVE_CXX_STDLIB,1,[Define if your compiler has standard C++ library support.]),[$1])
|
---|
108 | :
|
---|
109 | else
|
---|
110 | acx_cxx_stdlib_ok=no
|
---|
111 | $2
|
---|
112 | fi
|
---|
113 | ])dnl ACX_CHECK_CXX_STDLIB
|
---|
114 |
|
---|
115 | AC_DEFUN([ACX_CHECK_GETPWUID_R], [
|
---|
116 | AC_MSG_CHECKING([for working getpwuid_r])
|
---|
117 | AC_TRY_LINK([#include <pwd.h>],
|
---|
118 | [char buffer[4096]; struct passwd pwd, *pwdp;
|
---|
119 | getpwuid_r(0, &pwd, buffer, sizeof(buffer), &pwdp);],
|
---|
120 | acx_getpwuid_r_ok=yes, acx_getpwuid_r_ok=no)
|
---|
121 | AC_MSG_RESULT($acx_getpwuid_r_ok)
|
---|
122 | if test x"$acx_getpwuid_r_ok" = xyes; then
|
---|
123 | ifelse([$1],,AC_DEFINE(HAVE_GETPWUID_R,1,[Define if you have a working \`getpwuid_r\' function.]),[$1])
|
---|
124 | :
|
---|
125 | else
|
---|
126 | acx_getpwuid_r_ok=no
|
---|
127 | $2
|
---|
128 | fi
|
---|
129 | ])dnl ACX_CHECK_GETPWUID_R
|
---|
130 |
|
---|
131 | AC_DEFUN([ACX_CHECK_POLL], [
|
---|
132 | AC_MSG_CHECKING([for poll])
|
---|
133 | AC_TRY_LINK([#include <poll.h>],
|
---|
134 | [#if defined(_POLL_EMUL_H_)
|
---|
135 | #error emulated poll
|
---|
136 | #endif
|
---|
137 | struct pollfd ufds[] = { 0, POLLIN, 0 }; poll(ufds, 1, 10);],
|
---|
138 | acx_poll_ok=yes, acx_poll_ok=no)
|
---|
139 | AC_MSG_RESULT($acx_poll_ok)
|
---|
140 | if test x"$acx_poll_ok" = xyes; then
|
---|
141 | ifelse([$1],,AC_DEFINE(HAVE_POLL,1,[Define if you have the \`poll\' function.]),[$1])
|
---|
142 | :
|
---|
143 | else
|
---|
144 | acx_poll_ok=no
|
---|
145 | $2
|
---|
146 | fi
|
---|
147 | ])dnl ACX_CHECK_POLL
|
---|
148 |
|
---|
149 | dnl See if we need extra libraries for nanosleep
|
---|
150 | AC_DEFUN([ACX_CHECK_NANOSLEEP], [
|
---|
151 | acx_nanosleep_ok=no
|
---|
152 | acx_nanosleep_list=""
|
---|
153 |
|
---|
154 | dnl check if user has set NANOSLEEP_LIBS
|
---|
155 | save_user_NANOSLEEP_LIBS="$NANOSLEEP_LIBS"
|
---|
156 | if test x"$NANOSLEEP_LIBS" != x; then
|
---|
157 | acx_nanosleep_list=user
|
---|
158 | fi
|
---|
159 |
|
---|
160 | dnl check various libraries (including no extra libraries) for
|
---|
161 | dnl nanosleep. `none' should appear first.
|
---|
162 | acx_nanosleep_list="none $acx_nanosleep_list rt"
|
---|
163 | for flag in $acx_nanosleep_list; do
|
---|
164 | case $flag in
|
---|
165 | none)
|
---|
166 | AC_MSG_CHECKING([for nanosleep])
|
---|
167 | NANOSLEEP_LIBS=""
|
---|
168 | ;;
|
---|
169 |
|
---|
170 | user)
|
---|
171 | AC_MSG_CHECKING([for nanosleep in $save_user_NANOSLEEP_LIBS])
|
---|
172 | NANOSLEEP_LIBS="$save_user_NANOSLEEP_LIBS"
|
---|
173 | ;;
|
---|
174 |
|
---|
175 | *)
|
---|
176 | AC_MSG_CHECKING([for nanosleep in -l$flag])
|
---|
177 | NANOSLEEP_LIBS="-l$flag"
|
---|
178 | ;;
|
---|
179 | esac
|
---|
180 |
|
---|
181 | save_LIBS="$LIBS"
|
---|
182 | LIBS="$NANOSLEEP_LIBS $LIBS"
|
---|
183 | AC_TRY_LINK([#include <time.h>],
|
---|
184 | [struct timespec t = { 1, 1000 }; nanosleep(&t, NULL);],
|
---|
185 | acx_nanosleep_ok=yes, acx_nanosleep_ok=no)
|
---|
186 | LIBS="$save_LIBS"
|
---|
187 | AC_MSG_RESULT($acx_nanosleep_ok)
|
---|
188 | if test x"$acx_nanosleep_ok" = xyes; then
|
---|
189 | break;
|
---|
190 | fi
|
---|
191 | NANOSLEEP_LIBS=""
|
---|
192 | done
|
---|
193 |
|
---|
194 | AC_SUBST(NANOSLEEP_LIBS)
|
---|
195 |
|
---|
196 | # execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
---|
197 | if test x"$acx_nanosleep_ok" = xyes; then
|
---|
198 | ifelse([$1],,AC_DEFINE(HAVE_NANOSLEEP,1,[Define if you have the \`nanosleep\' function.]),[$1])
|
---|
199 | :
|
---|
200 | else
|
---|
201 | acx_nanosleep_ok=no
|
---|
202 | $2
|
---|
203 | fi
|
---|
204 | ])dnl ACX_CHECK_NANOSLEEP
|
---|
205 |
|
---|
206 | dnl See if we need extra libraries for inet_aton
|
---|
207 | AC_DEFUN([ACX_CHECK_INET_ATON], [
|
---|
208 | acx_inet_aton_ok=no
|
---|
209 | acx_inet_aton_list=""
|
---|
210 |
|
---|
211 | dnl check if user has set INET_ATON_LIBS
|
---|
212 | save_user_INET_ATON_LIBS="$INET_ATON_LIBS"
|
---|
213 | if test x"$INET_ATON_LIBS" != x; then
|
---|
214 | acx_inet_aton_list=user
|
---|
215 | fi
|
---|
216 |
|
---|
217 | dnl check various libraries (including no extra libraries) for
|
---|
218 | dnl inet_aton. `none' should appear first.
|
---|
219 | acx_inet_aton_list="none $acx_inet_aton_list resolv"
|
---|
220 | for flag in $acx_inet_aton_list; do
|
---|
221 | case $flag in
|
---|
222 | none)
|
---|
223 | AC_MSG_CHECKING([for inet_aton])
|
---|
224 | INET_ATON_LIBS=""
|
---|
225 | ;;
|
---|
226 |
|
---|
227 | user)
|
---|
228 | AC_MSG_CHECKING([for inet_aton in $save_user_INET_ATON_LIBS])
|
---|
229 | INET_ATON_LIBS="$save_user_INET_ATON_LIBS"
|
---|
230 | ;;
|
---|
231 |
|
---|
232 | *)
|
---|
233 | AC_MSG_CHECKING([for inet_aton in -l$flag])
|
---|
234 | INET_ATON_LIBS="-l$flag"
|
---|
235 | ;;
|
---|
236 | esac
|
---|
237 |
|
---|
238 | save_LIBS="$LIBS"
|
---|
239 | LIBS="$INET_ATON_LIBS $LIBS"
|
---|
240 | AC_TRY_LINK([#include <sys/types.h>
|
---|
241 | #include <sys/socket.h>
|
---|
242 | #include <netinet/in.h>
|
---|
243 | #include <arpa/inet.h>],
|
---|
244 | [struct in_addr addr; inet_aton("foo.bar", &addr);],
|
---|
245 | acx_inet_aton_ok=yes, acx_inet_aton_ok=no)
|
---|
246 | LIBS="$save_LIBS"
|
---|
247 | AC_MSG_RESULT($acx_inet_aton_ok)
|
---|
248 | if test x"$acx_inet_aton_ok" = xyes; then
|
---|
249 | AC_DEFINE(HAVE_INET_ATON,1,[Define if you have the \`inet_aton\' function.])
|
---|
250 | break;
|
---|
251 | fi
|
---|
252 | INET_ATON_LIBS=""
|
---|
253 | done
|
---|
254 |
|
---|
255 | AC_SUBST(INET_ATON_LIBS)
|
---|
256 | ])dnl ACX_CHECK_INET_ATON
|
---|
257 |
|
---|
258 | dnl The following macros are from http://www.gnu.org/software/ac-archive/
|
---|
259 | dnl which distributes them under the following license:
|
---|
260 | dnl
|
---|
261 | dnl Every Autoconf macro presented on this web site is free software; you can
|
---|
262 | dnl redistribute it and/or modify it under the terms of the GNU General
|
---|
263 | dnl Public License as published by the Free Software Foundation; either
|
---|
264 | dnl version 2, or (at your option) any later version.
|
---|
265 | dnl
|
---|
266 | dnl They are distributed in the hope that they will be useful, but WITHOUT
|
---|
267 | dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
268 | dnl FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
---|
269 | dnl more details. (You should have received a copy of the GNU General Public
|
---|
270 | dnl License along with this program; if not, write to the Free Software
|
---|
271 | dnl Foundation, Inc., 59 Temple Place -- Suite 330, Boston, MA 02111-1307,
|
---|
272 | dnl USA.)
|
---|
273 | dnl
|
---|
274 | dnl As a special exception, the Free Software Foundation gives unlimited
|
---|
275 | dnl permission to copy, distribute and modify the configure scripts that are
|
---|
276 | dnl the output of Autoconf. You need not follow the terms of the GNU General
|
---|
277 | dnl Public License when using or distributing such scripts, even though
|
---|
278 | dnl portions of the text of Autoconf appear in them. The GNU General Public
|
---|
279 | dnl License (GPL) does govern all other use of the material that constitutes
|
---|
280 | dnl the Autoconf program.
|
---|
281 | dnl
|
---|
282 | dnl Certain portions of the Autoconf source text are designed to be copied
|
---|
283 | dnl (in certain cases, depending on the input) into the output of Autoconf.
|
---|
284 | dnl We call these the "data" portions. The rest of the Autoconf source text
|
---|
285 | dnl consists of comments plus executable code that decides which of the data
|
---|
286 | dnl portions to output in any given case. We call these comments and
|
---|
287 | dnl executable code the "non-data" portions. Autoconf never copies any of the
|
---|
288 | dnl non-data portions into its output.
|
---|
289 | dnl
|
---|
290 | dnl This special exception to the GPL applies to versions of Autoconf
|
---|
291 | dnl released by the Free Software Foundation. When you make and distribute a
|
---|
292 | dnl modified version of Autoconf, you may extend this special exception to
|
---|
293 | dnl the GPL to apply to your modified version as well, *unless* your modified
|
---|
294 | dnl version has the potential to copy into its output some of the text that
|
---|
295 | dnl was the non-data portion of the version that you started with. (In other
|
---|
296 | dnl words, unless your change moves or copies text from the non-data portions
|
---|
297 | dnl to the data portions.) If your modification has such potential, you must
|
---|
298 | dnl delete any notice of this special exception to the GPL from your modified
|
---|
299 | dnl version
|
---|
300 |
|
---|
301 | AC_DEFUN([ACX_PTHREAD], [
|
---|
302 | AC_REQUIRE([AC_CANONICAL_HOST])
|
---|
303 | AC_LANG_SAVE
|
---|
304 | AC_LANG_C
|
---|
305 | acx_pthread_ok=no
|
---|
306 |
|
---|
307 | # We used to check for pthread.h first, but this fails if pthread.h
|
---|
308 | # requires special compiler flags (e.g. on True64 or Sequent).
|
---|
309 | # It gets checked for in the link test anyway.
|
---|
310 |
|
---|
311 | # First of all, check if the user has set any of the PTHREAD_LIBS,
|
---|
312 | # etcetera environment variables, and if threads linking works using
|
---|
313 | # them:
|
---|
314 | if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
---|
315 | save_CFLAGS="$CFLAGS"
|
---|
316 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
---|
317 | save_LIBS="$LIBS"
|
---|
318 | LIBS="$PTHREAD_LIBS $LIBS"
|
---|
319 | AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
---|
320 | AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
|
---|
321 | AC_MSG_RESULT($acx_pthread_ok)
|
---|
322 | if test x"$acx_pthread_ok" = xno; then
|
---|
323 | PTHREAD_LIBS=""
|
---|
324 | PTHREAD_CFLAGS=""
|
---|
325 | fi
|
---|
326 | LIBS="$save_LIBS"
|
---|
327 | CFLAGS="$save_CFLAGS"
|
---|
328 | fi
|
---|
329 |
|
---|
330 | # We must check for the threads library under a number of different
|
---|
331 | # names; the ordering is very important because some systems
|
---|
332 | # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
---|
333 | # libraries is broken (non-POSIX).
|
---|
334 |
|
---|
335 | # Create a list of thread flags to try. Items starting with a "-" are
|
---|
336 | # C compiler flags, and other items are library names, except for "none"
|
---|
337 | # which indicates that we try without any flags at all, and "pthread-config"
|
---|
338 | # which is a program returning the flags for the Pth emulation library.
|
---|
339 |
|
---|
340 | acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
---|
341 |
|
---|
342 | # The ordering *is* (sometimes) important. Some notes on the
|
---|
343 | # individual items follow:
|
---|
344 |
|
---|
345 | # pthreads: AIX (must check this before -lpthread)
|
---|
346 | # none: in case threads are in libc; should be tried before -Kthread and
|
---|
347 | # other compiler flags to prevent continual compiler warnings
|
---|
348 | # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
---|
349 | # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
---|
350 | # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
---|
351 | # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
---|
352 | # -pthreads: Solaris/gcc
|
---|
353 | # -mthreads: Mingw32/gcc, Lynx/gcc
|
---|
354 | # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
---|
355 | # doesn't hurt to check since this sometimes defines pthreads too;
|
---|
356 | # also defines -D_REENTRANT)
|
---|
357 | # pthread: Linux, etcetera
|
---|
358 | # --thread-safe: KAI C++
|
---|
359 | # pthread-config: use pthread-config program (for GNU Pth library)
|
---|
360 |
|
---|
361 | case "${host_cpu}-${host_os}" in
|
---|
362 | *solaris*)
|
---|
363 |
|
---|
364 | # On Solaris (at least, for some versions), libc contains stubbed
|
---|
365 | # (non-functional) versions of the pthreads routines, so link-based
|
---|
366 | # tests will erroneously succeed. (We need to link with -pthread or
|
---|
367 | # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
---|
368 | # a function called by this macro, so we could check for that, but
|
---|
369 | # who knows whether they'll stub that too in a future libc.) So,
|
---|
370 | # we'll just look for -pthreads and -lpthread first:
|
---|
371 |
|
---|
372 | acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
|
---|
373 | ;;
|
---|
374 | esac
|
---|
375 |
|
---|
376 | if test x"$acx_pthread_ok" = xno; then
|
---|
377 | for flag in $acx_pthread_flags; do
|
---|
378 |
|
---|
379 | case $flag in
|
---|
380 | none)
|
---|
381 | AC_MSG_CHECKING([whether pthreads work without any flags])
|
---|
382 | ;;
|
---|
383 |
|
---|
384 | -*)
|
---|
385 | AC_MSG_CHECKING([whether pthreads work with $flag])
|
---|
386 | PTHREAD_CFLAGS="$flag"
|
---|
387 | ;;
|
---|
388 |
|
---|
389 | pthread-config)
|
---|
390 | AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
|
---|
391 | if test x"$acx_pthread_config" = xno; then continue; fi
|
---|
392 | PTHREAD_CFLAGS="`pthread-config --cflags`"
|
---|
393 | PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
---|
394 | ;;
|
---|
395 |
|
---|
396 | *)
|
---|
397 | AC_MSG_CHECKING([for the pthreads library -l$flag])
|
---|
398 | PTHREAD_LIBS="-l$flag"
|
---|
399 | ;;
|
---|
400 | esac
|
---|
401 |
|
---|
402 | save_LIBS="$LIBS"
|
---|
403 | save_CFLAGS="$CFLAGS"
|
---|
404 | LIBS="$PTHREAD_LIBS $LIBS"
|
---|
405 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
---|
406 |
|
---|
407 | # Check for various functions. We must include pthread.h,
|
---|
408 | # since some functions may be macros. (On the Sequent, we
|
---|
409 | # need a special flag -Kthread to make this header compile.)
|
---|
410 | # We check for pthread_join because it is in -lpthread on IRIX
|
---|
411 | # while pthread_create is in libc. We check for pthread_attr_init
|
---|
412 | # due to DEC craziness with -lpthreads. We check for
|
---|
413 | # pthread_cleanup_push because it is one of the few pthread
|
---|
414 | # functions on Solaris that doesn't have a non-functional libc stub.
|
---|
415 | # We try pthread_create on general principles.
|
---|
416 | AC_TRY_LINK([#include <pthread.h>],
|
---|
417 | [pthread_t th; pthread_join(th, 0);
|
---|
418 | pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
---|
419 | pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
---|
420 | [acx_pthread_ok=yes])
|
---|
421 |
|
---|
422 | LIBS="$save_LIBS"
|
---|
423 | CFLAGS="$save_CFLAGS"
|
---|
424 |
|
---|
425 | AC_MSG_RESULT($acx_pthread_ok)
|
---|
426 | if test "x$acx_pthread_ok" = xyes; then
|
---|
427 | break;
|
---|
428 | fi
|
---|
429 |
|
---|
430 | PTHREAD_LIBS=""
|
---|
431 | PTHREAD_CFLAGS=""
|
---|
432 | done
|
---|
433 | fi
|
---|
434 |
|
---|
435 | # Various other checks:
|
---|
436 | if test "x$acx_pthread_ok" = xyes; then
|
---|
437 | save_LIBS="$LIBS"
|
---|
438 | LIBS="$PTHREAD_LIBS $LIBS"
|
---|
439 | save_CFLAGS="$CFLAGS"
|
---|
440 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
---|
441 |
|
---|
442 | # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
---|
443 | AC_MSG_CHECKING([for joinable pthread attribute])
|
---|
444 | attr_name=unknown
|
---|
445 | for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
---|
446 | AC_TRY_LINK([#include <pthread.h>], [int attr=$attr;],
|
---|
447 | [attr_name=$attr; break])
|
---|
448 | done
|
---|
449 | AC_MSG_RESULT($attr_name)
|
---|
450 | if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
|
---|
451 | AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
|
---|
452 | [Define to necessary symbol if this constant
|
---|
453 | uses a non-standard name on your system.])
|
---|
454 | fi
|
---|
455 |
|
---|
456 | AC_MSG_CHECKING([if more special flags are required for pthreads])
|
---|
457 | flag=no
|
---|
458 | case "${host_cpu}-${host_os}" in
|
---|
459 | *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
|
---|
460 | *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
|
---|
461 | esac
|
---|
462 | AC_MSG_RESULT(${flag})
|
---|
463 | if test "x$flag" != xno; then
|
---|
464 | PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
---|
465 | fi
|
---|
466 |
|
---|
467 | # Detect POSIX sigwait()
|
---|
468 | AC_MSG_CHECKING([for POSIX sigwait])
|
---|
469 | AC_TRY_LINK([#include <pthread.h>
|
---|
470 | #include <signal.h>],
|
---|
471 | [sigset_t sigset; int signal; sigwait(&sigset, &signal);],
|
---|
472 | ok=yes, ok=unknown)
|
---|
473 | if test x"$ok" = xunknown; then
|
---|
474 | save_CFLAGS2="$CFLAGS"
|
---|
475 | CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS"
|
---|
476 | AC_TRY_LINK([#include <pthread.h>
|
---|
477 | #include <signal.h>],
|
---|
478 | [sigset_t sigset; int signal; sigwait(&sigset, &signal);],
|
---|
479 | ok=-D_POSIX_PTHREAD_SEMANTICS, ok=no)
|
---|
480 | CFLAGS="$save_CFLAGS2"
|
---|
481 | fi
|
---|
482 | AC_MSG_RESULT(${ok})
|
---|
483 | if test x"$ok" != xno; then
|
---|
484 | AC_DEFINE(HAVE_POSIX_SIGWAIT,1,[Define if you have a POSIX \`sigwait\' function.])
|
---|
485 | if test x"$ok" != xyes; then
|
---|
486 | PTHREAD_CFLAGS="$ok $PTHREAD_CFLAGS"
|
---|
487 | fi
|
---|
488 | fi
|
---|
489 |
|
---|
490 | # Detect pthread signal functions
|
---|
491 | AC_MSG_CHECKING([for pthread signal functions])
|
---|
492 | AC_TRY_LINK([#include <pthread.h>
|
---|
493 | #include <signal.h>],
|
---|
494 | [pthread_kill(pthread_self(), SIGTERM);],
|
---|
495 | ok=yes, ok=no)
|
---|
496 | AC_MSG_RESULT(${ok})
|
---|
497 | if test x"$ok" = xyes; then
|
---|
498 | AC_DEFINE(HAVE_PTHREAD_SIGNAL,1,[Define if you have \`pthread_sigmask\' and \`pthread_kill\' functions.])
|
---|
499 | fi
|
---|
500 |
|
---|
501 | LIBS="$save_LIBS"
|
---|
502 | CFLAGS="$save_CFLAGS"
|
---|
503 |
|
---|
504 | # More AIX lossage: must compile with cc_r
|
---|
505 | AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
|
---|
506 | else
|
---|
507 | PTHREAD_CC="$CC"
|
---|
508 | fi
|
---|
509 |
|
---|
510 | AC_SUBST(PTHREAD_LIBS)
|
---|
511 | AC_SUBST(PTHREAD_CFLAGS)
|
---|
512 | AC_SUBST(PTHREAD_CC)
|
---|
513 |
|
---|
514 | # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
---|
515 | if test x"$acx_pthread_ok" = xyes; then
|
---|
516 | ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
|
---|
517 | :
|
---|
518 | else
|
---|
519 | acx_pthread_ok=no
|
---|
520 | $2
|
---|
521 | fi
|
---|
522 | AC_LANG_RESTORE
|
---|
523 | ])dnl ACX_PTHREAD
|
---|
524 |
|
---|
525 | dnl enable maximum compiler warnings. must ignore unknown pragmas to
|
---|
526 | dnl build on solaris.
|
---|
527 | dnl we only know how to do this for g++
|
---|
528 | AC_DEFUN([ACX_CXX_WARNINGS], [
|
---|
529 | AC_MSG_CHECKING([for C++ compiler warning flags])
|
---|
530 | if test "$GXX" = "yes"; then
|
---|
531 | acx_cxx_warnings="-Wall -Wno-unknown-pragmas"
|
---|
532 | fi
|
---|
533 | if test -n "$acx_cxx_warnings"; then
|
---|
534 | CXXFLAGS="$CXXFLAGS $acx_cxx_warnings"
|
---|
535 | else
|
---|
536 | acx_cxx_warnings="unknown"
|
---|
537 | fi
|
---|
538 | AC_MSG_RESULT($acx_cxx_warnings)
|
---|
539 | ])dnl ACX_CXX_WARNINGS
|
---|
540 |
|
---|
541 | dnl enable compiler warnings are errors
|
---|
542 | dnl we only know how to do this for g++
|
---|
543 | AC_DEFUN([ACX_CXX_WARNINGS_ARE_ERRORS], [
|
---|
544 | AC_MSG_CHECKING([for C++ compiler warning are errors flags])
|
---|
545 | if test "$GXX" = "yes"; then
|
---|
546 | acx_cxx_warnings_are_errors="-Werror"
|
---|
547 | fi
|
---|
548 | if test -n "$acx_cxx_warnings_are_errors"; then
|
---|
549 | CXXFLAGS="$CXXFLAGS $acx_cxx_warnings_are_errors"
|
---|
550 | else
|
---|
551 | acx_cxx_warnings_are_errors="unknown"
|
---|
552 | fi
|
---|
553 | AC_MSG_RESULT($acx_cxx_warnings_are_errors)
|
---|
554 | ])dnl ACX_CXX_WARNINGS_ARE_ERRORS
|
---|