autoconf
[Top][All Lists]
Advanced

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

Re: AC_OBJEXT again


From: akim
Subject: Re: AC_OBJEXT again
Date: Tue, 12 Dec 2000 21:22:08 +0100
User-agent: Mutt/1.2.5i

On Tue, Dec 12, 2000 at 07:30:05PM +0100, Akim Demaille wrote:
> 
> Alexandre> Such a cross-compiler would be a broken compiler.  I don't
> Alexandre> know of any such cross-compilers, so this point is moot.
> 
> Ah!!!  Then you are telling me we just don't care about __CYGWIN32__
> etc.  Then that's fine with me, that's all I wanted to hear.  All we
> want to know is the default extensions used by the compiler.  Fine.
> 

Here is my proposal.

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        
        EXEEXT and OBJEXT don't need to know $CYGWIN etc.
        
        * acspecific.m4 (AC_EXEEXT, AC_OBJEXT, _AC_EXEEXT, _AC_OBJEXT):
        Move as...
        * aclang.m4 (AC_EXEEXT, AC_OBJEXT, _AC_COMPILER_EXEEXT)
        (_AC_COMPILER_OBJEXT): these.
        (_AC_COMPILER_EXEEXT): Use _AC_LINK_IFELSE.
        Don't depend upon $CYGWIN and the like.
        (_AC_COMPILER_OBJEXT): Model after _AC_COMPILER_EXEEXT.
        Skip more extensions.
        Use _AC_COMPILE_IFELSE.
        
Index: aclang.m4
--- aclang.m4 Tue, 12 Dec 2000 20:23:51 +0100 akim (ace/b/32_aclang.m4 1.5.3.54 
644)
+++ aclang.m4 Tue, 12 Dec 2000 21:05:26 +0100 akim (ace/b/32_aclang.m4 1.5.3.54 
644)
@@ -613,11 +613,11 @@ AC_DEFUN_ONCE([AC_NO_EXECUTABLES],
 [m4_divert_push([KILL])
 
 AC_BEFORE([$0], [_AC_LANG_COMPILER_WORKS])
-AC_BEFORE([$0], [_AC_EXEEXT])
+AC_BEFORE([$0], [_AC_COMPILER_EXEEXT])
 
 m4_define([_AC_LANG_COMPILER_WORKS], [cross_compiling=maybe])
 
-m4_define([_AC_EXEEXT], [EXEEXT=])
+m4_define([_AC_COMPILER_EXEEXT], [EXEEXT=])
 
 m4_define([AC_LINK_IFELSE],
 [AC_FATAL([All the tests involving linking were disabled by $0])])
@@ -626,6 +626,86 @@ m4_define([AC_LINK_IFELSE],
 ])# # AC_NO_EXECUTABLES
 
 
+
+# ----------------------------- #
+# Computing EXEEXT and OBJEXT.  #
+# ----------------------------- #
+
+
+# Files to ignore
+# ---------------
+# Ignore .d files produced by CFLAGS=-MD.
+#
+# On UWIN (which uses a cc wrapper for MSVC), the compiler also generates
+# a .pdb file
+#
+# When the w32 free Borland C++ command line compiler links a program
+# (conftest.exe), it also produces a file named `conftest.tds' in
+# addition to `conftest.obj'
+
+
+# We must not AU define them, because autoupdate would them remove
+# them, which is right, but Automake 1.4 would remove the support for
+# $(EXEEXT) etc.
+# FIXME: Remove this once Automake fixed.
+AC_DEFUN([AC_EXEEXT],   [])
+AC_DEFUN([AC_OBJEXT],   [])
+
+
+# _AC_COMPILER_EXEEXT
+# -------------------
+# Check for the extension used for executables.  It compiles a test
+# executable.  If this is called, the executable extensions will be
+# automatically used by link commands run by the configure script.
+#
+# This macro is called by AC_LANG_COMPILER, the latter being required
+# by the AC_LINK_IFELSE macros, so use _AC_LINK_IFELSE.
+m4_define([_AC_COMPILER_EXEEXT],
+[AC_CACHE_CHECK([for executable suffix], ac_cv_exeext,
+[_AC_LINK_IFELSE([AC_LANG_PROGRAM()],
+[# If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in `ls conftest.exe conftest conftest.* 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
+    *) ac_cv_exeext=`expr "$ac_file" : 'conftest\(.*\)'`
+       break;;
+  esac
+done],
+              [AC_MSG_ERROR([cannot compute EXEEXT: cannot compile and link])])
+rm -f conftest$ac_cv_exeext])
+AC_SUBST([EXEEXT], [$ac_cv_exeext])dnl
+ac_exeext=$EXEEXT
+])# _AC_COMPILER_EXEEXT
+
+
+# _AC_COMPILER_OBJEXT
+# -------------------
+# Check the object extension used by the compiler: typically `.o' or
+# `.obj'.  If this is called, some other behaviour will change,
+# determined by ac_objext.
+#
+# This macro is called by AC_LANG_COMPILER, the latter being required
+# by the AC_COMPILE_IFELSE macros, so use _AC_COMPILE_IFELSE.
+m4_define([_AC_COMPILER_OBJEXT],
+[AC_CACHE_CHECK([for object suffix], ac_cv_objext,
+[_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+[for ac_file in `ls conftest.o conftest.obj conftest.* 2>/dev/null`; do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done],
+                     [AC_MSG_ERROR([cannot compute OBJEXT: cannot compile])])
+rm -f conftest.$ac_cv_objext])
+AC_SUBST([OBJEXT], [$ac_cv_objext])dnl
+ac_objext=$OBJEXT
+])# _AC_COMPILER_OBJEXT
+
+
 # -------------------- #
 # 3b. The C compiler.  #
 # -------------------- #
