X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=acinclude.m4;h=5ea34f0f54a3047beb0f8b89c1b8706747d985fc;hp=062216a2b689aed8355d73ff1da4ef4d56d89f9c;hb=30ae34dc4cb5e8c94fb1f13b0a089494256649af;hpb=c2588300e3b61df51b846dd79d90b3da9628d0cb diff --git a/acinclude.m4 b/acinclude.m4 index 062216a..5ea34f0 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -9,8 +9,8 @@ dnl if this check fails set the environment variable EX_CHECK_ALL_ERR to YES dnl and prints out a helful message dnl dnl -dnl EX_CHECK_ALL(library, function, header, pkgconf name, tested-version, homepage) -dnl $1 $2 $3 $4 $5 $6 +dnl EX_CHECK_ALL(library, function, header, pkgconf name, tested-version, homepage, cppflags) +dnl $1 $2 $3 $4 $5 $6 $7 dnl dnl AC_DEFUN([EX_CHECK_ALL], @@ -19,7 +19,10 @@ AC_DEFUN([EX_CHECK_ALL], EX_CHECK_STATE=NO ex_check_save_LIBS=${LIBS} ex_check_save_CPPFLAGS=${CPPFLAGS} - ex_check_save_LDFLAGS=${LDPFLAGS} + ex_check_save_LDFLAGS=${LDFLAGS} + if test "x$7" != "x"; then + CPPFLAGS="$CPPFLAGS -I$7" + fi dnl try compiling naked first AC_CHECK_LIB($1,$2, [ AC_CHECK_HEADER($3,[LIBS="-l$1 ${LIBS}";EX_CHECK_STATE=YES],[])],[]) @@ -33,8 +36,11 @@ AC_DEFUN([EX_CHECK_ALL], LDFLAGS=${LDFLAGS}" "`$PKGCONFIG --libs-only-other $4` LIBS=${LIBS}" "`$PKGCONFIG --libs-only-l $4` dnl remove the cached value and test again - unset ac_cv_lib_$1_$2 - AC_CHECK_LIB($1,$2,[ AC_CHECK_HEADER($3,[EX_CHECK_STATE=YES],[])],[]) + unset ac_cv_lib_`echo $1 | sed ['s/[^_a-zA-Z0-9]/_/g;s/^[0-9]/_/']`_$2 + AC_CHECK_LIB($1,$2,[ + unset ac_cv_header_`echo $3 | sed ['s/[^_a-zA-Z0-9]/_/g;s/^[0-9]/_/']` + AC_CHECK_HEADER($3,[EX_CHECK_STATE=YES],[]) + ],[]) else AC_MSG_WARN([ ---------------------------------------------------------------------------- @@ -59,7 +65,7 @@ AC_DEFUN([EX_CHECK_ALL], You can find also find an archive copy on - http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs + http://oss.oetiker.ch/rrdtool/pub/libs The last tested version of $4 is $5. @@ -77,6 +83,7 @@ AC_DEFUN([EX_CHECK_ALL], AC_LANG_POP(C) ] ) + dnl dnl Ptherad check from http://autoconf-archive.cryp.to/acx_pthread.m4 dnl @@ -282,6 +289,12 @@ if test "x$acx_pthread_ok" = xyes; then case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) x_rflag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) x_rflag="-D_REENTRANT";; + *-linux*) + if test x"$PTHREAD_CFLAGS" = "x-pthread"; then + # For Linux/gcc "-pthread" implies "-lpthread". We need, however, to make this explicit + # in PTHREAD_LIBS such that a shared library to be built properly depends on libpthread. + PTHREAD_LIBS="-lpthread $PTHREAD_LIBS" + fi;; esac AC_MSG_RESULT(${x_rflag}) if test "x$x_rflag" != xno; then @@ -349,6 +362,12 @@ AC_CACHE_VAL([rd_cv_ieee_$2], # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF) #endif +/* solaris 10 it defines isnan such that only forte can compile it ... bad bad */ +#if (defined(HAVE_ISNAN) && defined(isnan) && defined(HAVE_FPCLASS)) +# undef isnan +# define isnan(a) (fpclass(a) == FP_SNAN || fpclass(a) == FP_QNAN) +#endif + /* Digital UNIX */ #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H)) # define HAVE_ISINF 1 @@ -373,21 +392,21 @@ AC_CACHE_VAL([rd_cv_ieee_$2], #include int main(void){ - double nan,inf,c,zero; + double rrdnan,rrdinf,rrdc,rrdzero; $4; /* some math to see if we get a floating point exception */ - zero=sin(0.0); /* don't let the compiler optimize us away */ - nan=0.0/zero; /* especially here */ - inf=1.0/zero; /* and here. I want to know if it can do the magic */ + rrdzero=sin(0.0); /* don't let the compiler optimize us away */ + rrdnan=0.0/rrdzero; /* especially here */ + rrdinf=1.0/rrdzero; /* and here. I want to know if it can do the magic */ /* at run time without sig fpe */ - c = inf + nan; - c = inf / nan; - if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;} - if (nan == nan) {printf ("nan == nan ... "); return 1;} - if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;} - if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;} - if (! inf > 0) {printf ("not inf > 0 ... "); return 1;} - if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;} + rrdc = rrdinf + rrdnan; + rrdc = rrdinf / rrdnan; + if (! isnan(rrdnan)) {printf ("not isnan(NaN) ... "); return 1;} + if (rrdnan == rrdnan) {printf ("nan == nan ... "); return 1;} + if (! isinf(rrdinf)) {printf ("not isinf(oo) ... "); return 1;} + if (! isinf(-rrdinf)) {printf ("not isinf(-oo) ... "); return 1;} + if (! rrdinf > 0) {printf ("not inf > 0 ... "); return 1;} + if (! -rrdinf < 0) {printf ("not -inf < 0 ... "); return 1;} return 0; }]])],[rd_cv_ieee_$2=yes],[rd_cv_ieee_$2=no],[:])]) dnl these we run regardles is cached or not @@ -430,10 +449,144 @@ AC_IEEE([out of the box], works, , , , PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"], AC_MSG_ERROR([ Your Compiler does not do propper IEEE math ... Please find out how to -make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch). +make IEEE math work with your compiler and let me know (tobi@oetiker.ch). Check config.log to see what went wrong ... ]))])])])])])])])])]) AC_LANG_POP(C) ]) + + +dnl a macro to check for ability to create python extensions +dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) +dnl function also defines PYTHON_INCLUDES +AC_DEFUN([AM_CHECK_PYTHON_HEADERS], +[AC_REQUIRE([AM_PATH_PYTHON]) +AC_MSG_CHECKING(for headers required to compile python extensions) +dnl deduce PYTHON_INCLUDES +py_prefix=`$PYTHON -c "import sys; print sys.prefix"` +py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` +PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" +if test "$py_prefix" != "$py_exec_prefix"; then + PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" +fi +AC_SUBST(PYTHON_INCLUDES) +dnl check if the headers exist: +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" +AC_TRY_CPP([#include ],dnl +[AC_MSG_RESULT(found) +$1],dnl +[AC_MSG_RESULT(not found) +$2]) +CPPFLAGS="$save_CPPFLAGS" +]) + +dnl a macro to add some color to the build process. +dnl CONFIGURE_PART(MESSAGE) + +AC_DEFUN([CONFIGURE_PART],[ +case $TERM in + # for the most important terminal types we directly know the sequences + xterm|xterm*|vt220|vt220*) + T_MD=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' /dev/null` + T_ME=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' /dev/null` + ;; + vt100|vt100*|cygwin) + T_MD=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' /dev/null` + T_ME=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' /dev/null` + ;; + *) + T_MD='' + T_ME='' + ;; +esac + AC_MSG_RESULT() + AC_MSG_RESULT([${T_MD}$1${T_ME}]) +]) + +dnl check + +AC_DEFUN([CHECK_FOR_WORKING_MS_ASYNC], [ +AC_MSG_CHECKING([if msync with MS_ASYNC updates the files mtime]) +AC_CACHE_VAL([rd_cv_ms_async], +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include +#include +#include +#include +#include +#include +int main(void){ + int fd; + struct stat stbuf; + char *addr; + int res; + char temp[] = "mmaptestXXXXXX"; + struct utimbuf newtime; + + time_t create_ts; + fd = mkstemp(temp); + if (fd == -1){ + perror(temp); + return 1; + } + write(fd,"12345\n", 6); + stat(temp, &stbuf); + create_ts = stbuf.st_mtime; + newtime.actime = 0; + newtime.modtime = 0; + utime(temp,&newtime); + addr = mmap(NULL, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (addr == MAP_FAILED) { + perror("mmap"); + goto bad_exit; + } + addr[0]='x'; + res = msync(addr, 4, MS_ASYNC); + if (res == -1) { + perror("msync"); + goto bad_exit; + } + res = close(fd); + if (res == -1) { + perror("close"); + goto bad_exit; + } + /* The ASYNC means that we schedule the msync and return immediately. + Since we want to see if the modification time is updated upon + msync(), we have to make sure that our asynchronous request + completes before we stat below. In a real application, the + request would be completed at a random time in the future + but for this test we do not want to wait an arbitrary amount of + time, so force a commit now. */ + sync(); + stat(temp, &stbuf); + if (create_ts > stbuf.st_mtime){ + goto bad_exit; + } + unlink(temp); + return 0; + bad_exit: + unlink(temp); + return 1; +} +]])],[rd_cv_ms_async=ok],[rd_cv_ms_async=broken],[:])]) + + +if test "${rd_cv_ms_async}" = "ok"; then + AC_MSG_RESULT(yes) +else + AC_DEFINE_UNQUOTED(HAVE_BROKEN_MS_ASYNC, 1 , [set to 1 if msync with MS_ASYNC fails to update mtime]) + AC_MSG_RESULT(no) + AC_MSG_WARN([With mmap access, your platform fails to update the files]) + AC_MSG_WARN([mtime. RRDtool will work around this problem by calling utime on each]) + AC_MSG_WARN([file it opens for rw access.]) + sleep 2 +fi + +]) +