1 dnl Helper Functions for the RRDtool configure.ac script
2 dnl
3 dnl this file gets included into aclocal.m4 when runnning aclocal
4 dnl
5 dnl
6 dnl
7 dnl Check for the presence of a particular library and its header files
8 dnl if this check fails set the environment variable EX_CHECK_ALL_ERR to YES
9 dnl and prints out a helful message
10 dnl
11 dnl
12 dnl EX_CHECK_ALL(library, function, header, pkgconf name, tested-version, homepage, cppflags)
13 dnl $1 $2 $3 $4 $5 $6 $7
14 dnl
15 dnl
16 AC_DEFUN([EX_CHECK_ALL],
17 [
18 AC_LANG_PUSH(C)
19 EX_CHECK_STATE=NO
20 ex_check_save_LIBS=${LIBS}
21 ex_check_save_CPPFLAGS=${CPPFLAGS}
22 ex_check_save_LDFLAGS=${LDFLAGS}
23 if test "x$7" != "x"; then
24 CPPFLAGS="$CPPFLAGS -I$7"
25 fi
26 dnl try compiling naked first
27 AC_CHECK_LIB($1,$2, [
28 AC_CHECK_HEADER($3,[LIBS="-l$1 ${LIBS}";EX_CHECK_STATE=YES],[])],[])
29 if test $EX_CHECK_STATE = NO; then
30 dnl now asking pkg-config for help
31 AC_CHECK_PROGS(PKGCONFIG,[pkg-config],no)
32 if test "$PKGCONFIG" != "no"; then
33 if $PKGCONFIG --exists $4; then
34 CPPFLAGS=${CPPFLAGS}" "`$PKGCONFIG --cflags $4`
35 LDFLAGS=${LDFLAGS}" "`$PKGCONFIG --libs-only-L $4`
36 LDFLAGS=${LDFLAGS}" "`$PKGCONFIG --libs-only-other $4`
37 LIBS=${LIBS}" "`$PKGCONFIG --libs-only-l $4`
38 dnl remove the cached value and test again
39 unset ac_cv_lib_`echo $1 | sed ['s/[^_a-zA-Z0-9]/_/g;s/^[0-9]/_/']`_$2
40 AC_CHECK_LIB($1,$2,[
41 unset ac_cv_header_`echo $3 | sed ['s/[^_a-zA-Z0-9]/_/g;s/^[0-9]/_/']`
42 AC_CHECK_HEADER($3,[EX_CHECK_STATE=YES],[])
43 ],[])
44 else
45 AC_MSG_WARN([
46 ----------------------------------------------------------------------------
47 * I found a copy of pkgconfig, but there is no $4.pc file around.
48 You may want to set the PKG_CONFIG_PATH variable to point to its
49 location.
50 ----------------------------------------------------------------------------
51 ])
52 fi
53 fi
54 fi
56 if test ${EX_CHECK_STATE} = NO; then
57 AC_MSG_WARN([
58 ----------------------------------------------------------------------------
59 * I could not find a working copy of $4. Check config.log for hints on why
60 this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately
61 so that compiler and the linker can find lib$1 and its header files. If
62 you have not installed $4, you can get it either from its original home on
64 $6
66 You can find also find an archive copy on
68 http://oss.oetiker.ch/rrdtool/pub/libs
70 The last tested version of $4 is $5.
72 LIBS=$LIBS
73 LDFLAGS=$LDFLAGS
74 CPPFLAGS=$CPPFLAGS
76 ----------------------------------------------------------------------------
77 ])
78 EX_CHECK_ALL_ERR=YES
79 LIBS="${ex_check_save_LIBS}"
80 CPPFLAGS="${ex_check_save_CPPFLAGS}"
81 LDFLAGS="${ex_check_save_LDFLAGS}"
82 fi
83 AC_LANG_POP(C)
84 ]
85 )
87 dnl
88 dnl Ptherad check from http://autoconf-archive.cryp.to/acx_pthread.m4
89 dnl
90 dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
91 dnl
92 dnl This macro figures out how to build C programs using POSIX threads.
93 dnl It sets the PTHREAD_LIBS output variable to the threads library and
94 dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
95 dnl C compiler flags that are needed. (The user can also force certain
96 dnl compiler flags/libs to be tested by setting these environment
97 dnl variables.)
98 dnl
99 dnl Also sets PTHREAD_CC to any special C compiler that is needed for
100 dnl multi-threaded programs (defaults to the value of CC otherwise).
101 dnl (This is necessary on AIX to use the special cc_r compiler alias.)
102 dnl
103 dnl NOTE: You are assumed to not only compile your program with these
104 dnl flags, but also link it with them as well. e.g. you should link
105 dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
106 dnl $LIBS
107 dnl
108 dnl If you are only building threads programs, you may wish to use
109 dnl these variables in your default LIBS, CFLAGS, and CC:
110 dnl
111 dnl LIBS="$PTHREAD_LIBS $LIBS"
112 dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
113 dnl CC="$PTHREAD_CC"
114 dnl
115 dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
116 dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
117 dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
118 dnl
119 dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
120 dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
121 dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
122 dnl default action will define HAVE_PTHREAD.
123 dnl
124 dnl Please let the authors know if this macro fails on any platform, or
125 dnl if you have any other suggestions or comments. This macro was based
126 dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
127 dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
128 dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
129 dnl We are also grateful for the helpful feedback of numerous users.
130 dnl
131 dnl @category InstalledPackages
132 dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
133 dnl @version 2005-01-14
134 dnl @license GPLWithACException
136 AC_DEFUN([ACX_PTHREAD], [
137 AC_REQUIRE([AC_CANONICAL_HOST])
138 AC_LANG_PUSH(C)
139 acx_pthread_ok=no
141 # We used to check for pthread.h first, but this fails if pthread.h
142 # requires special compiler flags (e.g. on True64 or Sequent).
143 # It gets checked for in the link test anyway.
145 # First of all, check if the user has set any of the PTHREAD_LIBS,
146 # etcetera environment variables, and if threads linking works using
147 # them:
148 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
149 save_CFLAGS="$CFLAGS"
150 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
151 save_LIBS="$LIBS"
152 LIBS="$PTHREAD_LIBS $LIBS"
153 AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
154 AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
155 AC_MSG_RESULT($acx_pthread_ok)
156 if test x"$acx_pthread_ok" = xno; then
157 PTHREAD_LIBS=""
158 PTHREAD_CFLAGS=""
159 fi
160 LIBS="$save_LIBS"
161 CFLAGS="$save_CFLAGS"
162 fi
164 # We must check for the threads library under a number of different
165 # names; the ordering is very important because some systems
166 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
167 # libraries is broken (non-POSIX).
169 # Create a list of thread flags to try. Items starting with a "-" are
170 # C compiler flags, and other items are library names, except for "none"
171 # which indicates that we try without any flags at all, and "pthread-config"
172 # which is a program returning the flags for the Pth emulation library.
174 acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
176 # The ordering *is* (sometimes) important. Some notes on the
177 # individual items follow:
179 # pthreads: AIX (must check this before -lpthread)
180 # none: in case threads are in libc; should be tried before -Kthread and
181 # other compiler flags to prevent continual compiler warnings
182 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
183 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
184 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
185 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
186 # -pthreads: Solaris/gcc
187 # -mthreads: Mingw32/gcc, Lynx/gcc
188 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
189 # doesn't hurt to check since this sometimes defines pthreads too;
190 # also defines -D_REENTRANT)
191 # pthread: Linux, etcetera
192 # --thread-safe: KAI C++
193 # pthread-config: use pthread-config program (for GNU Pth library)
195 case "${host_cpu}-${host_os}" in
196 *solaris*)
198 # On Solaris (at least, for some versions), libc contains stubbed
199 # (non-functional) versions of the pthreads routines, so link-based
200 # tests will erroneously succeed. (We need to link with -pthread or
201 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
202 # a function called by this macro, so we could check for that, but
203 # who knows whether they'll stub that too in a future libc.) So,
204 # we'll just look for -pthreads and -lpthread first:
206 acx_pthread_flags="-pthread -pthreads pthread -mt $acx_pthread_flags"
207 ;;
208 esac
210 if test x"$acx_pthread_ok" = xno; then
211 for flag in $acx_pthread_flags; do
213 case $flag in
214 none)
215 AC_MSG_CHECKING([whether pthreads work without any flags])
216 ;;
218 -*)
219 AC_MSG_CHECKING([whether pthreads work with $flag])
220 PTHREAD_CFLAGS="$flag"
221 ;;
223 pthread-config)
224 AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
225 if test x"$acx_pthread_config" = xno; then continue; fi
226 PTHREAD_CFLAGS="`pthread-config --cflags`"
227 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
228 ;;
230 *)
231 AC_MSG_CHECKING([for the pthreads library -l$flag])
232 PTHREAD_LIBS="-l$flag"
233 ;;
234 esac
236 save_LIBS="$LIBS"
237 save_CFLAGS="$CFLAGS"
238 LIBS="$PTHREAD_LIBS $LIBS"
239 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
241 # Check for various functions. We must include pthread.h,
242 # since some functions may be macros. (On the Sequent, we
243 # need a special flag -Kthread to make this header compile.)
244 # We check for pthread_join because it is in -lpthread on IRIX
245 # while pthread_create is in libc. We check for pthread_attr_init
246 # due to DEC craziness with -lpthreads. We check for
247 # pthread_cleanup_push because it is one of the few pthread
248 # functions on Solaris that doesn't have a non-functional libc stub.
249 # We try pthread_create on general principles.
250 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_t th; pthread_join(th, 0);
251 pthread_attr_init(0); pthread_cleanup_push(0, 0);
252 pthread_create(0,0,0,0); pthread_cleanup_pop(0); ]])],[acx_pthread_ok=yes],[])
254 LIBS="$save_LIBS"
255 CFLAGS="$save_CFLAGS"
257 AC_MSG_RESULT($acx_pthread_ok)
258 if test "x$acx_pthread_ok" = xyes; then
259 break;
260 fi
262 PTHREAD_LIBS=""
263 PTHREAD_CFLAGS=""
264 done
265 fi
267 # Various other checks:
268 if test "x$acx_pthread_ok" = xyes; then
269 save_LIBS="$LIBS"
270 LIBS="$PTHREAD_LIBS $LIBS"
271 save_CFLAGS="$CFLAGS"
272 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
274 # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
275 AC_MSG_CHECKING([for joinable pthread attribute])
276 attr_name=unknown
277 for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
278 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], [[int attr=$attr;]])],[attr_name=$attr; break],[])
279 done
280 AC_MSG_RESULT($attr_name)
281 if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
282 AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
283 [Define to necessary symbol if this constant
284 uses a non-standard name on your system.])
285 fi
287 AC_MSG_CHECKING([if more special flags are required for pthreads])
288 x_rflag=no
289 case "${host_cpu}-${host_os}" in
290 *-aix* | *-freebsd* | *-darwin*) x_rflag="-D_THREAD_SAFE";;
291 *solaris* | *-osf* | *-hpux*) x_rflag="-D_REENTRANT";;
292 *-linux* | *-k*bsd*-gnu*)
293 if test x"$PTHREAD_CFLAGS" = "x-pthread"; then
294 # For Linux/gcc "-pthread" implies "-lpthread". We need, however, to make this explicit
295 # in PTHREAD_LIBS such that a shared library to be built properly depends on libpthread.
296 PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
297 fi;;
298 esac
299 AC_MSG_RESULT(${x_rflag})
300 if test "x$x_rflag" != xno; then
301 PTHREAD_CFLAGS="$x_rflag $PTHREAD_CFLAGS"
302 fi
304 LIBS="$save_LIBS"
305 CFLAGS="$save_CFLAGS"
307 # More AIX lossage: must compile with cc_r
308 AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
309 else
310 PTHREAD_CC="$CC"
311 fi
313 AC_SUBST(PTHREAD_LIBS)
314 AC_SUBST(PTHREAD_CFLAGS)
315 AC_SUBST(PTHREAD_CC)
317 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
318 if test x"$acx_pthread_ok" = xyes; then
319 ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
320 :
321 else
322 acx_pthread_ok=no
323 $2
324 fi
325 AC_LANG_POP(C)
326 ])dnl ACX_PTHREAD
329 dnl
330 dnl determine how to get IEEE math working
331 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
332 dnl FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
333 dnl
335 dnl substitute them in all the files listed in AC_OUTPUT
336 AC_SUBST(PERLFLAGS)
338 AC_DEFUN([AC_IEEE], [
339 AC_MSG_CHECKING([if IEEE math works $1])
340 AC_CACHE_VAL([rd_cv_ieee_$2],
341 [AC_RUN_IFELSE([AC_LANG_SOURCE([[$3
342 #include "src/rrd_config_bottom.h"
343 #include <stdio.h>
344 int main(void){
345 double rrdnan,rrdinf,rrdc,rrdzero;
346 $4;
347 /* some math to see if we get a floating point exception */
348 rrdzero=sin(0.0); /* don't let the compiler optimize us away */
349 rrdnan=0.0/rrdzero; /* especially here */
350 rrdinf=1.0/rrdzero; /* and here. I want to know if it can do the magic */
351 /* at run time without sig fpe */
352 rrdc = rrdinf + rrdnan;
353 rrdc = rrdinf / rrdnan;
354 if (! isnan(rrdnan)) {printf ("not isnan(NaN) ... "); return 1;}
355 if (rrdnan == rrdnan) {printf ("nan == nan ... "); return 1;}
356 if (! isinf(rrdinf)) {printf ("not isinf(oo) ... "); return 1;}
357 if (! isinf(-rrdinf)) {printf ("not isinf(-oo) ... "); return 1;}
358 if (! rrdinf > 0) {printf ("not inf > 0 ... "); return 1;}
359 if (! -rrdinf < 0) {printf ("not -inf < 0 ... "); return 1;}
360 return 0;
361 }]])],[rd_cv_ieee_$2=yes],[rd_cv_ieee_$2=no],[$as_echo_n "(skipped ... cross-compiling) " >&6
362 # Bypass further checks
363 rd_cv_ieee_works=yes])])
364 dnl these we run regardles is cached or not
365 if test x${rd_cv_ieee_$2} = "xyes"; then
366 AC_MSG_RESULT(yes)
367 $5
368 else
369 AC_MSG_RESULT(no)
370 $6
371 fi
373 ])
375 AC_DEFUN([AC_FULL_IEEE],[
376 AC_LANG_PUSH(C)
377 _cflags=${CFLAGS}
378 AC_IEEE([out of the box], works, , , ,
379 [CFLAGS="$_cflags -ieee"
380 AC_IEEE([with the -ieee switch], switch, , , ,
381 [CFLAGS="$_cflags -qfloat=nofold"
382 AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
383 [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
384 AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
385 [CFLAGS="$_cflags -mieee"
386 AC_IEEE([with the -mieee switch], mswitch, , , ,
387 [CFLAGS="$_cflags -q float=rndsngl"
388 AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
389 [CFLAGS="$_cflags -OPT:IEEE_NaN_inf=ON"
390 AC_IEEE([with the -OPT:IEEE_NaN_inf=ON switch], ieeenaninfswitch, , , ,
391 [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
392 AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
393 [CFLAGS=$_cflags
394 AC_IEEE([with fpsetmask(0)], mask,
395 [#include <floatingpoint.h>], [fpsetmask(0)],
396 [AC_DEFINE(MUST_DISABLE_FPMASK)
397 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
398 [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
399 [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
400 [AC_DEFINE(MUST_DISABLE_SIGFPE)
401 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],
402 AC_MSG_ERROR([
403 Your Compiler does not do propper IEEE math ... Please find out how to
404 make IEEE math work with your compiler and let me know (tobi@oetiker.ch).
405 Check config.log to see what went wrong ...
406 ]))])])])])])])])])])
408 AC_LANG_POP(C)
410 ])
413 dnl a macro to check for ability to create python extensions
414 dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
415 dnl function also defines PYTHON_INCLUDES
416 AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
417 [AC_REQUIRE([AM_PATH_PYTHON])
418 AC_MSG_CHECKING(for headers required to compile python extensions)
419 dnl deduce PYTHON_INCLUDES
420 py_prefix=`$PYTHON -c "import sys; print sys.prefix"`
421 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
422 PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
423 if test "$py_prefix" != "$py_exec_prefix"; then
424 PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
425 fi
426 AC_SUBST(PYTHON_INCLUDES)
427 dnl check if the headers exist:
428 save_CPPFLAGS="$CPPFLAGS"
429 CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
430 AC_TRY_CPP([#include <Python.h>],dnl
431 [AC_MSG_RESULT(found)
432 $1],dnl
433 [AC_MSG_RESULT(not found)
434 $2])
435 CPPFLAGS="$save_CPPFLAGS"
436 ])
438 dnl a macro to add some color to the build process.
439 dnl CONFIGURE_PART(MESSAGE)
441 AC_DEFUN([CONFIGURE_PART],[
442 case $TERM in
443 # for the most important terminal types we directly know the sequences
444 xterm|xterm*|vt220|vt220*)
445 T_MD=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
446 T_ME=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
447 ;;
448 vt100|vt100*|cygwin)
449 T_MD=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
450 T_ME=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
451 ;;
452 *)
453 T_MD=''
454 T_ME=''
455 ;;
456 esac
457 AC_MSG_RESULT()
458 AC_MSG_RESULT([${T_MD}$1${T_ME}])
459 ])
461 dnl check
463 AC_DEFUN([CHECK_FOR_WORKING_MS_ASYNC], [
464 AC_MSG_CHECKING([if msync with MS_ASYNC updates the files mtime])
465 AC_CACHE_VAL([rd_cv_ms_async],
466 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
467 #include <fcntl.h>
468 #include <sys/types.h>
469 #include <sys/stat.h>
470 #include <unistd.h>
471 #include <stdio.h>
472 #include <sys/mman.h>
473 #include <stdlib.h>
474 #include <utime.h>
475 #include <signal.h>
476 void timeout (int i) { exit (1); }
477 int main(void){
478 int fd;
479 struct stat stbuf;
480 char *addr;
481 int res;
482 char temp[] = "mmaptestXXXXXX";
483 struct utimbuf newtime;
484 time_t create_ts;
485 fd = mkstemp(temp);
486 if (fd == -1){
487 perror(temp);
488 return 1;
489 }
490 write(fd,"12345\n", 6);
491 stat(temp, &stbuf);
492 create_ts = stbuf.st_mtime;
493 newtime.actime = 0;
494 newtime.modtime = 0;
495 utime(temp,&newtime);
496 addr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
497 if (addr == MAP_FAILED) {
498 perror("mmap");
499 goto bad_exit;
500 }
501 addr[0]='x';
502 res = msync(addr, 4, MS_ASYNC);
503 if (res == -1) {
504 perror("msync");
505 goto bad_exit;
506 }
507 res = close(fd);
508 if (res == -1) {
509 perror("close");
510 goto bad_exit;
511 }
512 /* there were reports of sync hanging
513 so we better set an alarm */
514 signal(SIGALRM,&timeout);
515 alarm(5);
516 /* The ASYNC means that we schedule the msync and return immediately.
517 Since we want to see if the modification time is updated upon
518 msync(), we have to make sure that our asynchronous request
519 completes before we stat below. In a real application, the
520 request would be completed at a random time in the future
521 but for this test we do not want to wait an arbitrary amount of
522 time, so force a commit now. */
523 sync();
524 stat(temp, &stbuf);
525 if (create_ts > stbuf.st_mtime){
526 goto bad_exit;
527 }
528 unlink(temp);
529 return 0;
530 bad_exit:
531 unlink(temp);
532 return 1;
533 }
534 ]])],[rd_cv_ms_async=ok],[rd_cv_ms_async=broken],[:])])
537 if test "${rd_cv_ms_async}" = "ok"; then
538 AC_MSG_RESULT(yes)
539 else
540 AC_DEFINE_UNQUOTED(HAVE_BROKEN_MS_ASYNC, 1 , [set to 1 if msync with MS_ASYNC fails to update mtime])
541 AC_MSG_RESULT(no)
542 AC_MSG_WARN([With mmap access, your platform fails to update the files])
543 AC_MSG_WARN([mtime. RRDtool will work around this problem by calling utime on each])
544 AC_MSG_WARN([file it opens for rw access.])
545 sleep 2
546 fi
548 ])
550 dnl idea taken from the autoconf mailing list, posted by
551 dnl Timur I. Bakeyev timur@gnu.org,
552 dnl http://mail.gnu.org/pipermail/autoconf/1999-October/008311.html
553 dnl partly rewritten by Peter Stamfest <peter@stamfest.at>
555 dnl This determines, if struct tm containes tm_gmtoff field
556 dnl or we should use extern long int timezone.
558 dnl Add the following to your acconfig.h:
560 dnl /* Define if your struct tm has tm_gmtoff. */
561 dnl #undef HAVE_TM_GMTOFF
562 dnl #undef TM_GMTOFF
563 dnl
564 dnl /* Define if you don't have tm_gmtoff but do have the external timezone. */
565 dnl #undef HAVE_TIMEZONE
567 AC_DEFUN([GC_TIMEZONE], [
568 AC_REQUIRE([AC_STRUCT_TM])
569 AC_CACHE_CHECK([tm_gmtoff in struct tm], gq_cv_have_tm_gmtoff,
570 gq_cv_have_tm_gmtoff=no
571 AC_TRY_COMPILE([#include <time.h>
572 #include <$ac_cv_struct_tm>
573 ],
574 [struct tm t;
575 t.tm_gmtoff = 0;
576 exit(0);
577 ],
578 gq_cv_have_tm_gmtoff=yes
579 )
580 )
582 AC_CACHE_CHECK([__tm_gmtoff in struct tm], gq_cv_have___tm_gmtoff,
583 gq_cv_have___tm_gmtoff=no
584 AC_TRY_COMPILE([#include <time.h>
585 #include <$ac_cv_struct_tm>
586 ],
587 [struct tm t;
588 t.__tm_gmtoff = 0;
589 exit(0);
590 ],
591 gq_cv_have___tm_gmtoff=yes
592 )
593 )
595 if test "$gq_cv_have_tm_gmtoff" = yes ; then
596 AC_DEFINE(HAVE_TM_GMTOFF,1,[does tm have a tm_gmtoff member])
597 AC_DEFINE(TM_GMTOFF, tm_gmtoff,[the real name of tm_gmtoff])
598 elif test "$gq_cv_have___tm_gmtoff" = yes ; then
599 AC_DEFINE(HAVE_TM_GMTOFF)
600 AC_DEFINE(TM_GMTOFF, __tm_gmtoff)
601 else
602 AC_CACHE_CHECK(for timezone, ac_cv_var_timezone,
603 [AC_TRY_LINK([
604 #include <time.h>
605 extern long int timezone;
606 ],
607 [long int l = timezone;],
608 ac_cv_var_timezone=yes,
609 ac_cv_var_timezone=no)])
610 if test $ac_cv_var_timezone = yes; then
611 AC_DEFINE(HAVE_TIMEZONE,1,[is there an external timezone variable instead ?])
612 fi
613 fi
614 ])