@@ -752,8 +832,8 @@ AC_DEFUN([AC_PROG_CC],
 _AC_LANG_COMPILER_WORKS
 _AC_LANG_COMPILER_GNU
 GCC=`test $ac_compiler_gnu = yes && echo yes`
-AC_EXPAND_ONCE([_AC_OBJEXT])
-AC_EXPAND_ONCE([_AC_EXEEXT])
+AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
+AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
 _AC_PROG_CC_G
 AC_LANG_POP
 ])# AC_PROG_CC
@@ -945,8 +1025,8 @@ AC_DEFUN([AC_PROG_CXX],
 _AC_LANG_COMPILER_WORKS
 _AC_LANG_COMPILER_GNU
 GXX=`test $ac_compiler_gnu = yes && echo yes`
-AC_EXPAND_ONCE([_AC_OBJEXT])
-AC_EXPAND_ONCE([_AC_EXEEXT])
+AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
+AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
 _AC_PROG_CXX_G
 AC_LANG_POP
 ])# AC_PROG_CXX
@@ -1044,8 +1124,8 @@ AC_DEFUN([AC_PROG_F77],
 _AC_LANG_COMPILER_GNU
 ac_ext=$ac_save_ext
 G77=`test $ac_compiler_gnu = yes && echo yes`
-AC_EXPAND_ONCE([_AC_OBJEXT])
-AC_EXPAND_ONCE([_AC_EXEEXT])
+AC_EXPAND_ONCE([_AC_COMPILER_OBJEXT])[]dnl
+AC_EXPAND_ONCE([_AC_COMPILER_EXEEXT])[]dnl
 _AC_PROG_F77_G
 AC_LANG_POP
 ])# AC_PROG_F77
