From: Akim Demaille Date: Tue, 23 May 2000 14:50:43 +0000 (+0000) Subject: Modernize AC_EXEEXT and AC_OBJEXT. X-Git-Tag: autoconf-2.50~880 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ede91cff9487a1186f9c915e3bebe347d7307d5b;p=thirdparty%2Fautoconf.git Modernize AC_EXEEXT and AC_OBJEXT. Now work with other languages than C and C++. * acspecific.m4 (AC_EXEEXT, AC_OBJEXT): Use AC_COMPILE_IFELSE/AC_LINK_IFELSE and AC_LANG_PROGRAM instead of ad hoc code. Use `$ac_ext' instead of listing `.c', `.C' etc. Use AC_CACHE_CHECK. * doc/autoconf.texi (System Services): Adjust. --- diff --git a/ChangeLog b/ChangeLog index c8af754c0..d1c8e487f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2000-05-23 Akim Demaille + + Modernize AC_EXEEXT and AC_OBJEXT. + Now work with other languages than C and C++. + + * acspecific.m4 (AC_EXEEXT, AC_OBJEXT): Use + AC_COMPILE_IFELSE/AC_LINK_IFELSE and AC_LANG_PROGRAM instead of + ad hoc code. + Use `$ac_ext' instead of listing `.c', `.C' etc. + Use AC_CACHE_CHECK. + * doc/autoconf.texi (System Services): Adjust. + 2000-05-23 Akim Demaille Simplify the interface: users shouldn't need to explicitly check diff --git a/acspecific.m4 b/acspecific.m4 index 91d84f564..c65357b30 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -2554,30 +2554,22 @@ AC_DEFUN([AC_EXEEXT], [_AC_CYGWIN _AC_MINGW32 _AC_EMXOS2 -AC_MSG_CHECKING([for executable suffix]) -AC_CACHE_VAL(ac_cv_exeext, +AC_CACHE_CHECK([for executable suffix], ac_cv_exeext, [if test "$CYGWIN" = yes || test "$MINGW32" = yes || test "$EMXOS2" = yes; then ac_cv_exeext=.exe else - rm -f conftest* - echo 'int main () { return 0; }' >conftest.$ac_ext - ac_cv_exeext= - if AC_TRY_EVAL(ac_link); then - for ac_file in conftest.*; do - case $ac_file in - *.c | *.C | *.o | *.obj | *.xcoff) ;; - *) ac_cv_exeext=`echo $ac_file | sed -e s/conftest//` ;; - esac - done - else - AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.]) - fi - rm -f conftest* - test x"${ac_cv_exeext}" = x && ac_cv_exeext=no + AC_LINK_IFELSE([AC_LANG_PROGRAM()], + [for ac_file in conftest.*; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff) ;; + *) ac_cv_exeext=`echo $ac_file | sed -e s/conftest//` ;; + esac + done], + [AC_MSG_ERROR([cannot compile and link])]) + test -n "$ac_cv_exeext" && ac_cv_exeext=no fi]) -EXEEXT="" -test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext} -AC_MSG_RESULT(${ac_cv_exeext}) +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 @@ -2590,26 +2582,18 @@ AC_SUBST(EXEEXT)dnl # .obj. If this is called, some other behaviour will change, # determined by ac_objext. AC_DEFUN([AC_OBJEXT], -[AC_MSG_CHECKING([for object suffix]) -AC_CACHE_VAL(ac_cv_objext, -[rm -f conftest* -echo 'int i = 1;' >conftest.$ac_ext -if AC_TRY_EVAL(ac_compile); then - for ac_file in conftest.*; do +[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 - *.c) ;; - *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;; + *.$ac_ext) ;; + *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;; esac - done -else - AC_MSG_ERROR([installation or configuration problem; compiler does not work]) -fi -rm -f conftest*]) -AC_MSG_RESULT($ac_cv_objext) -OBJEXT=$ac_cv_objext + done], + [AC_MSG_ERROR([cannot compile])])]) +AC_SUBST(OBJEXT, $ac_cv_objext)dnl ac_objext=$ac_cv_objext -AC_SUBST(OBJEXT)]) - +]) diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 3212c260e..502ecdc61 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -4047,9 +4047,10 @@ The following macros check for operating system services or capabilities. @maindex EMXOS2 @maindex MINGW32 Defines substitute variable @code{EXEEXT} based on the output of the -compiler, after @samp{.c}, @samp{.C}, @samp{.o}, @samp{.obj} and -@samp{.xcoff} files have been excluded. Typically set to empty string -if Unix and @samp{.exe} if Win32 or OS/2. +compiler, after @samp{.$ac_ext} (i.e. source files of the current +language), @samp{.o}, @samp{.obj} and @samp{.xcoff} files have been +excluded. Typically set to empty string if Unix and @samp{.exe} if +Win32 or OS/2. This macro sets the shell variable @code{CYGWIN} to @samp{yes} if run in the Cygwin environment, @code{EMXOS2} to @samp{yes} if in the EMX diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index 91d84f564..c65357b30 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -2554,30 +2554,22 @@ AC_DEFUN([AC_EXEEXT], [_AC_CYGWIN _AC_MINGW32 _AC_EMXOS2 -AC_MSG_CHECKING([for executable suffix]) -AC_CACHE_VAL(ac_cv_exeext, +AC_CACHE_CHECK([for executable suffix], ac_cv_exeext, [if test "$CYGWIN" = yes || test "$MINGW32" = yes || test "$EMXOS2" = yes; then ac_cv_exeext=.exe else - rm -f conftest* - echo 'int main () { return 0; }' >conftest.$ac_ext - ac_cv_exeext= - if AC_TRY_EVAL(ac_link); then - for ac_file in conftest.*; do - case $ac_file in - *.c | *.C | *.o | *.obj | *.xcoff) ;; - *) ac_cv_exeext=`echo $ac_file | sed -e s/conftest//` ;; - esac - done - else - AC_MSG_ERROR([installation or configuration problem: compiler cannot create executables.]) - fi - rm -f conftest* - test x"${ac_cv_exeext}" = x && ac_cv_exeext=no + AC_LINK_IFELSE([AC_LANG_PROGRAM()], + [for ac_file in conftest.*; do + case $ac_file in + *.$ac_ext | *.o | *.obj | *.xcoff) ;; + *) ac_cv_exeext=`echo $ac_file | sed -e s/conftest//` ;; + esac + done], + [AC_MSG_ERROR([cannot compile and link])]) + test -n "$ac_cv_exeext" && ac_cv_exeext=no fi]) -EXEEXT="" -test x"${ac_cv_exeext}" != xno && EXEEXT=${ac_cv_exeext} -AC_MSG_RESULT(${ac_cv_exeext}) +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 @@ -2590,26 +2582,18 @@ AC_SUBST(EXEEXT)dnl # .obj. If this is called, some other behaviour will change, # determined by ac_objext. AC_DEFUN([AC_OBJEXT], -[AC_MSG_CHECKING([for object suffix]) -AC_CACHE_VAL(ac_cv_objext, -[rm -f conftest* -echo 'int i = 1;' >conftest.$ac_ext -if AC_TRY_EVAL(ac_compile); then - for ac_file in conftest.*; do +[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 - *.c) ;; - *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;; + *.$ac_ext) ;; + *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;; esac - done -else - AC_MSG_ERROR([installation or configuration problem; compiler does not work]) -fi -rm -f conftest*]) -AC_MSG_RESULT($ac_cv_objext) -OBJEXT=$ac_cv_objext + done], + [AC_MSG_ERROR([cannot compile])])]) +AC_SUBST(OBJEXT, $ac_cv_objext)dnl ac_objext=$ac_cv_objext -AC_SUBST(OBJEXT)]) - +])