bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

play nice with AC_CACHE_CHECK


From: Ralf Wildenhues
Subject: play nice with AC_CACHE_CHECK
Date: Wed, 22 Feb 2006 21:33:48 +0100
User-agent: Mutt/1.5.9i

1) readline.m4 gives different results with cached reruns: for example,
on x86_64-unknown-linux-gnu:

./configure -C
        -> LIBREADLINE="-lreadline -lncurses"
./config.status --recheck
        -> LIBREADLINE="-lreadline"

This is because the commands to set the cache variable
`gl_cv_lib_readline' also adjust LIBREADLINE and LTLIBREADLINE.

The patch below fixes that by (ab)using the cache variable to hold the
test result contents, making the COMMANDS-TO-SET-IT argument of the
AC_CACHE_CHECK macro side-effect free.  Do you think the cache variable
should be renamed (for users keeping the cache over the update; not that
it was working well before anyway)?


2) Similar with getaddrinfo.m4, except there is no need to store
additional information here.  Beware, the getaddrinfo part of the
patch is completely untested.

Cheers,
Ralf

        * readline.m4 (gl_FUNC_READLINE): Rewrite the cached part of the
        test to be side-effect free by storing the result in the cache
        variable gl_cv_lib_readline, and moving the assignment of
        LIBREADLINE and LTLIBREADLINE outside the COMMANDS-TO-SET-IT.
        * getaddrinfo.m4 (gl_GETADDRINFO): Likewise, set `LIBS'/call
        `AC_LIBOBJ' outside the COMMANDS-TO-SET-IT of AC_CACHE_CHECK.

Index: m4/readline.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/readline.m4,v
retrieving revision 1.4
diff -u -r1.4 readline.m4
--- m4/readline.m4      9 Jan 2006 21:42:56 -0000       1.4
+++ m4/readline.m4      22 Feb 2006 19:22:42 -0000
@@ -42,23 +42,18 @@
       AC_TRY_LINK([#include <stdio.h>
 #include <readline/readline.h>],
         [readline((char*)0);],
-        gl_cv_lib_readline=yes)
-      if test "$gl_cv_lib_readline" = yes; then
-        if test -n "$extra_lib"; then
-          LIBREADLINE="$LIBREADLINE -l$extra_lib"
-          LTLIBREADLINE="$LTLIBREADLINE -l$extra_lib"
-        fi
-        break
+        [gl_cv_lib_readline=" -l$extra_lib"])
+      if test "$gl_cv_lib_readline" != no; then
+       break
       fi
     done
     LIBS="$am_save_LIBS"
   ])
 
-  if test "$gl_cv_lib_readline" = yes; then
+  if test "$gl_cv_lib_readline" != no; then
     AC_DEFINE(HAVE_READLINE, 1, [Define if you have the readline library.])
-  fi
-
-  if test "$gl_cv_lib_readline" = yes; then
+    LIBREADLINE="$LIBREADLINE$gl_cv_lib_readline"
+    LTLIBREADLINE="$LTLIBREADLINE$gl_cv_lib_readline"
     AC_MSG_CHECKING([how to link with libreadline])
     AC_MSG_RESULT([$LIBREADLINE])
   else
Index: m4/getaddrinfo.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/getaddrinfo.m4,v
retrieving revision 1.14
diff -u -r1.14 getaddrinfo.m4
--- m4/getaddrinfo.m4   16 Feb 2006 09:48:07 -0000      1.14
+++ m4/getaddrinfo.m4   22 Feb 2006 19:34:02 -0000
@@ -22,12 +22,12 @@
 #endif
 ], [getaddrinfo(0, 0, 0, 0);], gl_cv_w32_getaddrinfo=yes)
       LIBS="$am_save_LIBS"
-      if test "$gl_cv_w32_getaddrinfo" = "yes"; then
-       LIBS="$LIBS -lws2_32"
-      else
-       AC_LIBOBJ(getaddrinfo)
-      fi
-    ])])
+    ])
+    if test "$gl_cv_w32_getaddrinfo" = "yes"; then
+      LIBS="$LIBS -lws2_32"
+    else
+      AC_LIBOBJ(getaddrinfo)
+    fi])
 
   AC_REPLACE_FUNCS(gai_strerror)
   gl_PREREQ_GETADDRINFO




reply via email to

[Prev in Thread] Current Thread [Next in Thread]