Index: acspecific.m4
--- acspecific.m4 Tue, 12 Dec 2000 20:23:51 +0100 akim (ace/25_acspecific 1.114 
644)
+++ acspecific.m4 Tue, 12 Dec 2000 20:31:32 +0100 akim (ace/25_acspecific 1.114 
644)
@@ -1189,90 +1189,6 @@ m4_define([_AC_MINGW32],
 AU_DEFUN([AC_MINGW32],  [])
 
 
-# We must not AU define them, because autoupdate would them remove
-# them, which is right, but Automake 1.4 would remove the support for
-# $(EXEEXT) etc.
-# FIXME: Remove this once Automake fixed.
-AC_DEFUN([AC_EXEEXT],   [])
-AC_DEFUN([AC_OBJEXT],   [])
-
-
-# _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.
-#
-# Ignore .d files produced by CFLAGS=-MD.
-#
-# On UWIN (which uses a cc wrapper for MSVC), the compiler also generates
-# a .pdb file
-#
-# This macro is called by AC_LANG_COMPILER, the latter being required
-# by the AC_COMPILE_IFELSE macros, so use AC_TRY_EVAL.
-m4_define([_AC_EXEEXT],
-[AC_CACHE_CHECK([for executable suffix], ac_cv_exeext,
-[cN $MINGW32 $EMXOS2" in
-  *yes*) ac_cv_exeext=.exe ;;
-  *)
-    AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
-    if AC_TRY_EVAL(ac_link); then
-      # If both `conftest.exe' and `conftest' are `present' (well, observable)
-      # catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
-      # work properly (i.e., refer to `conftest.exe'), while it won't with
-      # `rm'.
-      for ac_file in `ls conftest.exe conftest conftest.* 2>/dev/null`; do
-       case $ac_file in
-         *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;;
-         *) ac_cv_exeext=`expr "$ac_file" : 'conftest\(.*\)'`
-            break;;
-       esac
-      done
-      rm -f conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-    else
-      AC_MSG_ERROR([cannot compile and link])
-    fi
-    ;;
-esac])
-AC_SUBST([EXEEXT], [$ac_cv_exeext])dnl
-ac_exeext=$EXEEXT
-])# _AC_EXEEXT
-
-
-# _AC_OBJEXT
-# ----------
-# Check the object extension used by the compiler: typically .o or
-# .obj.  If this is called, some other behaviour will change,
-# determined by ac_objext.
-#
-# When the w32 free Borland C++ command line compiler links a program
-# (conftest.exe), it also produces a file named `conftest.tds' in
-# addition to `conftest.obj'
-#
-# Ignore .d files produced by CFLAGS=-MD.
-#
-# This macro is called by AC_LANG_COMPILER, the latter being required
-# by the AC_COMPILE_IFELSE macros, so use AC_TRY_EVAL.
-m4_define([_AC_OBJEXT],
-[AC_CACHE_CHECK([for object suffix], ac_cv_objext,
-[AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
-if AC_TRY_EVAL(ac_compile); then
-  for ac_file in `ls conftest.o conftest.obj conftest.* 2>/dev/null`; do
-    case $ac_file in
-      *.$ac_ext | *.tds | *.d ) ;;
-      *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
-         break;;
-    esac
-  done
-  rm -f conftest.$ac_objext conftest.$ac_ext
-else
-  AC_MSG_ERROR([cannot compile])
-fi])
-AC_SUBST(OBJEXT, $ac_cv_objext)dnl
-ac_objext=$ac_cv_objext
-])# _AC_OBJEXT
-
 
 
 ## -------------------------- ##
Index: doc/autoconf.texi
--- doc/autoconf.texi Tue, 12 Dec 2000 20:23:51 +0100 akim (ace/16_autoconf.t 
1.61.2.91 644)
+++ doc/autoconf.texi Tue, 12 Dec 2000 21:13:31 +0100 akim (ace/16_autoconf.t 
1.61.2.91 644)
@@ -4056,16 +4056,17 @@ @node Compilers and Preprocessors, C Com
 the output of the compiler, typically to the empty string if Unix and
 @samp{.exe} if Win32 or OS/2.
 
address@hidden CYGWIN
address@hidden EMXOS2
address@hidden MINGW32
-They also set the shell variable @code{CYGWIN} to @samp{yes} if run in
-the Cygwin environment, @code{EMXOS2} to @samp{yes} if in the EMX
-environment on OS/2, and @code{MINGW32} to @samp{yes} with the MingW32
-compiler.
address@hidden FIXME:
address@hidden @ovindex CYGWIN
address@hidden @ovindex EMXOS2
address@hidden @ovindex MINGW32
address@hidden They also set the shell variable @code{CYGWIN} to @samp{yes} if 
run in
address@hidden the Cygwin environment, @code{EMXOS2} to @samp{yes} if in the EMX
address@hidden environment on OS/2, and @code{MINGW32} to @samp{yes} with the 
MingW32
address@hidden compiler.
 
 @ovindex OBJEXT
-Finally, they define the output variable @code{OBJEXT} based on the
+They also define the output variable @code{OBJEXT} based on the
 output of the compiler, after .c files have been excluded, typically
 to @samp{o} if Unix, @samp{obj} if Win32.
 



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

There remains just one question: what shall we do out of AC_CYGWIN etc.

Frankly, the more I think about them, the more I think they were a mistake
introduced just for AC_EXEEXT and AC_OBJEXT: it allowed to guess the
system type without requiring config.guess.

Today it seems to me that if one depends upon knowing whether the host
is cygwin etc., then she should use AC_CANONICAL_HOST and case over
$host.  I propose either the pure removal of AC_CYGWIN etc. with an
error message telling how to write properly (not too good :), or
simply AU define them as

AC_REQUIRE([AC_CANONICAL_HOST])
if $host_os is cygwin; then
  CYGWIN=yes
else
  CYGWIN=no
fi

etc.



Mo, you are one of the people who most wanted AC_CYGWIN back.  Why
don't you depend on the host type?




reply via email to

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