|
| 1 | +# =========================================================================== |
| 2 | +# https://www.gnu.org/software/autoconf-archive/ax_prog_cxx_for_build.html |
| 3 | +# =========================================================================== |
| 4 | +# |
| 5 | +# SYNOPSIS |
| 6 | +# |
| 7 | +# AX_PROG_CXX_FOR_BUILD |
| 8 | +# |
| 9 | +# DESCRIPTION |
| 10 | +# |
| 11 | +# This macro searches for a C++ compiler that generates native |
| 12 | +# executables, that is a C++ compiler that surely is not a cross-compiler. |
| 13 | +# This can be useful if you have to generate source code at compile-time |
| 14 | +# like for example GCC does. |
| 15 | +# |
| 16 | +# The macro sets the CXX_FOR_BUILD and CXXCPP_FOR_BUILD macros to anything |
| 17 | +# needed to compile or link (CXX_FOR_BUILD) and preprocess |
| 18 | +# (CXXCPP_FOR_BUILD). The value of these variables can be overridden by |
| 19 | +# the user by specifying a compiler with an environment variable (like you |
| 20 | +# do for standard CXX). |
| 21 | +# |
| 22 | +# LICENSE |
| 23 | +# |
| 24 | +# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org> |
| 25 | +# Copyright (c) 2012 Avionic Design GmbH |
| 26 | +# |
| 27 | +# Based on the AX_PROG_CC_FOR_BUILD macro by Paolo Bonzini. |
| 28 | +# |
| 29 | +# Copying and distribution of this file, with or without modification, are |
| 30 | +# permitted in any medium without royalty provided the copyright notice |
| 31 | +# and this notice are preserved. This file is offered as-is, without any |
| 32 | +# warranty. |
| 33 | + |
| 34 | +#serial 5 |
| 35 | + |
| 36 | +AU_ALIAS([AC_PROG_CXX_FOR_BUILD], [AX_PROG_CXX_FOR_BUILD]) |
| 37 | +AC_DEFUN([AX_PROG_CXX_FOR_BUILD], [dnl |
| 38 | +AC_REQUIRE([AX_PROG_CC_FOR_BUILD])dnl |
| 39 | +AC_REQUIRE([AC_PROG_CXX])dnl |
| 40 | +AC_REQUIRE([AC_PROG_CXXCPP])dnl |
| 41 | +AC_REQUIRE([AC_CANONICAL_HOST])dnl |
| 42 | +
|
| 43 | +dnl Use the standard macros, but make them use other variable names |
| 44 | +dnl |
| 45 | +pushdef([ac_cv_prog_CXXCPP], ac_cv_build_prog_CXXCPP)dnl |
| 46 | +pushdef([ac_cv_prog_gxx], ac_cv_build_prog_gxx)dnl |
| 47 | +pushdef([ac_cv_prog_cxx_works], ac_cv_build_prog_cxx_works)dnl |
| 48 | +pushdef([ac_cv_prog_cxx_cross], ac_cv_build_prog_cxx_cross)dnl |
| 49 | +pushdef([ac_cv_prog_cxx_g], ac_cv_build_prog_cxx_g)dnl |
| 50 | +pushdef([CXX], CXX_FOR_BUILD)dnl |
| 51 | +pushdef([CXXCPP], CXXCPP_FOR_BUILD)dnl |
| 52 | +pushdef([GXX], GXX_FOR_BUILD)dnl |
| 53 | +pushdef([CXXFLAGS], CXXFLAGS_FOR_BUILD)dnl |
| 54 | +pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl |
| 55 | +pushdef([CXXCPPFLAGS], CXXCPPFLAGS_FOR_BUILD)dnl |
| 56 | +pushdef([host], build)dnl |
| 57 | +pushdef([host_alias], build_alias)dnl |
| 58 | +pushdef([host_cpu], build_cpu)dnl |
| 59 | +pushdef([host_vendor], build_vendor)dnl |
| 60 | +pushdef([host_os], build_os)dnl |
| 61 | +pushdef([ac_cv_host], ac_cv_build)dnl |
| 62 | +pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl |
| 63 | +pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl |
| 64 | +pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl |
| 65 | +pushdef([ac_cv_host_os], ac_cv_build_os)dnl |
| 66 | +pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl |
| 67 | +pushdef([am_cv_CXX_dependencies_compiler_type], am_cv_build_CXX_dependencies_compiler_type)dnl |
| 68 | +pushdef([cross_compiling], cross_compiling_build)dnl |
| 69 | +
|
| 70 | +cross_compiling_build=no |
| 71 | +
|
| 72 | +ac_build_tool_prefix= |
| 73 | +AS_IF([test -n "$build"], [ac_build_tool_prefix="$build-"], |
| 74 | + [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"]) |
| 75 | +
|
| 76 | +AC_LANG_PUSH([C++]) |
| 77 | +AC_PROG_CXX |
| 78 | +AC_PROG_CXXCPP |
| 79 | +
|
| 80 | +dnl Restore the old definitions |
| 81 | +dnl |
| 82 | +popdef([cross_compiling])dnl |
| 83 | +popdef([am_cv_CXX_dependencies_compiler_type])dnl |
| 84 | +popdef([ac_tool_prefix])dnl |
| 85 | +popdef([ac_cv_host_os])dnl |
| 86 | +popdef([ac_cv_host_vendor])dnl |
| 87 | +popdef([ac_cv_host_cpu])dnl |
| 88 | +popdef([ac_cv_host_alias])dnl |
| 89 | +popdef([ac_cv_host])dnl |
| 90 | +popdef([host_os])dnl |
| 91 | +popdef([host_vendor])dnl |
| 92 | +popdef([host_cpu])dnl |
| 93 | +popdef([host_alias])dnl |
| 94 | +popdef([host])dnl |
| 95 | +popdef([CXXCPPFLAGS])dnl |
| 96 | +popdef([CPPFLAGS])dnl |
| 97 | +popdef([CXXFLAGS])dnl |
| 98 | +popdef([CXXCPP])dnl |
| 99 | +popdef([CXX])dnl |
| 100 | +popdef([ac_cv_prog_cxx_g])dnl |
| 101 | +popdef([ac_cv_prog_cxx_cross])dnl |
| 102 | +popdef([ac_cv_prog_cxx_works])dnl |
| 103 | +popdef([ac_cv_prog_gxx])dnl |
| 104 | +popdef([ac_cv_prog_CXXCPP])dnl |
| 105 | +
|
| 106 | +dnl restore global variables (dependent on the current |
| 107 | +dnl language after popping): |
| 108 | +AC_LANG_POP([C++]) |
| 109 | +
|
| 110 | +dnl Finally, set Makefile variables |
| 111 | +dnl |
| 112 | +AC_SUBST([CXXFLAGS_FOR_BUILD])dnl |
| 113 | +AC_SUBST([CXXCPPFLAGS_FOR_BUILD])dnl |
| 114 | +]) |
0 commit comments