X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=acinclude.m4;h=38ee0c29f69347d63e9e6f25d50d116822925558;hp=34ec3310e7903426451dc82466523bd5cc75b897;hb=2ba0dac41cd82d69b612b5b4526f6e6f85c8abdc;hpb=d8c6bad0b7fa3852c16c1bdd65f9ce079e6920c7 diff --git a/acinclude.m4 b/acinclude.m4 index 34ec331..38ee0c2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -9,57 +9,81 @@ 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], [ + AC_LANG_PUSH(C) EX_CHECK_STATE=NO + ex_check_save_LIBS=${LIBS} + ex_check_save_CPPFLAGS=${CPPFLAGS} + 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],[ - dnl now asking pkg-config for help - AC_PATH_PROG(PKGCONFIG,pkg-config,no) - if test "$PKGCONFIG" != "no"; then + AC_CHECK_HEADER($3,[LIBS="-l$1 ${LIBS}";EX_CHECK_STATE=YES],[])],[]) + if test $EX_CHECK_STATE = NO; then + dnl now asking pkg-config for help + AC_CHECK_PROGS(PKGCONFIG,[pkg-config],no) + if test "$PKGCONFIG" != "no"; then if $PKGCONFIG --exists $4; then CPPFLAGS=${CPPFLAGS}" "`$PKGCONFIG --cflags $4` - LDFLAGS=${LDFLAGS}" "`$PKGCONFIG --libs-only-l $4` - LIBS=${LIBS}" " `$PKGCONFIG --libs-only-other $4` - AC_CHECK_LIB($1,$2,[ AC_CHECK_HEADER($3,[LIBS="-l$1 ${LIBS};EX_CHECK_STATE=YES"],[])],[]) + LDFLAGS=${LDFLAGS}" "`$PKGCONFIG --libs-only-L $4` + 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_`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([ ---------------------------------------------------------------------------- * I found a copy of pkgconfig, but there is no $4.pc file around. You may want to set the PKG_CONFIG_PATH variable to point to its location. +---------------------------------------------------------------------------- ]) fi - fi - ])],[]) - + fi + fi if test ${EX_CHECK_STATE} = NO; then AC_MSG_WARN([ ---------------------------------------------------------------------------- * I could not find a working copy of $4. Check config.log for hints on why - this is the case. Maybe you need to set LDFLAGS appropriately so that the - linker can find lib$1. If you have not installed $4, you can get it - either from its original home on + this is the case. Maybe you need to set LDFLAGS and CPPFLAGS appropriately + so that compiler and the linker can find lib$1 and its header files. If + you have not installed $4, you can get it either from its original home on $6 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. + + LIBS=$LIBS + LDFLAGS=$LDFLAGS + CPPFLAGS=$CPPFLAGS + ---------------------------------------------------------------------------- ]) EX_CHECK_ALL_ERR=YES + LIBS="${ex_check_save_LIBS}" + CPPFLAGS="${ex_check_save_CPPFLAGS}" + LDFLAGS="${ex_check_save_LDFLAGS}" fi + AC_LANG_POP(C) ] ) + dnl dnl Ptherad check from http://autoconf-archive.cryp.to/acx_pthread.m4 dnl @@ -111,8 +135,7 @@ dnl @license GPLWithACException AC_DEFUN([ACX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) -AC_LANG_SAVE -AC_LANG_C +AC_LANG_PUSH(C) acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h @@ -224,11 +247,9 @@ for flag in $acx_pthread_flags; do # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. - AC_TRY_LINK([#include ], - [pthread_t th; pthread_join(th, 0); + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], - [acx_pthread_ok=yes]) + pthread_create(0,0,0,0); pthread_cleanup_pop(0); ]])],[acx_pthread_ok=yes],[]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" @@ -254,8 +275,7 @@ if test "x$acx_pthread_ok" = xyes; then AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - AC_TRY_LINK([#include ], [int attr=$attr;], - [attr_name=$attr; break]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[int attr=$attr;]])],[attr_name=$attr; break],[]) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then @@ -265,14 +285,20 @@ if test "x$acx_pthread_ok" = xyes; then fi AC_MSG_CHECKING([if more special flags are required for pthreads]) - flag=no + x_rflag=no case "${host_cpu}-${host_os}" in - *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; - *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; + *-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(${flag}) - if test "x$flag" != xno; then - PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + AC_MSG_RESULT(${x_rflag}) + if test "x$x_rflag" != xno; then + PTHREAD_CFLAGS="$x_rflag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" @@ -296,5 +322,227 @@ else acx_pthread_ok=no $2 fi -AC_LANG_RESTORE +AC_LANG_POP(C) ])dnl ACX_PTHREAD + + +dnl +dnl determine how to get IEEE math working +dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES, +dnl FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]) +dnl + +dnl substitute them in all the files listed in AC_OUTPUT +AC_SUBST(PERLFLAGS) + +AC_DEFUN([AC_IEEE], [ +AC_MSG_CHECKING([if IEEE math works $1]) +AC_CACHE_VAL([rd_cv_ieee_$2], +[AC_RUN_IFELSE([AC_LANG_SOURCE([[$3 + +#if HAVE_MATH_H +# include +#endif + +#if HAVE_FLOAT_H +# include +#endif + +#if HAVE_IEEEFP_H +# include +#endif + +#if HAVE_FP_CLASS_H +# include +#endif + +/* Solaris */ +#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS)) +# define HAVE_ISINF 1 +# 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 +# define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF) +#endif + +/* AIX */ +#if (! defined(HAVE_ISINF) && defined(HAVE_CLASS)) +# define HAVE_ISINF 1 +# define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF) +#endif + +#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF)) +# define HAVE_ISINF 1 +# define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF) +#endif + +#if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE)) +# define HAVE_ISINF 1 +# define isinf(a) (fpclassify(a) == FP_INFINITE) +#endif + +#include +int main(void){ + double rrdnan,rrdinf,rrdc,rrdzero; + $4; + /* some math to see if we get a floating point exception */ + 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 */ + 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 +if test x${rd_cv_ieee_$2} = "xyes"; then + AC_MSG_RESULT(yes) + $5 +else + AC_MSG_RESULT(no) + $6 +fi + +]) + +AC_DEFUN([AC_FULL_IEEE],[ +AC_LANG_PUSH(C) +_cflags=${CFLAGS} +AC_IEEE([out of the box], works, , , , + [CFLAGS="$_cflags -ieee" + AC_IEEE([with the -ieee switch], switch, , , , + [CFLAGS="$_cflags -qfloat=nofold" + AC_IEEE([with the -qfloat=nofold switch], nofold, , , , + [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide" + AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , , + [CFLAGS="$_cflags -mieee" + AC_IEEE([with the -mieee switch], mswitch, , , , + [CFLAGS="$_cflags -q float=rndsngl" + AC_IEEE([with the -q float=rndsngl switch], qswitch, , , , + [CFLAGS="$_cflags -OPT:IEEE_NaN_inf=ON" + AC_IEEE([with the -OPT:IEEE_NaN_inf=ON switch], ieeenaninfswitch, , , , + [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON" + AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , , + [CFLAGS=$_cflags + AC_IEEE([with fpsetmask(0)], mask, + [#include ], [fpsetmask(0)], + [AC_DEFINE(MUST_DISABLE_FPMASK) + PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"], + [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe, + [#include ], [signal(SIGFPE,SIG_IGN)], + [AC_DEFINE(MUST_DISABLE_SIGFPE) + 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 (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 --------------------------------------------------------------------------- +dnl CF_DISABLE_ECHO version: 10 updated: 2003/04/17 22:27:11 +dnl --------------- +dnl stolen from xterm aclocal.m4 +dnl +dnl You can always use "make -n" to see the actual options, but it's hard to +dnl pick out/analyze warning messages when the compile-line is long. +dnl +dnl Sets: +dnl ECHO_LT - symbol to control if libtool is verbose +dnl ECHO_LD - symbol to prefix "cc -o" lines +dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o) +dnl SHOW_CC - symbol to put before explicit "cc -c" lines +dnl ECHO_CC - symbol to put before any "cc" line +dnl +AC_DEFUN([CF_DISABLE_ECHO],[ +AC_MSG_CHECKING(if you want to see long compiling messages) +CF_ARG_DISABLE(echo, + [ --disable-echo display "compiling" commands], + [ + ECHO_LT='--silent' + ECHO_LD='@echo linking [$]@;' + RULE_CC=' @echo compiling [$]<' + SHOW_CC=' @echo compiling [$]@' + ECHO_CC='@' +],[ + ECHO_LT='' + ECHO_LD='' + RULE_CC='# compiling' + SHOW_CC='# compiling' + ECHO_CC='' +]) +AC_MSG_RESULT($enableval) +AC_SUBST(ECHO_LT) +AC_SUBST(ECHO_LD) +AC_SUBST(RULE_CC) +AC_SUBST(SHOW_CC) +AC_SUBST(ECHO_CC) +])dnl