Blame m4/ac_prog_cc_for_build.m4

Packit fc043f
dnl Available from the GNU Autoconf Macro Archive at:
Packit fc043f
dnl https://www.gnu.org/software/ac-archive/htmldoc/ac_prog_cc_for_build.html
Packit fc043f
dnl
Packit fc043f
dnl All content of this archive is free software;
Packit fc043f
dnl you can redistribute it and/or modify it under the terms of the GNU
Packit fc043f
dnl General Public License as published by the Free Software Foundation;
Packit fc043f
dnl either version 2, or (at your option) any later version.
Packit fc043f
dnl
Packit fc043f
dnl As a special exception, the respective Autoconf Macro's copyright
Packit fc043f
dnl owner gives unlimited permission to copy, distribute and modify the
Packit fc043f
dnl configure scripts that are the output of Autoconf when processing the
Packit fc043f
dnl Macro. You need not follow the terms of the GNU General Public License
Packit fc043f
dnl when using or distributing such scripts, even though portions of the
Packit fc043f
dnl text of the Macro appear in them. The GNU General Public License (GPL)
Packit fc043f
dnl does govern all other use of the material that constitutes the
Packit fc043f
dnl Autoconf Macro.
Packit fc043f
dnl 
Packit fc043f
dnl This special exception to the GPL applies to versions of the Autoconf
Packit fc043f
dnl Macro released by the GNU Autoconf Macro Archive. When you make and
Packit fc043f
dnl distribute a modified version of the Autoconf Macro, you may extend
Packit fc043f
dnl this special exception to the GPL to apply to your modified version as
Packit fc043f
dnl well.
Packit fc043f
Packit fc043f
dnl Synopsis AC_PROG_CC_FOR_BUILD
Packit fc043f
dnl
Packit fc043f
dnl This macro searches for a C compiler that generates native
Packit fc043f
dnl executables, that is a C compiler that surely is not a cross-compiler.
Packit fc043f
dnl This can be useful if you have to generate source code at compile-time
Packit fc043f
dnl like for example GCC does.
Packit fc043f
dnl
Packit fc043f
dnl The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
Packit fc043f
dnl needed to compile or link (CC_FOR_BUILD) and preprocess
Packit fc043f
dnl (CPP_FOR_BUILD).  The value of these variables can be overridden by
Packit fc043f
dnl the user by specifying a compiler with an environment variable (like
Packit fc043f
dnl you do for standard CC).
Packit fc043f
dnl
Packit fc043f
dnl It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and
Packit fc043f
dnl object file extensions for the build platform, and GCC_FOR_BUILD
Packit fc043f
dnl to `yes' if the compiler we found is GCC.  All these variables but
Packit fc043f
dnl GCC_FOR_BUILD are substituted in the Makefile.
Packit fc043f
dnl
Packit fc043f
dnl Author Paolo Bonzini <bonzini@gnu.org>
Packit fc043f
dnl
Packit fc043f
AC_DEFUN([AC_PROG_CC_FOR_BUILD], [dnl
Packit fc043f
AC_REQUIRE([AC_PROG_CC])dnl
Packit fc043f
AC_REQUIRE([AC_PROG_CPP])dnl
Packit fc043f
AC_REQUIRE([AC_EXEEXT])dnl
Packit fc043f
AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl
Packit fc043f
dnl
Packit fc043f
pushdef([AC_TRY_COMPILER], [
Packit fc043f
cat > conftest.$ac_ext << EOF
Packit fc043f
#line __oline__ "configure"
Packit fc043f
#include "confdefs.h"
Packit fc043f
[$1]
Packit fc043f
EOF
Packit fc043f
# If we can't run a trivial program, we are probably using a cross
Packit fc043f
compiler.
Packit fc043f
# Fail miserably.
Packit fc043f
if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} && (./conftest;
Packit fc043f
exit) 2>/dev/null; then
Packit fc043f
  [$2]=yes
Packit fc043f
else
Packit fc043f
  echo "configure: failed program was:" >&AC_FD_CC
Packit fc043f
  cat conftest.$ac_ext >&AC_FD_CC
Packit fc043f
  [$2]=no
Packit fc043f
fi
Packit fc043f
[$3]=no
Packit fc043f
rm -fr conftest*])dnl
Packit fc043f
Packit fc043f
dnl Use the standard macros, but make them use other variable names
Packit fc043f
dnl
Packit fc043f
pushdef([cross_compiling], [#])dnl
Packit fc043f
pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
Packit fc043f
pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
Packit fc043f
pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
Packit fc043f
pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
Packit fc043f
pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
Packit fc043f
pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
Packit fc043f
pushdef([ac_cv_objext], ac_cv_build_objext)dnl
Packit fc043f
pushdef([ac_exeext], ac_build_exeext)dnl
Packit fc043f
pushdef([ac_objext], ac_build_objext)dnl
Packit fc043f
pushdef([CC], CC_FOR_BUILD)dnl
Packit fc043f
pushdef([CPP], CPP_FOR_BUILD)dnl
Packit fc043f
pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
Packit fc043f
pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
Packit fc043f
pushdef([host], build)dnl
Packit fc043f
pushdef([host_alias], build_alias)dnl
Packit fc043f
pushdef([host_cpu], build_cpu)dnl
Packit fc043f
pushdef([host_vendor], build_vendor)dnl
Packit fc043f
pushdef([host_os], build_os)dnl
Packit fc043f
pushdef([ac_cv_host], ac_cv_build)dnl
Packit fc043f
pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
Packit fc043f
pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
Packit fc043f
pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
Packit fc043f
pushdef([ac_cv_host_os], ac_cv_build_os)dnl
Packit fc043f
pushdef([ac_cpp], ac_build_cpp)dnl
Packit fc043f
pushdef([ac_compile], ac_build_compile)dnl
Packit fc043f
pushdef([ac_link], ac_build_link)dnl
Packit fc043f
Packit fc043f
dnl Defeat the anti-duplication mechanism
Packit fc043f
dnl
Packit fc043f
dnl undefine([AC_PROVIDE_AC_PROG_CPP])dnl
Packit fc043f
dnl undefine([AC_PROVIDE_AC_PROG_C])dnl
Packit fc043f
dnl undefine([AC_PROVIDE_AC_EXEEXT])dnl
Packit fc043f
Packit fc043f
AC_PROG_CC
Packit fc043f
AC_PROG_CPP
Packit fc043f
AC_EXEEXT
Packit fc043f
Packit fc043f
dnl Restore the old definitions
Packit fc043f
dnl
Packit fc043f
popdef([AC_TRY_COMPILER])dnl
Packit fc043f
popdef([ac_link])dnl
Packit fc043f
popdef([ac_compile])dnl
Packit fc043f
popdef([ac_cpp])dnl
Packit fc043f
popdef([ac_cv_host_os])dnl
Packit fc043f
popdef([ac_cv_host_vendor])dnl
Packit fc043f
popdef([ac_cv_host_cpu])dnl
Packit fc043f
popdef([ac_cv_host_alias])dnl
Packit fc043f
popdef([ac_cv_host])dnl
Packit fc043f
popdef([host_os])dnl
Packit fc043f
popdef([host_vendor])dnl
Packit fc043f
popdef([host_cpu])dnl
Packit fc043f
popdef([host_alias])dnl
Packit fc043f
popdef([host])dnl
Packit fc043f
popdef([CPPFLAGS])dnl
Packit fc043f
popdef([CFLAGS])dnl
Packit fc043f
popdef([CPP])dnl
Packit fc043f
popdef([CC])dnl
Packit fc043f
popdef([ac_objext])dnl
Packit fc043f
popdef([ac_exeext])dnl
Packit fc043f
popdef([ac_cv_objext])dnl
Packit fc043f
popdef([ac_cv_exeext])dnl
Packit fc043f
popdef([ac_cv_prog_cc_g])dnl
Packit fc043f
popdef([ac_cv_prog_cc_works])dnl
Packit fc043f
popdef([ac_cv_prog_cc_cross])dnl
Packit fc043f
popdef([ac_cv_prog_gcc])dnl
Packit fc043f
popdef([ac_cv_prog_CPP])dnl
Packit fc043f
popdef([cross_compiling])dnl
Packit fc043f
Packit fc043f
dnl Finally, set Makefile variables
Packit fc043f
dnl
Packit fc043f
BUILD_EXEEXT=$ac_build_exeext
Packit fc043f
BUILD_OBJEXT=$ac_build_objext
Packit fc043f
AC_SUBST(BUILD_EXEEXT)dnl
Packit fc043f
AC_SUBST(BUILD_OBJEXT)dnl
Packit fc043f
AC_SUBST([CFLAGS_FOR_BUILD])dnl
Packit fc043f
AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
Packit fc043f
])