]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
Check also for log and pow functions in configure
authorMiroslav Lichvar <mlichvar@redhat.com>
Sat, 12 Dec 2009 19:15:51 +0000 (20:15 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Sun, 13 Dec 2009 14:00:13 +0000 (15:00 +0100)
configure

index f044d48af5e4137f7b0c0fbd9e417d02945d719a..a709bf9f7131e1a1b83cea313ce56772d8b3b531 100755 (executable)
--- a/configure
+++ b/configure
@@ -32,43 +32,6 @@ fi
 # ======================================================================
 # FUNCTIONS
 
-#{{{ test_for_sqrt
-test_for_sqrt () {
-# 0 : doesn't need -lm
-# 1 : needs -lm
-# 2 : doesn't even link with -lm
-
-  cat >docheck.c <<EOF;
-#include <math.h>
-int main(int argc, char **argv) {
-  return (int) sqrt((double)argc);
-}
-EOF
-
-  ${MYCC} ${MYCFLAGS} ${MYCPPFLAGS} -c -o docheck.o docheck.c >/dev/null 2>&1
-  if [ $? -eq 0 ]
-  then
-    ${MYCC} ${MYCFLAGS} ${MYCPPFLAGS} -o docheck docheck.o >/dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
-      result=0
-    else
-      ${MYCC} ${MYCFLAGS} ${MYCPPFLAGS} -o docheck docheck.o -lm >/dev/null 2>&1
-      if [ $? -eq 0 ]
-      then
-        result=1
-      else
-        result=2
-      fi
-    fi
-  else
-    result=2
-  fi
-
-  rm -f docheck.c docheck.o docheck
-  echo $result
-}
-#}}}
 #{{{ test_code
 test_code () {
   name=$1
@@ -354,23 +317,18 @@ case $SYSTEM in
     ;;
 esac
 
-printf "Checking if sqrt() needs -lm : "
-case `test_for_sqrt`
-in
-0)
-  printf "No\n"
+MATHCODE='return (int) pow(2.0, log(sqrt((double)argc)));'
+if test_code 'math' 'math.h' '' '' "$MATHCODE"; then
   LIBS=""
-;;
-1)
-  printf "Yes\n"
-  LIBS="-lm"
-;;
-*)
-  printf "\nCan't compile/link a program which uses sqrt(), bailing out\n"
-  exit 1
-;;
-esac
-
+else
+  if test_code 'math in -lm' 'math.h' '' '-lm' "$MATHCODE"; then
+    LIBS="-lm"
+  else
+    printf "Can't compile/link a program which uses sqrt(), log(), pow(), bailing out\n"
+    exit 1
+  fi
+fi
+  
 if test_code '<stdint.h>' 'stdint.h' '' '' ''; then
   SYSDEFS="${SYSDEFS} -DHAS_STDINT_H"
 fi