1dnl Available from the GNU Autoconf Macro Archive at:
2dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_prog_cc_for_build.html
3dnl
4dnl All content of this archive is free software;
5dnl you can redistribute it and/or modify it under the terms of the GNU
6dnl General Public License as published by the Free Software Foundation;
7dnl either version 2, or (at your option) any later version.
8dnl
9dnl As a special exception, the respective Autoconf Macro's copyright
10dnl owner gives unlimited permission to copy, distribute and modify the
11dnl configure scripts that are the output of Autoconf when processing the
12dnl Macro. You need not follow the terms of the GNU General Public License
13dnl when using or distributing such scripts, even though portions of the
14dnl text of the Macro appear in them. The GNU General Public License (GPL)
15dnl does govern all other use of the material that constitutes the
16dnl Autoconf Macro.
17dnl 
18dnl This special exception to the GPL applies to versions of the Autoconf
19dnl Macro released by the GNU Autoconf Macro Archive. When you make and
20dnl distribute a modified version of the Autoconf Macro, you may extend
21dnl this special exception to the GPL to apply to your modified version as
22dnl well.
23
24dnl Synopsis AC_PROG_CC_FOR_BUILD
25dnl
26dnl This macro searches for a C compiler that generates native
27dnl executables, that is a C compiler that surely is not a cross-compiler.
28dnl This can be useful if you have to generate source code at compile-time
29dnl like for example GCC does.
30dnl
31dnl The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
32dnl needed to compile or link (CC_FOR_BUILD) and preprocess
33dnl (CPP_FOR_BUILD).  The value of these variables can be overridden by
34dnl the user by specifying a compiler with an environment variable (like
35dnl you do for standard CC).
36dnl
37dnl It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and
38dnl object file extensions for the build platform, and GCC_FOR_BUILD
39dnl to `yes' if the compiler we found is GCC.  All these variables but
40dnl GCC_FOR_BUILD are substituted in the Makefile.
41dnl
42dnl Author Paolo Bonzini <bonzini@gnu.org>
43dnl
44AC_DEFUN([AC_PROG_CC_FOR_BUILD], [dnl
45AC_REQUIRE([AC_PROG_CC])dnl
46AC_REQUIRE([AC_PROG_CPP])dnl
47AC_REQUIRE([AC_EXEEXT])dnl
48AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl
49dnl
50pushdef([AC_TRY_COMPILER], [
51cat > conftest.$ac_ext << EOF
52#line __oline__ "configure"
53#include "confdefs.h"
54[$1]
55EOF
56# If we can't run a trivial program, we are probably using a cross
57compiler.
58# Fail miserably.
59if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} && (./conftest;
60exit) 2>/dev/null; then
61  [$2]=yes
62else
63  echo "configure: failed program was:" >&AC_FD_CC
64  cat conftest.$ac_ext >&AC_FD_CC
65  [$2]=no
66fi
67[$3]=no
68rm -fr conftest*])dnl
69
70dnl Use the standard macros, but make them use other variable names
71dnl
72pushdef([cross_compiling], [#])dnl
73pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
74pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
75pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
76pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
77pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
78pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
79pushdef([ac_cv_objext], ac_cv_build_objext)dnl
80pushdef([ac_exeext], ac_build_exeext)dnl
81pushdef([ac_objext], ac_build_objext)dnl
82pushdef([CC], CC_FOR_BUILD)dnl
83pushdef([CPP], CPP_FOR_BUILD)dnl
84pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
85pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
86pushdef([host], build)dnl
87pushdef([host_alias], build_alias)dnl
88pushdef([host_cpu], build_cpu)dnl
89pushdef([host_vendor], build_vendor)dnl
90pushdef([host_os], build_os)dnl
91pushdef([ac_cv_host], ac_cv_build)dnl
92pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
93pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
94pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
95pushdef([ac_cv_host_os], ac_cv_build_os)dnl
96pushdef([ac_cpp], ac_build_cpp)dnl
97pushdef([ac_compile], ac_build_compile)dnl
98pushdef([ac_link], ac_build_link)dnl
99
100dnl Defeat the anti-duplication mechanism
101dnl
102dnl undefine([AC_PROVIDE_AC_PROG_CPP])dnl
103dnl undefine([AC_PROVIDE_AC_PROG_C])dnl
104dnl undefine([AC_PROVIDE_AC_EXEEXT])dnl
105
106AC_PROG_CC
107AC_PROG_CPP
108AC_EXEEXT
109
110dnl Restore the old definitions
111dnl
112popdef([AC_TRY_COMPILER])dnl
113popdef([ac_link])dnl
114popdef([ac_compile])dnl
115popdef([ac_cpp])dnl
116popdef([ac_cv_host_os])dnl
117popdef([ac_cv_host_vendor])dnl
118popdef([ac_cv_host_cpu])dnl
119popdef([ac_cv_host_alias])dnl
120popdef([ac_cv_host])dnl
121popdef([host_os])dnl
122popdef([host_vendor])dnl
123popdef([host_cpu])dnl
124popdef([host_alias])dnl
125popdef([host])dnl
126popdef([CPPFLAGS])dnl
127popdef([CFLAGS])dnl
128popdef([CPP])dnl
129popdef([CC])dnl
130popdef([ac_objext])dnl
131popdef([ac_exeext])dnl
132popdef([ac_cv_objext])dnl
133popdef([ac_cv_exeext])dnl
134popdef([ac_cv_prog_cc_g])dnl
135popdef([ac_cv_prog_cc_works])dnl
136popdef([ac_cv_prog_cc_cross])dnl
137popdef([ac_cv_prog_gcc])dnl
138popdef([ac_cv_prog_CPP])dnl
139popdef([cross_compiling])dnl
140
141dnl Finally, set Makefile variables
142dnl
143BUILD_EXEEXT=$ac_build_exeext
144BUILD_OBJEXT=$ac_build_objext
145AC_SUBST(BUILD_EXEEXT)dnl
146AC_SUBST(BUILD_OBJEXT)dnl
147AC_SUBST([CFLAGS_FOR_BUILD])dnl
148AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
149])
150