1# ===========================================================================
2#   http://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
3# ===========================================================================
4#
5# SYNOPSIS
6#
7#   AX_PROG_CC_FOR_BUILD
8#
9# DESCRIPTION
10#
11#   This macro searches for a C compiler that generates native executables,
12#   that is a C compiler that surely is not a cross-compiler. This can be
13#   useful if you have to generate source code at compile-time like for
14#   example GCC does.
15#
16#   The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
17#   needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD).
18#   The value of these variables can be overridden by the user by specifying
19#   a compiler with an environment variable (like you do for standard CC).
20#
21#   It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object
22#   file extensions for the build platform, and GCC_FOR_BUILD to `yes' if
23#   the compiler we found is GCC. All these variables but GCC_FOR_BUILD are
24#   substituted in the Makefile.
25#
26# LICENSE
27#
28#   Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
29#
30#   Copying and distribution of this file, with or without modification, are
31#   permitted in any medium without royalty provided the copyright notice
32#   and this notice are preserved. This file is offered as-is, without any
33#   warranty.
34
35#serial 8
36
37AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
38AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
39AC_REQUIRE([AC_PROG_CC])dnl
40AC_REQUIRE([AC_PROG_CPP])dnl
41AC_REQUIRE([AC_EXEEXT])dnl
42AC_REQUIRE([AC_CANONICAL_HOST])dnl
43
44dnl Use the standard macros, but make them use other variable names
45dnl
46pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
47pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
48pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
49pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
50pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
51pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
52pushdef([ac_cv_objext], ac_cv_build_objext)dnl
53pushdef([ac_exeext], ac_build_exeext)dnl
54pushdef([ac_objext], ac_build_objext)dnl
55pushdef([CC], CC_FOR_BUILD)dnl
56pushdef([CPP], CPP_FOR_BUILD)dnl
57pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
58pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
59pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
60pushdef([host], build)dnl
61pushdef([host_alias], build_alias)dnl
62pushdef([host_cpu], build_cpu)dnl
63pushdef([host_vendor], build_vendor)dnl
64pushdef([host_os], build_os)dnl
65pushdef([ac_cv_host], ac_cv_build)dnl
66pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
67pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
68pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
69pushdef([ac_cv_host_os], ac_cv_build_os)dnl
70pushdef([ac_cpp], ac_build_cpp)dnl
71pushdef([ac_compile], ac_build_compile)dnl
72pushdef([ac_link], ac_build_link)dnl
73
74save_cross_compiling=$cross_compiling
75save_ac_tool_prefix=$ac_tool_prefix
76cross_compiling=no
77ac_tool_prefix=
78
79AC_PROG_CC
80AC_PROG_CPP
81AC_EXEEXT
82
83ac_tool_prefix=$save_ac_tool_prefix
84cross_compiling=$save_cross_compiling
85
86dnl Restore the old definitions
87dnl
88popdef([ac_link])dnl
89popdef([ac_compile])dnl
90popdef([ac_cpp])dnl
91popdef([ac_cv_host_os])dnl
92popdef([ac_cv_host_vendor])dnl
93popdef([ac_cv_host_cpu])dnl
94popdef([ac_cv_host_alias])dnl
95popdef([ac_cv_host])dnl
96popdef([host_os])dnl
97popdef([host_vendor])dnl
98popdef([host_cpu])dnl
99popdef([host_alias])dnl
100popdef([host])dnl
101popdef([LDFLAGS])dnl
102popdef([CPPFLAGS])dnl
103popdef([CFLAGS])dnl
104popdef([CPP])dnl
105popdef([CC])dnl
106popdef([ac_objext])dnl
107popdef([ac_exeext])dnl
108popdef([ac_cv_objext])dnl
109popdef([ac_cv_exeext])dnl
110popdef([ac_cv_prog_cc_g])dnl
111popdef([ac_cv_prog_cc_cross])dnl
112popdef([ac_cv_prog_cc_works])dnl
113popdef([ac_cv_prog_gcc])dnl
114popdef([ac_cv_prog_CPP])dnl
115
116dnl Finally, set Makefile variables
117dnl
118BUILD_EXEEXT=$ac_build_exeext
119BUILD_OBJEXT=$ac_build_objext
120AC_SUBST(BUILD_EXEEXT)dnl
121AC_SUBST(BUILD_OBJEXT)dnl
122AC_SUBST([CFLAGS_FOR_BUILD])dnl
123AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
124AC_SUBST([LDFLAGS_FOR_BUILD])dnl
125])
126