| 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 <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 26 |
| 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_gcc], ac_cv_build_prog_gcc)dnl |
| 47 | pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl |
| 48 | pushdef([ac_cv_prog_cc_c99], ac_cv_build_prog_cc_c99)dnl |
| 49 | pushdef([ac_cv_prog_cc_c11], ac_cv_build_prog_cc_c11)dnl |
| 50 | pushdef([ac_cv_prog_cc_c23], ac_cv_build_prog_cc_c23)dnl |
| 51 | pushdef([ac_cv_prog_cc_stdc], ac_cv_build_prog_cc_stdc)dnl |
| 52 | pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl |
| 53 | pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl |
| 54 | pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl |
| 55 | pushdef([ac_prog_cc_stdc], ac_build_prog_cc_stdc)dnl |
| 56 | pushdef([ac_exeext], ac_build_exeext)dnl |
| 57 | pushdef([ac_objext], ac_build_objext)dnl |
| 58 | pushdef([CC], CC_FOR_BUILD)dnl |
| 59 | pushdef([CPP], CPP_FOR_BUILD)dnl |
| 60 | pushdef([GCC], GCC_FOR_BUILD)dnl |
| 61 | pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl |
| 62 | pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl |
| 63 | pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)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 | dnl |
| 79 | dnl These variables are problematic to rename by M4 macros, so we save |
| 80 | dnl their values in alternative names, and restore the values later. |
| 81 | dnl |
| 82 | dnl _AC_COMPILER_EXEEXT and _AC_COMPILER_OBJEXT internally call |
| 83 | dnl AC_SUBST which prevents the renaming of EXEEXT and OBJEXT |
| 84 | dnl variables. It's not a good idea to rename ac_cv_exeext and |
| 85 | dnl ac_cv_objext either as they're related. |
| 86 | dnl Renaming ac_exeext and ac_objext is safe though. |
| 87 | dnl |
| 88 | ac_cv_host_exeext=$ac_cv_exeext |
| 89 | AS_VAR_SET_IF([ac_cv_build_exeext], |
| 90 | [ac_cv_exeext=$ac_cv_build_exeext], |
| 91 | [AS_UNSET([ac_cv_exeext])]) |
| 92 | ac_cv_host_objext=$ac_cv_objext |
| 93 | AS_VAR_SET_IF([ac_cv_build_objext], |
| 94 | [ac_cv_objext=$ac_cv_build_objext], |
| 95 | [AS_UNSET([ac_cv_objext])]) |
| 96 | dnl |
| 97 | dnl ac_cv_c_compiler_gnu is used in _AC_LANG_COMPILER_GNU (called by |
| 98 | dnl AC_PROG_CC) indirectly. |
| 99 | dnl |
| 100 | ac_cv_host_c_compiler_gnu=$ac_cv_c_compiler_gnu |
| 101 | AS_VAR_SET_IF([ac_cv_build_c_compiler_gnu], |
| 102 | [ac_cv_c_compiler_gnu=$ac_cv_build_c_compiler_gnu], |
| 103 | [AS_UNSET([ac_cv_c_compiler_gnu])]) |
| 104 |
|
| 105 | cross_compiling_build=no |
| 106 |
|
| 107 | ac_build_tool_prefix= |
| 108 | AS_IF([test -n "$build"], [ac_build_tool_prefix="$build-"], |
| 109 | [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"]) |
| 110 |
|
| 111 | AC_LANG_PUSH([C]) |
| 112 | AC_PROG_CC |
| 113 | _AC_COMPILER_EXEEXT |
| 114 | _AC_COMPILER_OBJEXT |
| 115 | AC_PROG_CPP |
| 116 |
|
| 117 | BUILD_EXEEXT=$ac_cv_exeext |
| 118 | BUILD_OBJEXT=$ac_cv_objext |
| 119 |
|
| 120 | dnl Restore the old definitions |
| 121 | dnl |
| 122 | popdef([cross_compiling])dnl |
| 123 | popdef([am_cv_prog_cc_c_o])dnl |
| 124 | popdef([am_cv_CC_dependencies_compiler_type])dnl |
| 125 | popdef([ac_tool_prefix])dnl |
| 126 | popdef([ac_cv_host_os])dnl |
| 127 | popdef([ac_cv_host_vendor])dnl |
| 128 | popdef([ac_cv_host_cpu])dnl |
| 129 | popdef([ac_cv_host_alias])dnl |
| 130 | popdef([ac_cv_host])dnl |
| 131 | popdef([host_os])dnl |
| 132 | popdef([host_vendor])dnl |
| 133 | popdef([host_cpu])dnl |
| 134 | popdef([host_alias])dnl |
| 135 | popdef([host])dnl |
| 136 | popdef([LDFLAGS])dnl |
| 137 | popdef([CPPFLAGS])dnl |
| 138 | popdef([CFLAGS])dnl |
| 139 | popdef([GCC])dnl |
| 140 | popdef([CPP])dnl |
| 141 | popdef([CC])dnl |
| 142 | popdef([ac_objext])dnl |
| 143 | popdef([ac_exeext])dnl |
| 144 | popdef([ac_prog_cc_stdc])dnl |
| 145 | popdef([ac_cv_prog_cc_g])dnl |
| 146 | popdef([ac_cv_prog_cc_cross])dnl |
| 147 | popdef([ac_cv_prog_cc_works])dnl |
| 148 | popdef([ac_cv_prog_cc_stdc])dnl |
| 149 | popdef([ac_cv_prog_cc_c23])dnl |
| 150 | popdef([ac_cv_prog_cc_c11])dnl |
| 151 | popdef([ac_cv_prog_cc_c99])dnl |
| 152 | popdef([ac_cv_prog_cc_c89])dnl |
| 153 | popdef([ac_cv_prog_gcc])dnl |
| 154 | popdef([ac_cv_prog_CPP])dnl |
| 155 | dnl |
| 156 | ac_cv_exeext=$ac_cv_host_exeext |
| 157 | EXEEXT=$ac_cv_host_exeext |
| 158 | ac_cv_objext=$ac_cv_host_objext |
| 159 | OBJEXT=$ac_cv_host_objext |
| 160 | ac_cv_c_compiler_gnu=$ac_cv_host_c_compiler_gnu |
| 161 | ac_compiler_gnu=$ac_cv_host_c_compiler_gnu |
| 162 |
|
| 163 | dnl restore global variables ac_ext, ac_cpp, ac_compile, |
| 164 | dnl ac_link, ac_compiler_gnu (dependent on the current |
| 165 | dnl language after popping): |
| 166 | AC_LANG_POP([C]) |
| 167 |
|
| 168 | dnl Finally, set Makefile variables |
| 169 | dnl |
| 170 | AC_SUBST([BUILD_EXEEXT])dnl |
| 171 | AC_SUBST([BUILD_OBJEXT])dnl |
| 172 | AC_SUBST([CFLAGS_FOR_BUILD])dnl |
| 173 | AC_SUBST([CPPFLAGS_FOR_BUILD])dnl |
| 174 | AC_SUBST([LDFLAGS_FOR_BUILD])dnl |
| 175 | ]) |
| 176 |
|