Hi,

this fixes a bug when running configure scripts with compilers which
generates object-files where the suffix is not the default ".o":
_AC_OBJEXT uses AC_COMPILE_IFELSE, but AC_COMPILE_IFELSE contains this
snippet of code

    [...]
    if AC_TRY_EVAL(ac_compile) && test -s conftest.$ac_objext; then
    [...]

I.e., the AC_COMPILE_IFELSE macro depends on the value of $ac_objext
(which defaults to .o before _AC_OBJEXT is called). This means
compilers using .obj or .xcoff, for instance, will fail the "test -s"
case, which makes AC_COMPILE_IFELSE fail, which in turn makes
_AC_OBJEXT abort the configure script with an AC_MSG_ERROR.

BTW, looking some more at the code, this looks like a hornet's nest of
bugs. IMO, $ac_objext shouldn't have a default value at all, and
AC_COMPILE_IFELSE should AC_REQUIRE the _AC_OBJEXT macro -- since the
value of $ac_objext will not be correct until _AC_OBJEXT is called
anyhow for compilers not using the .o suffix for object files.

But this will in turn lead to other "dependency deadlock" problems,
since AC_COMPILE_IFELSE is used to detect a working compiler, and a
working compiler is needed by _AC_OBJEXT to detect the object
extension suffix.

In addition, it also seems to me (after a quick glance) that
_AC_EXEEXT have some of the same problems; it calls AC_LINK_IFELSE,
but AC_LINK_IFELSE depends on the value of $ac_exeext being
correct. There's an ugly workaround for this in the _AC_EXEEXT macro
-- the value of $ac_exeext is explicitly set to .exe if CYGWIN,
MINGW32 or EMXOS2 is detected.

As I said, a hornet's nest. Was anyone on the list aware of these
bugs?

Regards,
Morten

=========================================================

2000-08-30  Morten Eriksen  <[EMAIL PROTECTED]>

        * acspecific.m4: _AC_OBJEXT was using AC_COMPILE_IFELSE, but
        AC_COMPILE_IFELSE depends on the value of $ac_objext. This
        dependency deadlock is broken by making _AC_OBJEXT independent
        of AC_COMPILE_IFELSE.

Index: acspecific.m4
===================================================================
RCS file: /cvs/autoconf/acspecific.m4,v
retrieving revision 1.293
diff -u -r1.293 acspecific.m4
--- acspecific.m4       2000/08/04 09:21:52     1.293
+++ acspecific.m4       2000/08/30 14:05:10
@@ -1586,16 +1586,22 @@
 # determined by ac_objext.
 define([_AC_OBJEXT],
 [AC_CACHE_CHECK([for object suffix], ac_cv_objext,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
-   [for ac_file in conftest.*; do
-    case $ac_file in
-      *.$ac_ext) ;;
-      *) ac_cv_objext=`echo $ac_file | sed s/conftest.//` ;;
-    esac
-  done],
-   [AC_MSG_ERROR([cannot compile])])])
+[AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
+ if AC_TRY_EVAL(ac_compile); then
+   for ac_file in conftest.*; do
+   case $ac_file in
+     *.$ac_ext) ;;
+     *) ac_cv_objext=`echo $ac_file | sed s/conftest.//` ;;
+   esac
+   done
+ else
+   rm -f conftest.$ac_ext
+   AC_MSG_ERROR([cannot compile])
+ fi
+])
 AC_SUBST(OBJEXT, $ac_cv_objext)dnl
 ac_objext=$ac_cv_objext
+rm -f conftest.$ac_objext conftest.$ac_ext
 ])# _AC_OBJEXT
 
 

Reply via email to