| 1 |
# =========================================================================== |
| 2 |
# https://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 <[email protected]> |
| 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 18 |
| 36 |
|
| 37 |
AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD]) |
| 38 |
AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl |
| 39 |
AC_REQUIRE([AC_PROG_CC])dnl |
| 40 |
AC_REQUIRE([AC_PROG_CPP])dnl |
| 41 |
AC_REQUIRE([AC_CANONICAL_BUILD])dnl |
| 42 |
|
| 43 |
dnl Use the standard macros, but make them use other variable names |
| 44 |
dnl |
| 45 |
pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl |
| 46 |
pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl |
| 47 |
pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl |
| 48 |
pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl |
| 49 |
pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl |
| 50 |
pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl |
| 51 |
pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl |
| 52 |
pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl |
| 53 |
pushdef([ac_cv_objext], ac_cv_build_objext)dnl |
| 54 |
pushdef([ac_exeext], ac_build_exeext)dnl |
| 55 |
pushdef([ac_objext], ac_build_objext)dnl |
| 56 |
pushdef([CC], CC_FOR_BUILD)dnl |
| 57 |
pushdef([CPP], CPP_FOR_BUILD)dnl |
| 58 |
pushdef([GCC], GCC_FOR_BUILD)dnl |
| 59 |
pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl |
| 60 |
pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl |
| 61 |
pushdef([EXEEXT], BUILD_EXEEXT)dnl |
| 62 |
pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl |
| 63 |
pushdef([OBJEXT], BUILD_OBJEXT)dnl |
| 64 |
pushdef([host], build)dnl |
| 65 |
pushdef([host_alias], build_alias)dnl |
| 66 |
pushdef([host_cpu], build_cpu)dnl |
| 67 |
pushdef([host_vendor], build_vendor)dnl |
| 68 |
pushdef([host_os], build_os)dnl |
| 69 |
pushdef([ac_cv_host], ac_cv_build)dnl |
| 70 |
pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl |
| 71 |
pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl |
| 72 |
pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl |
| 73 |
pushdef([ac_cv_host_os], ac_cv_build_os)dnl |
| 74 |
pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl |
| 75 |
pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)dnl |
| 76 |
pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl |
| 77 |
pushdef([cross_compiling], cross_compiling_build)dnl |
| 78 |
|
| 79 |
cross_compiling_build=no |
| 80 |
|
| 81 |
ac_build_tool_prefix= |
| 82 |
AS_IF([test -n "$build"], [ac_build_tool_prefix="$build-"], |
| 83 |
[test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"]) |
| 84 |
|
| 85 |
AC_LANG_PUSH([C]) |
| 86 |
AC_PROG_CC |
| 87 |
_AC_COMPILER_EXEEXT |
| 88 |
_AC_COMPILER_OBJEXT |
| 89 |
AC_PROG_CPP |
| 90 |
|
| 91 |
dnl Restore the old definitions |
| 92 |
dnl |
| 93 |
popdef([cross_compiling])dnl |
| 94 |
popdef([am_cv_prog_cc_c_o])dnl |
| 95 |
popdef([am_cv_CC_dependencies_compiler_type])dnl |
| 96 |
popdef([ac_tool_prefix])dnl |
| 97 |
popdef([ac_cv_host_os])dnl |
| 98 |
popdef([ac_cv_host_vendor])dnl |
| 99 |
popdef([ac_cv_host_cpu])dnl |
| 100 |
popdef([ac_cv_host_alias])dnl |
| 101 |
popdef([ac_cv_host])dnl |
| 102 |
popdef([host_os])dnl |
| 103 |
popdef([host_vendor])dnl |
| 104 |
popdef([host_cpu])dnl |
| 105 |
popdef([host_alias])dnl |
| 106 |
popdef([host])dnl |
| 107 |
popdef([OBJEXT])dnl |
| 108 |
popdef([LDFLAGS])dnl |
| 109 |
popdef([EXEEXT])dnl |
| 110 |
popdef([CPPFLAGS])dnl |
| 111 |
popdef([CFLAGS])dnl |
| 112 |
popdef([GCC])dnl |
| 113 |
popdef([CPP])dnl |
| 114 |
popdef([CC])dnl |
| 115 |
popdef([ac_objext])dnl |
| 116 |
popdef([ac_exeext])dnl |
| 117 |
popdef([ac_cv_objext])dnl |
| 118 |
popdef([ac_cv_exeext])dnl |
| 119 |
popdef([ac_cv_c_compiler_gnu])dnl |
| 120 |
popdef([ac_cv_prog_cc_g])dnl |
| 121 |
popdef([ac_cv_prog_cc_cross])dnl |
| 122 |
popdef([ac_cv_prog_cc_works])dnl |
| 123 |
popdef([ac_cv_prog_cc_c89])dnl |
| 124 |
popdef([ac_cv_prog_gcc])dnl |
| 125 |
popdef([ac_cv_prog_CPP])dnl |
| 126 |
|
| 127 |
dnl restore global variables ac_ext, ac_cpp, ac_compile, |
| 128 |
dnl ac_link, ac_compiler_gnu (depending on the current |
| 129 |
dnl language after popping): |
| 130 |
AC_LANG_POP([C]) |
| 131 |
|
| 132 |
dnl Finally, set Makefile variables |
| 133 |
dnl |
| 134 |
AC_SUBST(BUILD_EXEEXT)dnl |
| 135 |
AC_SUBST(BUILD_OBJEXT)dnl |
| 136 |
AC_SUBST([CFLAGS_FOR_BUILD])dnl |
| 137 |
AC_SUBST([CPPFLAGS_FOR_BUILD])dnl |
| 138 |
AC_SUBST([LDFLAGS_FOR_BUILD])dnl |
| 139 |
]) |