Fixed bug #1946138 to stop ignoring CFLAGS in the sqrt configure test
authorDan Fandrich <dan@coneharvesters.com>
Tue, 23 Dec 2008 08:24:46 +0000 (00:24 -0800)
committerDan Fandrich <dan@coneharvesters.com>
Tue, 23 Dec 2008 08:24:46 +0000 (00:24 -0800)
ChangeLog
NEWS
configure.ac
libexif/Makefile.am

index 5e072a5..7fc9f46 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-12-22  Dan Fandrich <dan@coneharvesters.com>
 
        * po/vi.po: Updated Vietnamese translation by Clytie Siddall
+        * Fixed bug #1946138 to stop ignoring CFLAGS in the sqrt configure test
 
 2008-11-25  Dan Fandrich <dan@coneharvesters.com>
 
diff --git a/NEWS b/NEWS
index 3278ef7..3bc51ce 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ libexif-0.6.x:
   * Access to the raw EXIF data through the ExifEntry structure members is
     now officially documented
   * Fixed some Olympus/Sanyo MakerNote interpretations
+  * Fixed bug #1946138 to stop ignoring CFLAGS in the sqrt configure test
 
 libexif-0.6.17 (2008-11-06):
   * Updated translations: cs, de, pl, sk, vi
index e6309de..4b387e1 100644 (file)
@@ -94,31 +94,45 @@ dnl ---------------------------------------------------------------------------
 dnl Whether -lm is required for our math functions
 dnl ---------------------------------------------------------------------------
 
-# we need sqrt and pow, but checking for sqrt should be sufficient
-AC_ARG_VAR([MATHLIBS],[The libraries required for mathematical functions, e.g. -lm])
-if test "x$MATHLIBS" = "x"; then
-       # We must not compile with -Wall -Werror here:
-       # char *sqrt() conflicts with double sin(const double xx) in any case.
-       CFLAGS_save="$CFLAGS"
-       CPPFLAGS_save="$CPPFLAGS"
-       CPPFLAGS=""
-       CFLAGS=""
-       AC_CHECK_FUNC([sqrt],[
-               MATHLIBS=""
+# we need sqrt and pow which may be in libm
+# We cannot use AC_CHECK_FUNC because if CFLAGS contains
+# -Wall -Werror here the check fails because
+# char *sqrt() conflicts with double sqrt(double xx)
+
+# Start by assuming -lm is needed, because it's possible that the little
+# test program below will be optimized to in-line floating point code that
+# doesn't require -lm, whereas the library itself cannot be so optimized
+# (this actually seems to be the case on x86 with gcc 4.2). Assuming the
+# reverse means that -lm could be needed but wouldn't be detected below.
+
+LIBS_orig="$LIBS"
+LIBS="$LIBS -lm"
+AC_MSG_CHECKING([for math functions in libm])
+AC_LINK_IFELSE([
+       #include <math.h>
+       int main() {
+         double s = sqrt(0);
+         double p = pow(s,s);
+         return (int)p;
+       }
+], [AC_MSG_RESULT(yes)], [
+       AC_MSG_RESULT(no)
+       LIBS="$LIBS_orig"
+       AC_MSG_CHECKING([for math functions without libm])
+       AC_LINK_IFELSE([
+               #include <math.h>
+               int main() {
+                 double s = sqrt(0);
+                 double p = pow(s,s);
+                 return (int)p;
+               }
+       ], [
+               AC_MSG_RESULT(yes)
        ],[
-               AC_CHECK_LIB([m],[sqrt],[
-                       MATHLIBS="-lm"
-               ],[
-                       AC_MSG_ERROR([
-*** Could not find sqrt() function
-])
-               ])
+               AC_MSG_RESULT(no)
+               AC_MSG_ERROR([*** Could not find sqrt() & pow() functions])
        ])
-       CFLAGS="$CFLAGS_save"
-       CPPFLAGS="$CPPFLAGS_save"
-fi
-AC_SUBST([MATHLIBS])
-
+])
 
 # doc support
 GP_CHECK_DOC_DIR
index 0b39504..163736e 100644 (file)
@@ -37,7 +37,6 @@ libexif_la_DEPENDENCIES = \
        libmnote-olympus.la     \
        libmnote-pentax.la
 libexif_la_LIBADD =                    \
-       $(MATHLIBS)                     \
        $(LTLIBINTL)                    \
        libmnote-canon.la               \
        libmnote-fuji.la        \