From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/config/tools/Jamfile.v2 | 15 + src/boost/libs/config/tools/configure.in | 463 +++++++++++++++++++++++++++ src/boost/libs/config/tools/generate.cpp | 522 +++++++++++++++++++++++++++++++ 3 files changed, 1000 insertions(+) create mode 100644 src/boost/libs/config/tools/Jamfile.v2 create mode 100644 src/boost/libs/config/tools/configure.in create mode 100644 src/boost/libs/config/tools/generate.cpp (limited to 'src/boost/libs/config/tools') diff --git a/src/boost/libs/config/tools/Jamfile.v2 b/src/boost/libs/config/tools/Jamfile.v2 new file mode 100644 index 00000000..de66b8d2 --- /dev/null +++ b/src/boost/libs/config/tools/Jamfile.v2 @@ -0,0 +1,15 @@ +# Copyright John Maddock 2005. +# Use, modification and distribution are subject to the +# Boost Software License, Version 1.0. (See accompanying file +# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +run generate.cpp + ../../regex/build//boost_regex + ../../filesystem/build//boost_filesystem ../../system/build//boost_system + : ../../.. +; + + + + + diff --git a/src/boost/libs/config/tools/configure.in b/src/boost/libs/config/tools/configure.in new file mode 100644 index 00000000..3e1425ce --- /dev/null +++ b/src/boost/libs/config/tools/configure.in @@ -0,0 +1,463 @@ +# copyright John Maddock 2003 +# Use, modification and distribution are subject to the +# Boost Software License, Version 1.0. (See accompanying file +# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +# +# the following variables contain our macro definitions: +# +required_defs="" +required_undefs="" + +dnl Process this file with autoconf to produce a configure script. +dnl disable cache processing, it has no effect here: +define([AC_CACHE_LOAD], )dnl +define([AC_CACHE_SAVE], )dnl +AC_INIT(./tools/configure.in) + + +AC_ARG_ENABLE(test, --enable-test tests current settings rather than defining new ones) + +if test "foo"$enable_test = "foo"; then + enable_test="no" +fi + +cat << EOF +*** $0: boost configuration utility *** + +Please stand by while exploring compiler capabilities... +Be patient - this could take some time... + +Note that this test script only gives an approximate +configuration - you will need to test the results carefully +using the boost regression test suite before using the results. +EOF + +if test $enable_test = 'yes'; then + +cat << EOF + +This script reports only the difference between the detected +configuration, and the existing boost configuration. Its +primary aim is to quickly report how well boost is configured +for one compiler. + +*** + +EOF + +else + +cat << EOF + +*** + +EOF +fi + +AC_ARG_ENABLE(extension,[--enable-extension=], +[ +case "$enableval" in + no) AC_MSG_RESULT(Info :.cpp used as extension for tests) + ac_ext=cpp + ;; + *) AC_MSG_RESULT(Argument : .$enableval used as extension) + ac_ext=$enableval +esac +], +[AC_MSG_RESULT(Info : .cpp used as extension for tests) + ac_ext=cpp +] +) + +dnl figure out which version of sed to use, on some platforms +dnl the version in the path is not Unix conforming (MacOS X ? ) + +if test -f /bin/sed ; then + SED=/bin/sed +else + if test -f /usr/bin/sed ; then + SED=/usr/bin/sed + else + SED=sed + fi +fi + +dnl Set the boost main directory. +AC_MSG_CHECKING(for boost main tree) +boost_base= +AC_ARG_WITH(boost, + AC_HELP_STRING([--with-boost=DIR],[path to the boost main tree]), + [ + #echo "--with boost is set" + if test "x$withval" != "x"; then + if test "x$withval" != no; then + boost_base=`echo "$withval" | $SED 's,//*,/,g' | $SED 's,/$,,'` + #echo boost_base=$boost_base + if test -f "$boost_base/boost/config.hpp"; then + if test -f "$boost_base/libs/config/configure"; then :; else + boost_base= + #echo "$boost_base/libs/config/configure" not found + fi + else + #echo "$boost_base/boost/config.hpp" not found + boost_base= + fi + fi + fi + ] +) +if test "x$boost_base" = "x"; then + #echo '$0 = ' $0 + boost_base=`expr "x$0" : 'x\(.*\)/@<:@/@:>@*' \| '.'` + boost_base="$boost_base/../.." + #echo boost_base=$boost_base + if test -f "$boost_base/boost/config.hpp"; then + if test -f "$boost_base/libs/config/configure"; then :; else + boost_base= + fi + else + boost_base= + fi +fi +if test "x$boost_base" != "x"; then + AC_MSG_RESULT([$boost_base]) +else + AC_MSG_RESULT([not found]) + AC_MSG_ERROR([The boost main tree was not found. + Specify its location by the --with-boost option.]) +fi + + + +# Save that, as it is being redefined several times +use_ac_ext=$ac_ext + +AC_PROG_CXX +ac_ext=$use_ac_ext + +AC_LANG_CPLUSPLUS + +OLD_CXXFLAGS="$CXXFLAGS" + + +if test $enable_test = 'yes'; then + CXXFLAGS="-I$boost_base -I$boost_base/libs/config/test $CXXFLAGS" +else + CXXFLAGS="-I$boost_base -I$boost_base/libs/config/test $CXXFLAGS -DBOOST_NO_CONFIG" +fi + +# add the -AA conformance option to CXXFLAGS for HP aCC only +if test $CXX = 'aCC'; then + CXXFLAGS="-AA $CXXFLAGS" +fi + +dnl check for some standard libraries +dnl without these some of the tests may fail: + +AC_CHECK_LIB(pthread, pthread_exit) +AC_CHECK_LIB(m, cos) +AC_CHECK_LIB(rt, clock) + +# +# enumerate test files and test each one: +# +for file in $boost_base/libs/config/test/boost_no*.ipp; do + + basename=`echo $file | $SED 's/.*boost_\(.*\)\.ipp/\1/'` + macroname=`cat $file | grep '^//[[ ]]*MACRO:' | $SED 's/.*MACRO:[[ ]]*\([[_A-Z0-9]]*\).*/\1/'` + title=`cat $file | grep '^//[[ ]]*TITLE:' | $SED 's/.*TITLE:[[ ]]*\([[^ ]].*\)/\1/'` + namespace=`echo $macroname | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + +#echo file = $file +#echo basename = $basename +#echo macroname = $macroname +#echo title = $title +#echo namespace = $namespace + + ac_ext=$use_ac_ext + if test $enable_test = 'yes'; then + AC_MSG_CHECKING($title (pass expected) ) + else + AC_MSG_CHECKING($title ) + fi + AC_TRY_RUN( + [ +#include +#include "test.hpp" + +#if !defined($macroname) || defined(BOOST_NO_CONFIG) +#include "boost_$basename.ipp" +#else +namespace ${namespace} = empty_boost; +#endif + +int main(){ return ${namespace}::test(); } ] + , + [AC_MSG_RESULT(OK)] + , + [AC_MSG_RESULT(Failed) + required_defs="$macroname $required_defs"] + ) + + if test $enable_test = 'yes'; then + + ac_ext=$use_ac_ext + AC_MSG_CHECKING($title (fail expected) ) + AC_TRY_RUN( + [ +#include +#include "test.hpp" + +#ifdef $macroname +#include "boost_$basename.ipp" +#else +#error "this file should not compile" +#endif + +int main() { return ${namespace}::test(); }] + , + [AC_MSG_RESULT(failed) + required_undefs="$macroname $required_undefs"] + , + [AC_MSG_RESULT(OK)] + ) + + fi + +done + +# +# enumerate optional test files and test each one: +# +for file in $boost_base/libs/config/test/boost_has*.ipp; do + + basename=`echo $file | $SED 's/.*boost_\(.*\)\.ipp/\1/'` + macroname=`cat $file | grep '^//[[ ]]*MACRO:' | $SED 's/.*MACRO:[[ ]]*\([[_A-Z0-9]]*\).*/\1/'` + title=`cat $file | grep '^//[[ ]]*TITLE:' | $SED 's/.*TITLE:[[ ]]*\([[^ ]].*\)/\1/'` + namespace=`echo $macroname | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + +# echo $file +# echo $basename +# echo $macroname +# echo $title + + ac_ext=$use_ac_ext + if test $enable_test = 'yes'; then + AC_MSG_CHECKING($title (pass expected) ) + AC_TRY_RUN( + [ +#include +#include "test.hpp" + +#ifdef $macroname +#include "boost_$basename.ipp" +#else +namespace ${namespace} = empty_boost; +#endif + +int main(){ return ${namespace}::test(); }] + , + [AC_MSG_RESULT(OK)] + , + [AC_MSG_RESULT(Failed) + required_undefs="$macroname $required_undefs"] + ) + + AC_MSG_CHECKING($title (fail expected) ) + AC_TRY_RUN( + [ +#include +#include "test.hpp" + +#ifndef $macroname +#include "boost_$basename.ipp" +#else +#error "this file should not compile" +#endif + +int main(){ return ${namespace}::test(); }] + , + [ + AC_MSG_RESULT(failed) + required_defs="$macroname $required_defs" + ] + , + [ + AC_MSG_RESULT(OK) + ] + ) + + else + + ac_ext=$use_ac_ext + AC_MSG_CHECKING($title) + AC_TRY_RUN( + [ +#include +#include "test.hpp" + +#include "boost_$basename.ipp" + +int main(){ return ${namespace}::test(); }] + , + [ + AC_MSG_RESULT(Yes) + required_defs="$macroname $required_defs" + ] + , + [ + AC_MSG_RESULT(no) + ] + ) + + fi + +done + + +#echo $required_defs +#echo $required_undefs + +if test $enable_test = 'yes'; then + +if test "$required_defs" = ""; then +echo no boost macros need to be defined +echo no boost macros need to be defined >&5 +else +echo the following macros need to be defined +echo $required_defs +echo the following macros need to be defined >&5 +echo $required_defs >&5 +fi +if test "$required_undefs" = ""; then +echo no boost macros need to be undefined +echo no boost macros need to be undefined >&5 +else +echo "the following macros need to be undef'ed" +echo $required_undefs +echo "the following macros need to be undef'ed" >&5 +echo $required_undefs >&5 +fi + +else + +date_string=`date` + +echo boost_base=$boost_base + +cat > user.hpp << EOF +// (C) Copyright Boost.org 2001. +// Do not check in modified versions of this file, +// This file may be customised by the end user, but not by boost. + +// +// Use this file to define a site and compiler specific +// configuration policy, this version was auto-generated by +// configure on ${date_string} +// With the following options: +// CXX = ${CXX} +// CXXFLAGS = ${CXXFLAGS} +// LDFLAGS = ${LDFLAGS} +// LIBS = ${LIBS} +// + +// define this to disable all config options, +// excluding the user config. Use if your +// setup is fully ISO complient, and has no +// useful extentions, or for autoconf generated +// setups: +#ifndef BOOST_NO_CONFIG +# define BOOST_NO_CONFIG +#endif + + +// define if you want to disable threading support, even +// when available: +// #define BOOST_DISABLE_THREADS + +// define if you want the regex library to use the C locale +// even on Win32: +// #define BOOST_REGEX_USE_C_LOCALE + +// define this is you want the regex library to use the C++ +// locale: +// #define BOOST_REGEX_USE_CPP_LOCALE + + +// +// options added by configure: +// +EOF + +for name in $required_defs; do +echo '#define '"$name" >> user.hpp +done + +cat_conts=`cat user.hpp` + +# +# post configuration step: +# +AC_MSG_CHECKING(original configuration ) +rm -f conftest$ac_exeext +$CXX -I$boost_base $OLD_CXXFLAGS -DBOOST_NO_USER_CONFIG -o conftest$ac_exeext $LDFLAGS $boost_base/libs/config/test/config_info.cpp $LIBS >&5 2>&1 +./conftest >&5 2>&1 +AC_MSG_RESULT(done) +AC_MSG_CHECKING(new configuration ) +rm -f conftest$ac_exeext +$CXX -I$boost_base -I$boost_base/libs/config $OLD_CXXFLAGS -DBOOST_USER_CONFIG='"user.hpp"' -o conftest$ac_exeext $LDFLAGS $boost_base/libs/config/test/config_info.cpp $LIBS >&5 2>&1 +./conftest >&5 2>&1 +AC_MSG_RESULT(done) + +AC_OUTPUT( +[], +[ +cat > user.hpp << EEEOF +${cat_conts} +EEEOF +cat << EEEOF + +Adjustments to boost configuration have been written to +user.hpp. Copy this to boost/config/user.hpp to use "as is", +or define BOOST_SITE_CONFIG to point to its location. + +TREAT THIS FILE WITH CARE. +Autoconf generated options are not infallible! + +EEEOF +], +[ +cat_conts="$cat_conts" +] +) + +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/boost/libs/config/tools/generate.cpp b/src/boost/libs/config/tools/generate.cpp new file mode 100644 index 00000000..b1b3c496 --- /dev/null +++ b/src/boost/libs/config/tools/generate.cpp @@ -0,0 +1,522 @@ +// (C) Copyright John Maddock 2004. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// +// This progam scans for *.ipp files in the libs/config/test +// directory and then generates the *.cpp test files from them +// along with config_test.cpp and a Jamfile. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace fs = boost::filesystem; + +fs::path config_path; + +std::string copyright( +"// Copyright John Maddock 2002-4.\n" +"// Use, modification and distribution are subject to the \n" +"// Boost Software License, Version 1.0. (See accompanying file \n" +"// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" +"\n" +"// See http://www.boost.org/libs/config for the most recent version." +"//\n// Revision $Id$\n//\n"); + +std::stringstream config_test1; +std::stringstream config_test1a; +std::stringstream config_test2; +std::stringstream jamfile; +std::stringstream jamfile_v2; +std::stringstream build_config_test; +std::stringstream build_config_jamfile; +std::set macro_list; +std::set feature_list; + +void write_config_info() +{ + // load the file into memory so we can scan it: + fs::ifstream ifs(config_path / "config_info.cpp"); + std::string file_text; + std::copy(std::istreambuf_iterator(ifs), std::istreambuf_iterator(), std::back_inserter(file_text)); + ifs.close(); + // create macro list: + std::stringstream ss; + for(std::set::const_iterator i(macro_list.begin()), j(macro_list.end()); + i != j; + ++i) + { + ss << " PRINT_MACRO(" << *i << ");\n"; + } + std::string macros = ss.str(); + // scan for Boost macro block: + boost::regex re("BEGIN\\s+GENERATED\\s+BLOCK\\s+DO\\s+NOT\\s+EDIT\\s+THIS[^\\n]+\\n(.*?)\\n\\s+//\\s*END\\s+GENERATED\\s+BLOCK"); + boost::smatch what; + if(boost::regex_search(file_text, what, re)) + { + std::string new_text; + new_text.append(what.prefix().first, what[1].first); + new_text.append(macros); + new_text.append(what[1].second, what.suffix().second); + fs::ofstream ofs(config_path / "config_info.cpp"); + ofs << new_text; + } +} + +void write_config_test() +{ + fs::ofstream ofs(config_path / "config_test.cpp"); + time_t t = std::time(0); + ofs << "// This file was automatically generated on " << std::ctime(&t); + ofs << "// by libs/config/tools/generate.cpp\n" << copyright << std::endl; + ofs << "// Test file for config setup\n" + "// This file should compile, if it does not then\n" + "// one or more macros need to be defined.\n" + "// see boost_*.ipp for more details\n\n" + "// Do not edit this file, it was generated automatically by\n\n" + "#include \n#include \n#include \"test.hpp\"\n\n" + "int error_count = 0;\n\n"; + ofs << config_test1.str() << std::endl; + ofs << config_test1a.str() << std::endl; + ofs << "int main( int, char *[] )\n{\n" << config_test2.str() << " return error_count;\n}\n\n"; +} + +void write_jamfile_v2() +{ + fs::ofstream ofs(config_path / "all" / "Jamfile.v2"); + time_t t = std::time(0); + ofs << "#\n# Regression test Jamfile for boost configuration setup.\n# *** DO NOT EDIT THIS FILE BY HAND ***\n" + "# This file was automatically generated on " << std::ctime(&t); + ofs << "# by libs/config/tools/generate.cpp\n" + "# Copyright John Maddock.\n" + "# Use, modification and distribution are subject to the \n" + "# Boost Software License, Version 1.0. (See accompanying file \n" + "# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" + "#\n# If you need to alter build preferences then set them in\n" + "# the template defined in options_v2.jam.\n#\n" + "path-constant DOT : . ;\n" + "include $(DOT)/options_v2.jam ;\n\n" + "run ../config_info.cpp : : : single msvc:static msvc:static ;\n" + "run ../config_info.cpp : : : multi : config_info_threaded ;\n" + "run ../math_info.cpp : : : borland:static borland:static ;\n" + "run ../config_test.cpp : : : single msvc:static msvc:static ;\n" + "run ../config_test.cpp : : : multi : config_test_threaded ;\n" + "run ../limits_test.cpp ../../../test/build//boost_test_exec_monitor ;\n" + "run ../abi/abi_test.cpp ../abi/main.cpp ;\n\n"; + ofs << jamfile_v2.str() << std::endl; + +} + +void write_test_file(const fs::path& file, + const std::string& macro_name, + const std::string& namespace_name, + const std::string& header_file, + bool positive_test, + bool expect_success) +{ + if(!fs::exists(file)) + { + std::cout << "Writing test file " << file.string() << std::endl; + + fs::ofstream ofs(file); + std::time_t t = std::time(0); + ofs << "// This file was automatically generated on " << std::ctime(&t); + ofs << "// by libs/config/tools/generate.cpp\n" << copyright << std::endl; + ofs << "\n// Test file for macro " << macro_name << std::endl; + + if(expect_success) + { + ofs << "// This file should compile, if it does not then\n" + "// " << macro_name << " should "; + if(positive_test) + ofs << "not "; + ofs << "be defined.\n"; + } + else + { + ofs << "// This file should not compile, if it does then\n" + "// " << macro_name << " should "; + if(!positive_test) + ofs << "not "; + ofs << "be defined.\n"; + } + ofs << "// See file " << header_file << " for details\n\n"; + + ofs << "// Must not have BOOST_ASSERT_CONFIG set; it defeats\n" + "// the objective of this file:\n" + "#ifdef BOOST_ASSERT_CONFIG\n" + "# undef BOOST_ASSERT_CONFIG\n" + "#endif\n\n"; + + static const boost::regex tr1_exp("BOOST_HAS_TR1.*"); + + ofs << "#include \n"; + + ofs << "#include \"test.hpp\"\n\n" + "#if"; + if(positive_test != expect_success) + ofs << "n"; + ofs << "def " << macro_name << + "\n#include \"" << header_file << + "\"\n#else\n"; + if(expect_success) + ofs << "namespace " << namespace_name << " = empty_boost;\n"; + else + ofs << "#error \"this file should not compile\"\n"; + ofs << "#endif\n\n"; + + ofs << "int main( int, char *[] )\n{\n return " << namespace_name << "::test();\n}\n\n"; + } + else + { + std::cout << "Skipping existing test file " << file.string() << std::endl; + } +} + +void write_build_tests() +{ + fs::ofstream ofs(config_path / ".." / "checks" / "test_case.cpp"); + time_t t = std::time(0); + ofs << "// This file was automatically generated on " << std::ctime(&t); + ofs << "// by libs/config/tools/generate.cpp\n" << copyright << std::endl; + ofs << "#include \n\n"; + ofs << build_config_test.str() << std::endl; + ofs << "int main( int, char *[] )\n{\n" << " return 0;\n}\n\n"; +} + +void write_build_check_jamfile() +{ + fs::ofstream ofs(config_path / ".." / "checks" / "Jamfile.v2"); + time_t t = std::time(0); + ofs << "#\n# *** DO NOT EDIT THIS FILE BY HAND ***\n" + "# This file was automatically generated on " << std::ctime(&t); + ofs << "# by libs/config/tools/generate.cpp\n" + "# Copyright John Maddock.\n" + "# Use, modification and distribution are subject to the \n" + "# Boost Software License, Version 1.0. (See accompanying file \n" + "# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n\n" + "import modules ;\nimport path ; \n\n" + "\n" + ; + ofs << build_config_jamfile.str() << std::endl; +} + +void process_ipp_file(const fs::path& file, bool positive_test) +{ + std::cout << "Info: Scanning file: " << file.string() << std::endl; + + // our variables: + std::string file_text; + std::string macro_name; + std::string namespace_name; + fs::path positive_file; + fs::path negative_file; + + // load the file into memory so we can scan it: + fs::ifstream ifs(file); + std::copy(std::istreambuf_iterator(ifs), std::istreambuf_iterator(), std::back_inserter(file_text)); + ifs.close(); + // scan for the macro name: + boost::regex macro_regex("//\\s*MACRO\\s*:\\s*(\\w+)"); + boost::smatch macro_match; + if(boost::regex_search(file_text, macro_match, macro_regex)) + { + macro_name = macro_match[1]; + macro_list.insert(macro_name); + namespace_name = boost::regex_replace(file_text, macro_regex, "\\L$1", boost::format_first_only | boost::format_no_copy); + } + if(macro_name.empty()) + { + std::cout << "Error: no macro definition found in " << file.string(); + } + else + { + std::cout << "Info: Macroname: " << macro_name << std::endl; + } + + // get the output filesnames: + boost::regex file_regex("boost_([^.]+)\\.ipp"); + positive_file = file.branch_path() / boost::regex_replace(file.leaf().string(), file_regex, "$1_pass.cpp"); + negative_file = file.branch_path() / boost::regex_replace(file.leaf().string(), file_regex, "$1_fail.cpp"); + write_test_file(positive_file, macro_name, namespace_name, file.leaf().string(), positive_test, true); + write_test_file(negative_file, macro_name, namespace_name, file.leaf().string(), positive_test, false); + + // always create config_test data, + // positive and negative tests go to separate streams, because for some + // reason some compilers choke unless we put them in a particular order... + std::ostream* pout = positive_test ? &config_test1a : &config_test1; + *pout << "#if"; + if(!positive_test) + *pout << "n"; + *pout << "def " << macro_name + << "\n#include \"" << file.leaf().string() << "\"\n#else\nnamespace " + << namespace_name << " = empty_boost;\n#endif\n"; + + config_test2 << " if(0 != " << namespace_name << "::test())\n" + " {\n" + " std::cerr << \"Failed test for " << macro_name << " at: \" << __FILE__ << \":\" << __LINE__ << std::endl;\n" + " ++error_count;\n" + " }\n"; + + // always generate the jamfile data: + jamfile << "test-suite \"" << macro_name << "\" : \n" + "[ run " << positive_file.leaf().string() << "