Hi Ben, A week ago I promised this: > OK, I can provide a macro that just tests whether floorf() needs libm.
Here it is (committed): 2007-10-28 Bruno Haible <[EMAIL PROTECTED]> * m4/floorl.m4 (gl_FUNC_FLOORL_LIBS): New macro, extracted from gl_FUNC_FLOORL. Cache the result. (gl_FUNC_FLOORL): Use it. * m4/ceill.m4 (gl_FUNC_CEILL_LIBS): New macro, extracted from gl_FUNC_CEILL. Cache the result. (gl_FUNC_CEILL): Use it. * m4/floor.m4 (gl_FUNC_FLOOR_LIBS): New macro, extracted from gl_FUNC_FLOOR. Cache the result. (gl_FUNC_FLOOR): Use it. * m4/ceil.m4 (gl_FUNC_CEIL_LIBS): New macro, extracted from gl_FUNC_CEIL. Cache the result. (gl_FUNC_CEIL): Use it. * m4/floorf.m4 (gl_FUNC_FLOORF_LIBS): New macro, extracted from gl_FUNC_FLOORF. Cache the result. (gl_FUNC_FLOORF): Use it. * m4/ceilf.m4 (gl_FUNC_CEILF_LIBS): New macro, extracted from gl_FUNC_CEILF. Cache the result. (gl_FUNC_CEILF): Use it. *** m4/ceil.m4.orig 2007-10-29 01:56:35.000000000 +0100 --- m4/ceil.m4 2007-10-29 01:41:05.000000000 +0100 *************** *** 1,4 **** ! # ceil.m4 serial 1 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # ceil.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 7,24 **** AC_DEFUN([gl_FUNC_CEIL], [ dnl Test whether ceil() can be used without libm. ! CEIL_LIBM=? ! AC_TRY_LINK([ ! #ifndef __NO_MATH_INLINES ! # define __NO_MATH_INLINES 1 /* for glibc */ ! #endif ! #include <math.h> ! double x;], ! [x = ceil(x);], ! [CEIL_LIBM=]) if test "$CEIL_LIBM" = "?"; then ! save_LIBS="$LIBS" ! LIBS="$LIBS -lm" AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ --- 7,25 ---- AC_DEFUN([gl_FUNC_CEIL], [ dnl Test whether ceil() can be used without libm. ! gl_FUNC_CEIL_LIBS if test "$CEIL_LIBM" = "?"; then ! CEIL_LIBM= ! fi ! AC_SUBST([CEIL_LIBM]) ! ]) ! ! # Determines the libraries needed to get the ceil() function. ! # Sets CEIL_LIBM. ! AC_DEFUN([gl_FUNC_CEIL_LIBS], ! [ ! AC_CACHE_VAL([gl_func_ceil_libm], [ ! gl_func_ceil_libm=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ *************** *** 26,36 **** #include <math.h> double x;], [x = ceil(x);], ! [CEIL_LIBM="-lm"]) ! LIBS="$save_LIBS" ! fi ! if test "$CEIL_LIBM" = "?"; then ! CEIL_LIBM= ! fi ! AC_SUBST([CEIL_LIBM]) ]) --- 27,46 ---- #include <math.h> double x;], [x = ceil(x);], ! [gl_func_ceil_libm=]) ! if test "$gl_func_ceil_libm" = "?"; then ! save_LIBS="$LIBS" ! LIBS="$LIBS -lm" ! AC_TRY_LINK([ ! #ifndef __NO_MATH_INLINES ! # define __NO_MATH_INLINES 1 /* for glibc */ ! #endif ! #include <math.h> ! double x;], ! [x = ceil(x);], ! [gl_func_ceil_libm="-lm"]) ! LIBS="$save_LIBS" ! fi ! ]) ! CEIL_LIBM="$gl_func_ceil_libm" ]) *** m4/ceilf.m4.orig 2007-10-29 01:56:35.000000000 +0100 --- m4/ceilf.m4 2007-10-29 01:45:44.000000000 +0100 *************** *** 1,4 **** ! # ceilf.m4 serial 1 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # ceilf.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 13,19 **** AC_CHECK_DECLS([ceilf], , , [#include <math.h>]) if test "$ac_cv_have_decl_ceilf" = yes; then dnl Test whether ceilf() can be used without libm. ! CEILF_LIBM=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ --- 13,37 ---- AC_CHECK_DECLS([ceilf], , , [#include <math.h>]) if test "$ac_cv_have_decl_ceilf" = yes; then dnl Test whether ceilf() can be used without libm. ! gl_FUNC_CEILF_LIBS ! if test "$CEILF_LIBM" = "?"; then ! CEILF_LIBM= ! fi ! else ! HAVE_DECL_CEILF=0 ! AC_LIBOBJ([ceilf]) ! CEILF_LIBM= ! fi ! AC_SUBST([HAVE_DECL_CEILF]) ! AC_SUBST([CEILF_LIBM]) ! ]) ! ! # Determines the libraries needed to get the ceilf() function. ! # Sets CEILF_LIBM. ! AC_DEFUN([gl_FUNC_CEILF_LIBS], ! [ ! AC_CACHE_VAL([gl_func_ceilf_libm], [ ! gl_func_ceilf_libm=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ *************** *** 21,28 **** #include <math.h> float x;], [x = ceilf(x);], ! [CEILF_LIBM=]) ! if test "$CEILF_LIBM" = "?"; then save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ --- 39,46 ---- #include <math.h> float x;], [x = ceilf(x);], ! [gl_func_ceilf_libm=]) ! if test "$gl_func_ceilf_libm" = "?"; then save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ *************** *** 32,48 **** #include <math.h> float x;], [x = ceilf(x);], ! [CEILF_LIBM="-lm"]) LIBS="$save_LIBS" fi ! if test "$CEILF_LIBM" = "?"; then ! CEILF_LIBM= ! fi ! else ! HAVE_DECL_CEILF=0 ! AC_LIBOBJ([ceilf]) ! CEILF_LIBM= ! fi ! AC_SUBST([HAVE_DECL_CEILF]) ! AC_SUBST([CEILF_LIBM]) ]) --- 50,58 ---- #include <math.h> float x;], [x = ceilf(x);], ! [gl_func_ceilf_libm="-lm"]) LIBS="$save_LIBS" fi ! ]) ! CEILF_LIBM="$gl_func_ceilf_libm" ]) *** m4/ceill.m4.orig 2007-10-29 01:56:35.000000000 +0100 --- m4/ceill.m4 2007-10-29 01:53:36.000000000 +0100 *************** *** 1,4 **** ! # ceill.m4 serial 1 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # ceill.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 13,19 **** AC_CHECK_DECLS([ceill], , , [#include <math.h>]) if test "$ac_cv_have_decl_ceill" = yes; then dnl Test whether ceill() can be used without libm. ! CEILL_LIBM=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ --- 13,37 ---- AC_CHECK_DECLS([ceill], , , [#include <math.h>]) if test "$ac_cv_have_decl_ceill" = yes; then dnl Test whether ceill() can be used without libm. ! gl_FUNC_CEILL_LIBS ! if test "$CEILL_LIBM" = "?"; then ! CEILL_LIBM= ! fi ! else ! HAVE_DECL_CEILL=0 ! AC_LIBOBJ([ceill]) ! CEILL_LIBM= ! fi ! AC_SUBST([HAVE_DECL_CEILL]) ! AC_SUBST([CEILL_LIBM]) ! ]) ! ! # Determines the libraries needed to get the ceill() function. ! # Sets CEILL_LIBM. ! AC_DEFUN([gl_FUNC_CEILL_LIBS], ! [ ! AC_CACHE_VAL([gl_func_ceill_libm], [ ! gl_func_ceill_libm=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ *************** *** 21,28 **** #include <math.h> long double x;], [x = ceill(x);], ! [CEILL_LIBM=]) ! if test "$CEILL_LIBM" = "?"; then save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ --- 39,46 ---- #include <math.h> long double x;], [x = ceill(x);], ! [gl_func_ceill_libm=]) ! if test "$gl_func_ceill_libm" = "?"; then save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ *************** *** 32,48 **** #include <math.h> long double x;], [x = ceill(x);], ! [CEILL_LIBM="-lm"]) LIBS="$save_LIBS" fi ! if test "$CEILL_LIBM" = "?"; then ! CEILL_LIBM= ! fi ! else ! HAVE_DECL_CEILL=0 ! AC_LIBOBJ([ceill]) ! CEILL_LIBM= ! fi ! AC_SUBST([HAVE_DECL_CEILL]) ! AC_SUBST([CEILL_LIBM]) ]) --- 50,58 ---- #include <math.h> long double x;], [x = ceill(x);], ! [gl_func_ceill_libm="-lm"]) LIBS="$save_LIBS" fi ! ]) ! CEILL_LIBM="$gl_func_ceill_libm" ]) *** m4/floor.m4.orig 2007-10-29 01:56:35.000000000 +0100 --- m4/floor.m4 2007-10-29 01:36:54.000000000 +0100 *************** *** 1,4 **** ! # floor.m4 serial 1 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # floor.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 7,24 **** AC_DEFUN([gl_FUNC_FLOOR], [ dnl Test whether floor() can be used without libm. ! FLOOR_LIBM=? ! AC_TRY_LINK([ ! #ifndef __NO_MATH_INLINES ! # define __NO_MATH_INLINES 1 /* for glibc */ ! #endif ! #include <math.h> ! double x;], ! [x = floor(x);], ! [FLOOR_LIBM=]) if test "$FLOOR_LIBM" = "?"; then ! save_LIBS="$LIBS" ! LIBS="$LIBS -lm" AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ --- 7,25 ---- AC_DEFUN([gl_FUNC_FLOOR], [ dnl Test whether floor() can be used without libm. ! gl_FUNC_FLOOR_LIBS if test "$FLOOR_LIBM" = "?"; then ! FLOOR_LIBM= ! fi ! AC_SUBST([FLOOR_LIBM]) ! ]) ! ! # Determines the libraries needed to get the floor() function. ! # Sets FLOOR_LIBM. ! AC_DEFUN([gl_FUNC_FLOOR_LIBS], ! [ ! AC_CACHE_VAL([gl_func_floor_libm], [ ! gl_func_floor_libm=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ *************** *** 26,36 **** #include <math.h> double x;], [x = floor(x);], ! [FLOOR_LIBM="-lm"]) ! LIBS="$save_LIBS" ! fi ! if test "$FLOOR_LIBM" = "?"; then ! FLOOR_LIBM= ! fi ! AC_SUBST([FLOOR_LIBM]) ]) --- 27,46 ---- #include <math.h> double x;], [x = floor(x);], ! [gl_func_floor_libm=]) ! if test "$gl_func_floor_libm" = "?"; then ! save_LIBS="$LIBS" ! LIBS="$LIBS -lm" ! AC_TRY_LINK([ ! #ifndef __NO_MATH_INLINES ! # define __NO_MATH_INLINES 1 /* for glibc */ ! #endif ! #include <math.h> ! double x;], ! [x = floor(x);], ! [gl_func_floor_libm="-lm"]) ! LIBS="$save_LIBS" ! fi ! ]) ! FLOOR_LIBM="$gl_func_floor_libm" ]) *** m4/floorf.m4.orig 2007-10-29 01:56:35.000000000 +0100 --- m4/floorf.m4 2007-10-29 01:44:35.000000000 +0100 *************** *** 1,4 **** ! # floorf.m4 serial 1 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # floorf.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 13,19 **** AC_CHECK_DECLS([floorf], , , [#include <math.h>]) if test "$ac_cv_have_decl_floorf" = yes; then dnl Test whether floorf() can be used without libm. ! FLOORF_LIBM=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ --- 13,37 ---- AC_CHECK_DECLS([floorf], , , [#include <math.h>]) if test "$ac_cv_have_decl_floorf" = yes; then dnl Test whether floorf() can be used without libm. ! gl_FUNC_FLOORF_LIBS ! if test "$FLOORF_LIBM" = "?"; then ! FLOORF_LIBM= ! fi ! else ! HAVE_DECL_FLOORF=0 ! AC_LIBOBJ([floorf]) ! FLOORF_LIBM= ! fi ! AC_SUBST([HAVE_DECL_FLOORF]) ! AC_SUBST([FLOORF_LIBM]) ! ]) ! ! # Determines the libraries needed to get the floorf() function. ! # Sets FLOORF_LIBM. ! AC_DEFUN([gl_FUNC_FLOORF_LIBS], ! [ ! AC_CACHE_VAL([gl_func_floorf_libm], [ ! gl_func_floorf_libm=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ *************** *** 21,28 **** #include <math.h> float x;], [x = floorf(x);], ! [FLOORF_LIBM=]) ! if test "$FLOORF_LIBM" = "?"; then save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ --- 39,46 ---- #include <math.h> float x;], [x = floorf(x);], ! [gl_func_floorf_libm=]) ! if test "$gl_func_floorf_libm" = "?"; then save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ *************** *** 32,48 **** #include <math.h> float x;], [x = floorf(x);], ! [FLOORF_LIBM="-lm"]) LIBS="$save_LIBS" fi ! if test "$FLOORF_LIBM" = "?"; then ! FLOORF_LIBM= ! fi ! else ! HAVE_DECL_FLOORF=0 ! AC_LIBOBJ([floorf]) ! FLOORF_LIBM= ! fi ! AC_SUBST([HAVE_DECL_FLOORF]) ! AC_SUBST([FLOORF_LIBM]) ]) --- 50,58 ---- #include <math.h> float x;], [x = floorf(x);], ! [gl_func_floorf_libm="-lm"]) LIBS="$save_LIBS" fi ! ]) ! FLOORF_LIBM="$gl_func_floorf_libm" ]) *** m4/floorl.m4.orig 2007-10-29 01:56:35.000000000 +0100 --- m4/floorl.m4 2007-10-29 01:49:49.000000000 +0100 *************** *** 1,4 **** ! # floorl.m4 serial 1 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # floorl.m4 serial 2 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 13,19 **** AC_CHECK_DECLS([floorl], , , [#include <math.h>]) if test "$ac_cv_have_decl_floorl" = yes; then dnl Test whether floorl() can be used without libm. ! FLOORL_LIBM=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ --- 13,37 ---- AC_CHECK_DECLS([floorl], , , [#include <math.h>]) if test "$ac_cv_have_decl_floorl" = yes; then dnl Test whether floorl() can be used without libm. ! gl_FUNC_FLOORL_LIBS ! if test "$FLOORL_LIBM" = "?"; then ! FLOORL_LIBM= ! fi ! else ! HAVE_DECL_FLOORL=0 ! AC_LIBOBJ([floorl]) ! FLOORL_LIBM= ! fi ! AC_SUBST([HAVE_DECL_FLOORL]) ! AC_SUBST([FLOORL_LIBM]) ! ]) ! ! # Determines the libraries needed to get the floorl() function. ! # Sets FLOORL_LIBM. ! AC_DEFUN([gl_FUNC_FLOORL_LIBS], ! [ ! AC_CACHE_VAL([gl_func_floorl_libm], [ ! gl_func_floorl_libm=? AC_TRY_LINK([ #ifndef __NO_MATH_INLINES # define __NO_MATH_INLINES 1 /* for glibc */ *************** *** 21,28 **** #include <math.h> long double x;], [x = floorl(x);], ! [FLOORL_LIBM=]) ! if test "$FLOORL_LIBM" = "?"; then save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ --- 39,46 ---- #include <math.h> long double x;], [x = floorl(x);], ! [gl_func_floorl_libm=]) ! if test "$gl_func_floorl_libm" = "?"; then save_LIBS="$LIBS" LIBS="$LIBS -lm" AC_TRY_LINK([ *************** *** 32,48 **** #include <math.h> long double x;], [x = floorl(x);], ! [FLOORL_LIBM="-lm"]) LIBS="$save_LIBS" fi ! if test "$FLOORL_LIBM" = "?"; then ! FLOORL_LIBM= ! fi ! else ! HAVE_DECL_FLOORL=0 ! AC_LIBOBJ([floorl]) ! FLOORL_LIBM= ! fi ! AC_SUBST([HAVE_DECL_FLOORL]) ! AC_SUBST([FLOORL_LIBM]) ]) --- 50,58 ---- #include <math.h> long double x;], [x = floorl(x);], ! [gl_func_floorl_libm="-lm"]) LIBS="$save_LIBS" fi ! ]) ! FLOORL_LIBM="$gl_func_floorl_libm" ])