1 # generated automatically by aclocal 1.16.5 -*- Autoconf -*-
3 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
15 # ===========================================================================
16 # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html
17 # ===========================================================================
21 # AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional])
25 # Check for baseline language coverage in the compiler for the specified
26 # version of the C++ standard. If necessary, add switches to CXX and
27 # CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for
28 # the respective C++ standard version.
30 # The second argument, if specified, indicates whether you insist on an
31 # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
32 # -std=c++11). If neither is specified, you get whatever works, with
33 # preference for no added switch, and then for an extended mode.
35 # The third argument, if specified 'mandatory' or if left unspecified,
36 # indicates that baseline support for the specified C++ standard is
37 # required and that the macro should error out if no mode with that
38 # support is found. If specified 'optional', then configuration proceeds
39 # regardless, after defining HAVE_CXX${VERSION} if and only if a
40 # supporting mode is found.
44 # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
45 # Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
46 # Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
47 # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
48 # Copyright (c) 2015 Paul Norman <penorman@mac.com>
49 # Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
50 # Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
51 # Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com>
52 # Copyright (c) 2020 Jason Merrill <jason@redhat.com>
53 # Copyright (c) 2021 Jörn Heusipp <osmanx@problemloesungsmaschine.de>
55 # Copying and distribution of this file, with or without modification, are
56 # permitted in any medium without royalty provided the copyright notice
57 # and this notice are preserved. This file is offered as-is, without any
62 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
63 dnl (serial version number 13).
65 AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
66 m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"],
67 [$1], [14], [ax_cxx_compile_alternatives="14 1y"],
68 [$1], [17], [ax_cxx_compile_alternatives="17 1z"],
69 [$1], [20], [ax_cxx_compile_alternatives="20"],
70 [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
74 [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl
75 m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true],
76 [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true],
77 [$3], [optional], [ax_cxx_compile_cxx$1_required=false],
78 [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])])
79 AC_LANG_PUSH([C++])dnl
83 AC_CACHE_CHECK(whether $CXX supports C++$1 features by default,
84 ax_cv_cxx_compile_cxx$1,
85 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
86 [ax_cv_cxx_compile_cxx$1=yes],
87 [ax_cv_cxx_compile_cxx$1=no])])
88 if test x$ax_cv_cxx_compile_cxx$1 = xyes; then
92 m4_if([$2], [noext], [], [dnl
93 if test x$ac_success = xno; then
94 for alternative in ${ax_cxx_compile_alternatives}; do
95 switch="-std=gnu++${alternative}"
96 cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
97 AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
101 AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
102 [eval $cachevar=yes],
105 if eval test x\$$cachevar = xyes; then
107 if test -n "$CXXCPP" ; then
108 CXXCPP="$CXXCPP $switch"
116 m4_if([$2], [ext], [], [dnl
117 if test x$ac_success = xno; then
118 dnl HP's aCC needs +std=c++11 according to:
119 dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
120 dnl Cray's crayCC needs "-h std=c++11"
121 for alternative in ${ax_cxx_compile_alternatives}; do
122 for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do
123 cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch])
124 AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch,
128 AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])],
129 [eval $cachevar=yes],
132 if eval test x\$$cachevar = xyes; then
134 if test -n "$CXXCPP" ; then
135 CXXCPP="$CXXCPP $switch"
141 if test x$ac_success = xyes; then
147 if test x$ax_cxx_compile_cxx$1_required = xtrue; then
148 if test x$ac_success = xno; then
149 AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.])
152 if test x$ac_success = xno; then
154 AC_MSG_NOTICE([No compiler with C++$1 support was found])
157 AC_DEFINE(HAVE_CXX$1,1,
158 [define if the compiler supports basic C++$1 syntax])
164 dnl Test body for checking C++11 support
166 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
167 _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
170 dnl Test body for checking C++14 support
172 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
173 _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
174 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
177 dnl Test body for checking C++17 support
179 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
180 _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
181 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
182 _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
185 dnl Test body for checking C++20 support
187 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
188 _AX_CXX_COMPILE_STDCXX_testbody_new_in_11
189 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14
190 _AX_CXX_COMPILE_STDCXX_testbody_new_in_17
191 _AX_CXX_COMPILE_STDCXX_testbody_new_in_20
195 dnl Tests for new features in C++11
197 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
199 // If the compiler admits that it is not ready for C++11, why torture it?
200 // Hopefully, this will speed up the test.
204 #error "This is not a C++ compiler"
206 // MSVC always sets __cplusplus to 199711L in older versions; newer versions
207 // only set it correctly if /Zc:__cplusplus is specified as well as a
208 // /std:c++NN switch:
209 // https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
210 #elif __cplusplus < 201103L && !defined _MSC_VER
212 #error "This is not a C++11 compiler"
219 namespace test_static_assert
222 template <typename T>
225 static_assert(sizeof(int) <= sizeof(T), "not big enough");
230 namespace test_final_override
239 struct Derived : public Base
241 virtual ~Derived() override {}
242 virtual void f() override {}
247 namespace test_double_right_angle_brackets
250 template < typename T >
253 typedef check<void> single_type;
254 typedef check<check<void>> double_type;
255 typedef check<check<check<void>>> triple_type;
256 typedef check<check<check<check<void>>>> quadruple_type;
260 namespace test_decltype
273 namespace test_type_deduction
276 template < typename T1, typename T2 >
279 static const bool value = false;
282 template < typename T >
285 static const bool value = true;
288 template < typename T1, typename T2 >
290 add(T1 a1, T2 a2) -> decltype(a1 + a2)
296 test(const int c, volatile int v)
298 static_assert(is_same<int, decltype(0)>::value == true, "");
299 static_assert(is_same<int, decltype(c)>::value == false, "");
300 static_assert(is_same<int, decltype(v)>::value == false, "");
303 auto sumi = ac + av + 'x';
304 auto sumf = ac + av + 1.0;
305 static_assert(is_same<int, decltype(ac)>::value == true, "");
306 static_assert(is_same<int, decltype(av)>::value == true, "");
307 static_assert(is_same<int, decltype(sumi)>::value == true, "");
308 static_assert(is_same<int, decltype(sumf)>::value == false, "");
309 static_assert(is_same<int, decltype(add(c, v))>::value == true, "");
310 return (sumf > 0.0) ? sumi : add(c, v);
315 namespace test_noexcept
318 int f() { return 0; }
319 int g() noexcept { return 0; }
321 static_assert(noexcept(f()) == false, "");
322 static_assert(noexcept(g()) == true, "");
326 namespace test_constexpr
329 template < typename CharT >
330 unsigned long constexpr
331 strlen_c_r(const CharT *const s, const unsigned long acc) noexcept
333 return *s ? strlen_c_r(s + 1, acc + 1) : acc;
336 template < typename CharT >
337 unsigned long constexpr
338 strlen_c(const CharT *const s) noexcept
340 return strlen_c_r(s, 0UL);
343 static_assert(strlen_c("") == 0UL, "");
344 static_assert(strlen_c("1") == 1UL, "");
345 static_assert(strlen_c("example") == 7UL, "");
346 static_assert(strlen_c("another\0example") == 7UL, "");
350 namespace test_rvalue_references
356 static constexpr int value = N;
359 answer<1> f(int&) { return answer<1>(); }
360 answer<2> f(const int&) { return answer<2>(); }
361 answer<3> f(int&&) { return answer<3>(); }
368 static_assert(decltype(f(i))::value == 1, "");
369 static_assert(decltype(f(c))::value == 2, "");
370 static_assert(decltype(f(0))::value == 3, "");
375 namespace test_uniform_initialization
380 static const int zero {};
381 static const int one {1};
384 static_assert(test::zero == 0, "");
385 static_assert(test::one == 1, "");
389 namespace test_lambdas
395 auto lambda1 = [](){};
396 auto lambda2 = lambda1;
404 auto a = [](int i, int j){ return i + j; }(1, 2);
405 auto b = []() -> int { return '0'; }();
406 auto c = [=](){ return a + b; }();
407 auto d = [&](){ return c; }();
408 auto e = [a, &b](int x) mutable {
409 const auto identity = [](int y){ return y; };
410 for (auto i = 0; i < a; ++i)
412 return x + identity(a + b);
414 return a + b + c + d + e;
420 const auto nullary = [](){ return 0; };
421 const auto unary = [](int x){ return x; };
422 using nullary_t = decltype(nullary);
423 using unary_t = decltype(unary);
424 const auto higher1st = [](nullary_t f){ return f(); };
425 const auto higher2nd = [unary](nullary_t f1){
426 return [unary, f1](unary_t f2){ return f2(unary(f1())); };
428 return higher1st(nullary) + higher2nd(nullary)(unary);
433 namespace test_variadic_templates
439 template <int N0, int... N1toN>
440 struct sum<N0, N1toN...>
442 static constexpr auto value = N0 + sum<N1toN...>::value;
448 static constexpr auto value = 0;
451 static_assert(sum<>::value == 0, "");
452 static_assert(sum<1>::value == 1, "");
453 static_assert(sum<23>::value == 23, "");
454 static_assert(sum<1, 2>::value == 3, "");
455 static_assert(sum<5, 5, 11>::value == 21, "");
456 static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, "");
460 // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
461 // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function
463 namespace test_template_alias_sfinae
469 using member = typename T::member_type;
475 void func(member<T>*) {}
479 void test() { func<foo>(0); }
485 #endif // __cplusplus >= 201103L
490 dnl Tests for new features in C++14
492 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[
494 // If the compiler admits that it is not ready for C++14, why torture it?
495 // Hopefully, this will speed up the test.
499 #error "This is not a C++ compiler"
501 #elif __cplusplus < 201402L && !defined _MSC_VER
503 #error "This is not a C++14 compiler"
510 namespace test_polymorphic_lambdas
516 const auto lambda = [](auto&&... args){
517 const auto istiny = [](auto x){
518 return (sizeof(x) == 1UL) ? 1 : 0;
520 const int aretiny[] = { istiny(args)... };
523 return lambda(1, 1L, 1.0f, '1');
528 namespace test_binary_literals
531 constexpr auto ivii = 0b0000000000101010;
532 static_assert(ivii == 42, "wrong value");
536 namespace test_generalized_constexpr
539 template < typename CharT >
540 constexpr unsigned long
541 strlen_c(const CharT *const s) noexcept
544 for (auto p = s; *p; ++p)
549 static_assert(strlen_c("") == 0UL, "");
550 static_assert(strlen_c("x") == 1UL, "");
551 static_assert(strlen_c("test") == 4UL, "");
552 static_assert(strlen_c("another\0test") == 7UL, "");
556 namespace test_lambda_init_capture
563 const auto lambda1 = [a = x](int b){ return a + b; };
564 const auto lambda2 = [a = lambda1(x)](){ return a; };
570 namespace test_digit_separators
573 constexpr auto ten_million = 100'000'000;
574 static_assert(ten_million == 100000000, "");
578 namespace test_return_type_deduction
581 auto f(int& x) { return x; }
582 decltype(auto) g(int& x) { return x; }
584 template < typename T1, typename T2 >
587 static constexpr auto value = false;
590 template < typename T >
593 static constexpr auto value = true;
600 static_assert(is_same<int, decltype(f(x))>::value, "");
601 static_assert(is_same<int&, decltype(g(x))>::value, "");
609 #endif // __cplusplus >= 201402L
614 dnl Tests for new features in C++17
616 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
618 // If the compiler admits that it is not ready for C++17, why torture it?
619 // Hopefully, this will speed up the test.
623 #error "This is not a C++ compiler"
625 #elif __cplusplus < 201703L && !defined _MSC_VER
627 #error "This is not a C++17 compiler"
631 #include <initializer_list>
633 #include <type_traits>
638 namespace test_constexpr_lambdas
641 constexpr int foo = [](){return 42;}();
645 namespace test::nested_namespace::definitions
650 namespace test_fold_expression
653 template<typename... Args>
654 int multiply(Args... args)
656 return (args * ... * 1);
659 template<typename... Args>
660 bool all(Args... args)
662 return (args && ...);
667 namespace test_extended_static_assert
670 static_assert (true);
674 namespace test_auto_brace_init_list
680 static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value);
681 static_assert(std::is_same<int, decltype(bar)>::value);
684 namespace test_typename_in_template_template_parameter
687 template<template<typename> typename X> struct D;
691 namespace test_fallthrough_nodiscard_maybe_unused_attributes
699 [[nodiscard]] int f2()
701 [[maybe_unused]] auto unused = f1();
716 namespace test_extended_aggregate_initialization
732 struct derived : base1, base2
737 derived d1 {{1, 2}, {}, 4}; // full initialization
738 derived d2 {{}, {}, 4}; // value-initialized bases
742 namespace test_general_range_based_for_loop
754 const int& operator* () const
771 bool operator== (const iter& i, const sentinel& s)
776 bool operator!= (const iter& i, const sentinel& s)
800 [[maybe_unused]] auto v = i;
806 namespace test_lambda_capture_asterisk_this_by_value
823 namespace test_enum_class_construction
826 enum class byte : unsigned char
833 namespace test_constexpr_if
851 namespace test_selection_statement_with_initializer
861 if (auto i = f(); i > 0)
866 switch (auto i = f(); i + 4)
878 namespace test_template_argument_deduction_for_class_templates
881 template <typename T1, typename T2>
895 [[maybe_unused]] auto p = pair{13, 42u};
900 namespace test_non_type_auto_template_parameters
912 namespace test_structured_bindings
915 int arr[2] = { 1, 2 };
916 std::pair<int, int> pr = { 1, 2 };
918 auto f1() -> int(&)[2]
923 auto f2() -> std::pair<int, int>&
939 auto [ x1, y1 ] = f1();
940 auto& [ xr1, yr1 ] = f1();
941 auto [ x2, y2 ] = f2();
942 auto& [ xr2, yr2 ] = f2();
943 const auto [ x3, y3 ] = f3();
947 namespace test_exception_spec_type_system
960 template<typename T1, typename T2>
964 static_assert (std::is_same_v<Good, decltype(f(g1, g2))>);
968 namespace test_inline_variables
971 template<class T> void f(T)
974 template<class T> inline T g(T)
979 template<> inline void f<>(int)
982 template<> int g<>(int)
991 #endif // __cplusplus < 201703L && !defined _MSC_VER
996 dnl Tests for new features in C++20
998 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
1002 #error "This is not a C++ compiler"
1004 #elif __cplusplus < 202002L && !defined _MSC_VER
1006 #error "This is not a C++20 compiler"
1015 // As C++20 supports feature test macros in the standard, there is no
1016 // immediate need to actually test for feature availability on the
1019 } // namespace cxx20
1021 #endif // __cplusplus < 202002L && !defined _MSC_VER
1025 # =============================================================================
1026 # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
1027 # =============================================================================
1031 # AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional])
1035 # Check for baseline language coverage in the compiler for the C++11
1036 # standard; if necessary, add switches to CXX and CXXCPP to enable
1039 # This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
1040 # macro with the version set to C++11. The two optional arguments are
1041 # forwarded literally as the second and third argument respectively.
1042 # Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
1043 # more information. If you want to use this macro, you also need to
1044 # download the ax_cxx_compile_stdcxx.m4 file.
1048 # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
1049 # Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
1050 # Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
1051 # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
1052 # Copyright (c) 2015 Paul Norman <penorman@mac.com>
1053 # Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
1055 # Copying and distribution of this file, with or without modification, are
1056 # permitted in any medium without royalty provided the copyright notice
1057 # and this notice are preserved. This file is offered as-is, without any
1062 AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
1063 AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])
1065 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
1067 # This file is free software; the Free Software Foundation
1068 # gives unlimited permission to copy and/or distribute it,
1069 # with or without modifications, as long as this notice is preserved.
1072 # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1073 # ---------------------------------------------------------------------------
1074 # Adds support for distributing Python modules and packages. To
1075 # install modules, copy them to $(pythondir), using the python_PYTHON
1076 # automake variable. To install a package with the same name as the
1077 # automake package, install to $(pkgpythondir), or use the
1078 # pkgpython_PYTHON automake variable.
1080 # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
1081 # locations to install python extension modules (shared libraries).
1082 # Another macro is required to find the appropriate flags to compile
1083 # extension modules.
1085 # If your package is configured with a different prefix to python,
1086 # users will have to add the install directory to the PYTHONPATH
1087 # environment variable, or create a .pth file (see the python
1088 # documentation for details).
1090 # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
1091 # cause an error if the version of python installed on the system
1092 # doesn't meet the requirement. MINIMUM-VERSION should consist of
1093 # numbers and dots only.
1094 AC_DEFUN([AM_PATH_PYTHON],
1096 dnl Find a Python interpreter. Python versions prior to 2.0 are not
1097 dnl supported. (2.0 was released on October 16, 2000).
1098 m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
1099 [python python2 python3 dnl
1100 python3.11 python3.10 dnl
1101 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 dnl
1102 python3.2 python3.1 python3.0 dnl
1103 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 dnl
1106 AC_ARG_VAR([PYTHON], [the Python interpreter])
1109 dnl No version check is needed.
1110 # Find any Python interpreter.
1111 if test -z "$PYTHON"; then
1112 AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
1114 am_display_PYTHON=python
1116 dnl A version check is needed.
1117 if test -n "$PYTHON"; then
1118 # If the user set $PYTHON, use it and don't search something else.
1119 AC_MSG_CHECKING([whether $PYTHON version is >= $1])
1120 AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
1121 [AC_MSG_RESULT([yes])],
1122 [AC_MSG_RESULT([no])
1123 AC_MSG_ERROR([Python interpreter is too old])])
1124 am_display_PYTHON=$PYTHON
1126 # Otherwise, try each interpreter until we find one that satisfies
1128 AC_CACHE_CHECK([for a Python interpreter with version >= $1],
1129 [am_cv_pathless_PYTHON],[
1130 for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
1131 test "$am_cv_pathless_PYTHON" = none && break
1132 AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
1134 # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
1135 if test "$am_cv_pathless_PYTHON" = none; then
1138 AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
1140 am_display_PYTHON=$am_cv_pathless_PYTHON
1144 if test "$PYTHON" = :; then
1145 dnl Run any user-specified action, or abort.
1146 m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
1149 dnl Query Python for its version number. Although site.py simply uses
1150 dnl sys.version[:3], printing that failed with Python 3.10, since the
1151 dnl trailing zero was eliminated. So now we output just the major
1152 dnl and minor version numbers, as numbers. Apparently the tertiary
1153 dnl version is not of interest.
1155 AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
1156 [am_cv_python_version=`$PYTHON -c "import sys; print ('%u.%u' % sys.version_info[[:2]])"`])
1157 AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
1159 dnl At times, e.g., when building shared libraries, you may want
1160 dnl to know which OS platform Python thinks this is.
1162 AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
1163 [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
1164 AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
1167 dnl If --with-python-sys-prefix is given, use the values of sys.prefix
1168 dnl and sys.exec_prefix for the corresponding values of PYTHON_PREFIX
1169 dnl and PYTHON_EXEC_PREFIX. Otherwise, use the GNU ${prefix} and
1170 dnl ${exec_prefix} variables.
1172 dnl The two are made distinct variables so they can be overridden if
1173 dnl need be, although general consensus is that you shouldn't need
1174 dnl this separation.
1176 dnl Also allow directly setting the prefixes via configure options,
1177 dnl overriding any default.
1179 if test "x$prefix" = xNONE; then
1180 am__usable_prefix=$ac_default_prefix
1182 am__usable_prefix=$prefix
1185 # Allow user to request using sys.* values from Python,
1186 # instead of the GNU $prefix values.
1187 AC_ARG_WITH([python-sys-prefix],
1188 [AS_HELP_STRING([--with-python-sys-prefix],
1189 [use Python's sys.prefix and sys.exec_prefix values])],
1190 [am_use_python_sys=:],
1191 [am_use_python_sys=false])
1193 # Allow user to override whatever the default Python prefix is.
1194 AC_ARG_WITH([python_prefix],
1195 [AS_HELP_STRING([--with-python_prefix],
1196 [override the default PYTHON_PREFIX])],
1197 [am_python_prefix_subst=$withval
1198 am_cv_python_prefix=$withval
1199 AC_MSG_CHECKING([for explicit $am_display_PYTHON prefix])
1200 AC_MSG_RESULT([$am_cv_python_prefix])],
1202 if $am_use_python_sys; then
1203 # using python sys.prefix value, not GNU
1204 AC_CACHE_CHECK([for python default $am_display_PYTHON prefix],
1205 [am_cv_python_prefix],
1206 [am_cv_python_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`])
1208 dnl If sys.prefix is a subdir of $prefix, replace the literal value of
1209 dnl $prefix with a variable reference so it can be overridden.
1210 case $am_cv_python_prefix in
1211 $am__usable_prefix*)
1212 am__strip_prefix=`echo "$am__usable_prefix" | sed 's|.|.|g'`
1213 am_python_prefix_subst=`echo "$am_cv_python_prefix" | sed "s,^$am__strip_prefix,\\${prefix},"`
1216 am_python_prefix_subst=$am_cv_python_prefix
1219 else # using GNU prefix value, not python sys.prefix
1220 am_python_prefix_subst='${prefix}'
1221 am_python_prefix=$am_python_prefix_subst
1222 AC_MSG_CHECKING([for GNU default $am_display_PYTHON prefix])
1223 AC_MSG_RESULT([$am_python_prefix])
1225 # Substituting python_prefix_subst value.
1226 AC_SUBST([PYTHON_PREFIX], [$am_python_prefix_subst])
1228 # emacs-page Now do it all over again for Python exec_prefix, but with yet
1229 # another conditional: fall back to regular prefix if that was specified.
1230 AC_ARG_WITH([python_exec_prefix],
1231 [AS_HELP_STRING([--with-python_exec_prefix],
1232 [override the default PYTHON_EXEC_PREFIX])],
1233 [am_python_exec_prefix_subst=$withval
1234 am_cv_python_exec_prefix=$withval
1235 AC_MSG_CHECKING([for explicit $am_display_PYTHON exec_prefix])
1236 AC_MSG_RESULT([$am_cv_python_exec_prefix])],
1238 # no explicit --with-python_exec_prefix, but if
1239 # --with-python_prefix was given, use its value for python_exec_prefix too.
1240 AS_IF([test -n "$with_python_prefix"],
1241 [am_python_exec_prefix_subst=$with_python_prefix
1242 am_cv_python_exec_prefix=$with_python_prefix
1243 AC_MSG_CHECKING([for python_prefix-given $am_display_PYTHON exec_prefix])
1244 AC_MSG_RESULT([$am_cv_python_exec_prefix])],
1246 # Set am__usable_exec_prefix whether using GNU or Python values,
1247 # since we use that variable for pyexecdir.
1248 if test "x$exec_prefix" = xNONE; then
1249 am__usable_exec_prefix=$am__usable_prefix
1251 am__usable_exec_prefix=$exec_prefix
1254 if $am_use_python_sys; then # using python sys.exec_prefix, not GNU
1255 AC_CACHE_CHECK([for python default $am_display_PYTHON exec_prefix],
1256 [am_cv_python_exec_prefix],
1257 [am_cv_python_exec_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.exec_prefix)"`])
1258 dnl If sys.exec_prefix is a subdir of $exec_prefix, replace the
1259 dnl literal value of $exec_prefix with a variable reference so it can
1261 case $am_cv_python_exec_prefix in
1262 $am__usable_exec_prefix*)
1263 am__strip_prefix=`echo "$am__usable_exec_prefix" | sed 's|.|.|g'`
1264 am_python_exec_prefix_subst=`echo "$am_cv_python_exec_prefix" | sed "s,^$am__strip_prefix,\\${exec_prefix},"`
1267 am_python_exec_prefix_subst=$am_cv_python_exec_prefix
1270 else # using GNU $exec_prefix, not python sys.exec_prefix
1271 am_python_exec_prefix_subst='${exec_prefix}'
1272 am_python_exec_prefix=$am_python_exec_prefix_subst
1273 AC_MSG_CHECKING([for GNU default $am_display_PYTHON exec_prefix])
1274 AC_MSG_RESULT([$am_python_exec_prefix])
1276 # Substituting python_exec_prefix_subst.
1277 AC_SUBST([PYTHON_EXEC_PREFIX], [$am_python_exec_prefix_subst])
1279 # Factor out some code duplication into this shell variable.
1280 am_python_setup_sysconfig="\
1282 # Prefer sysconfig over distutils.sysconfig, for better compatibility
1283 # with python 3.x. See automake bug#10227.
1287 can_use_sysconfig = 0
1289 can_use_sysconfig = 1
1290 # Can't use sysconfig in CPython 2.7, since it's broken in virtualenvs:
1291 # <https://github.com/pypa/virtualenv/issues/118>
1293 from platform import python_implementation
1294 if python_implementation() == 'CPython' and sys.version[[:3]] == '2.7':
1295 can_use_sysconfig = 0
1299 dnl emacs-page Set up 4 directories:
1301 dnl 1. pythondir: where to install python scripts. This is the
1302 dnl site-packages directory, not the python standard library
1303 dnl directory like in previous automake betas. This behavior
1304 dnl is more consistent with lispdir.m4 for example.
1305 dnl Query distutils for this directory.
1307 AC_CACHE_CHECK([for $am_display_PYTHON script directory (pythondir)],
1308 [am_cv_python_pythondir],
1309 [if test "x$am_cv_python_prefix" = x; then
1310 am_py_prefix=$am__usable_prefix
1312 am_py_prefix=$am_cv_python_prefix
1314 am_cv_python_pythondir=`$PYTHON -c "
1315 $am_python_setup_sysconfig
1316 if can_use_sysconfig:
1317 if hasattr(sysconfig, 'get_default_scheme'):
1318 scheme = sysconfig.get_default_scheme()
1320 scheme = sysconfig._get_default_scheme()
1321 if scheme == 'posix_local':
1322 # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/
1323 scheme = 'posix_prefix'
1324 sitedir = sysconfig.get_path('purelib', scheme, vars={'base':'$am_py_prefix'})
1326 from distutils import sysconfig
1327 sitedir = sysconfig.get_python_lib(0, 0, prefix='$am_py_prefix')
1328 sys.stdout.write(sitedir)"`
1330 case $am_cv_python_pythondir in
1332 am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'`
1333 am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,\\${PYTHON_PREFIX},"`
1336 case $am_py_prefix in
1338 *) am_cv_python_pythondir="\${PYTHON_PREFIX}/lib/python$PYTHON_VERSION/site-packages"
1344 AC_SUBST([pythondir], [$am_cv_python_pythondir])
1346 dnl 2. pkgpythondir: $PACKAGE directory under pythondir. Was
1347 dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
1348 dnl more consistent with the rest of automake.
1350 AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
1352 dnl 3. pyexecdir: directory for installing python extension modules
1353 dnl (shared libraries).
1354 dnl Query distutils for this directory.
1356 AC_CACHE_CHECK([for $am_display_PYTHON extension module directory (pyexecdir)],
1357 [am_cv_python_pyexecdir],
1358 [if test "x$am_cv_python_exec_prefix" = x; then
1359 am_py_exec_prefix=$am__usable_exec_prefix
1361 am_py_exec_prefix=$am_cv_python_exec_prefix
1363 am_cv_python_pyexecdir=`$PYTHON -c "
1364 $am_python_setup_sysconfig
1365 if can_use_sysconfig:
1366 if hasattr(sysconfig, 'get_default_scheme'):
1367 scheme = sysconfig.get_default_scheme()
1369 scheme = sysconfig._get_default_scheme()
1370 if scheme == 'posix_local':
1371 # Debian's default scheme installs to /usr/local/ but we want to find headers in /usr/
1372 scheme = 'posix_prefix'
1373 sitedir = sysconfig.get_path('platlib', scheme, vars={'platbase':'$am_py_exec_prefix'})
1375 from distutils import sysconfig
1376 sitedir = sysconfig.get_python_lib(1, 0, prefix='$am_py_exec_prefix')
1377 sys.stdout.write(sitedir)"`
1379 case $am_cv_python_pyexecdir in
1380 $am_py_exec_prefix*)
1381 am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'`
1382 am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,\\${PYTHON_EXEC_PREFIX},"`
1385 case $am_py_exec_prefix in
1387 *) am_cv_python_pyexecdir="\${PYTHON_EXEC_PREFIX}/lib/python$PYTHON_VERSION/site-packages"
1393 AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
1395 dnl 4. pkgpyexecdir: $(pyexecdir)/$(PACKAGE)
1397 AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
1399 dnl Run any user-specified action.
1405 # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
1406 # ---------------------------------------------------------------------------
1407 # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
1408 # Run ACTION-IF-FALSE otherwise.
1409 # This test uses sys.hexversion instead of the string equivalent (first
1410 # word of sys.version), in order to cope with versions such as 2.2c1.
1411 # This supports Python 2.0 or higher. (2.0 was released on October 16, 2000).
1412 AC_DEFUN([AM_PYTHON_CHECK_VERSION],
1414 # split strings by '.' and convert to numeric. Append some zeros
1415 # because we need at least 4 digits for the hex conversion.
1416 # map returns an iterator in Python 3.0 and a list in 2.x
1417 minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]]
1419 # xrange is not present in Python 3.0 and range returns an iterator
1420 for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
1421 sys.exit(sys.hexversion < minverhex)"
1422 AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
1424 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
1426 # This file is free software; the Free Software Foundation
1427 # gives unlimited permission to copy and/or distribute it,
1428 # with or without modifications, as long as this notice is preserved.
1430 # AM_RUN_LOG(COMMAND)
1431 # -------------------
1432 # Run COMMAND, save the exit status in ac_status, and log it.
1433 # (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
1434 AC_DEFUN([AM_RUN_LOG],
1435 [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
1436 ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
1438 echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
1439 (exit $ac_status); }])