Hi,

this issue was touched upon earlier today: how the _AC_EXEEXT macro
does host-checking for Cygwin|Mingw|EMXOS2 when deciding the value of
$ac_exeext (which seems like an ugly mismatch with standard Autoconf
policy of checking for _features_ to me).

It was also mentioned on the list a while ago (by yours truly) how the
_AC_EXEEXT macro has a circular dependency: _AC_EXEEXT uses
AC_LINK_IFELSE which uses $ac_exeext which is found by _AC_EXEEXT.

My new version of the _AC_EXEEXT macro fixes both these problems, with
a change in behavior: it now just searches (in a prefered order) for a
valid executable suffix -- instead of trying hard to find _the_
correct suffix.

BTW, is the "-ef" option to ``test'' portable? If not, that part could
be stripped out.

AFAICS, this should also kill the last trace of use of _AC_CYGWIN,
_AC_MINGW32 and _AC_EMXOS2.

Regards,
Morten

Index: ChangeLog
===================================================================
RCS file: /cvs/autoconf/ChangeLog,v
retrieving revision 1.897
diff -u -r1.897 ChangeLog
--- ChangeLog   2000/10/05 13:52:41     1.897
+++ ChangeLog   2000/10/10 16:29:34
@@ -1,3 +1,9 @@
+2000-10-10  Morten Eriksen <[EMAIL PROTECTED]>
+
+       * acspecific.m4 (_AC_EXEEXT): Change of strategy for the macro, we
+       now search for a valid executable suffix. The old code had circular
+       dependencies which basically made it fubar.
+
 2000-10-05  Akim Demaille  <[EMAIL PROTECTED]>
 
        Check that updated scripts are valid scripts.
Index: acspecific.m4
===================================================================
RCS file: /cvs/autoconf/acspecific.m4,v
retrieving revision 1.300
diff -u -r1.300 acspecific.m4
--- acspecific.m4       2000/10/02 12:47:13     1.300
+++ acspecific.m4       2000/10/10 16:29:36
@@ -1554,35 +1552,31 @@
 
 # _AC_EXEEXT
 # ----------
-# Check for the extension used for executables.  This knows that we
-# add .exe for Cygwin or mingw32.  Otherwise, it compiles a test
-# executable.  If this is called, the executable extensions will be
-# automatically used by link commands run by the configure script.
+# Check for a valid extension to use for executables.
 define([_AC_EXEEXT],
-[_AC_CYGWIN
-_AC_MINGW32
-_AC_EMXOS2
-AC_CACHE_CHECK([for executable suffix], ac_cv_exeext,
-[case "$CYGWIN $MINGW32 $EMXOS2" in
-  *yes*) ac_cv_exeext=.exe ;;
-  *)
-  AC_LINK_IFELSE([AC_LANG_PROGRAM()],
-  [if test ! -f conftest; then
-    for ac_file in conftest.*; do
-       case $ac_file in
-         *.$ac_ext | *.o | *.obj | *.xcoff) ;;
-         *) ac_cv_exeext=`expr "$ac_file" : 'conftest\(.*\)'`;;
-       esac
-     done
-   fi],
-  [AC_MSG_ERROR([cannot compile and link])])
-  test -n "$ac_cv_exeext" && ac_cv_exeext=no;;
-esac])
-EXEEXT=
-test "$ac_cv_exeext" != no && EXEEXT=$ac_cv_exeext
-dnl Setting ac_exeext will implicitly change the ac_link command.
-ac_exeext=$EXEEXT
-AC_SUBST(EXEEXT)dnl
+[AC_CACHE_CHECK([for executable suffix], ac_cv_exeext,
+[# Try to compile and link an executable with no suffix first.
+ac_exeext=
+AC_LINK_IFELSE([AC_LANG_PROGRAM],
+ [# Ok, we can use an empty suffix for executables. Now see if the
+  # executable with the empty suffix is just a filesystem mapping
+  # from the real file (this happens under Cygwin, for instance).
+  if test conftest -ef conftest.exe; then
+    # Prefer .exe over empty suffix.
+    ac_cv_exeext=.exe
+  else
+    ac_cv_exeext=
+  fi
+ ],
+ [# Couldn't use empty suffix, try with suffix commonly used
+  # on MSWindows platforms.
+  ac_exeext=.exe
+  AC_LINK_IFELSE([AC_LANG_PROGRAM], [ac_cv_exeext=.exe],
+                 [AC_MSG_ERROR(cannot compile and link)])
+ ])
+])
+EXEEXT=$ac_cv_exeext
+AC_SUBST(EXEEXT)
 ])# _AC_EXEEXT
 
 

Reply via email to