#
# Copyright John Maddock 2008.
# 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)
#
# If you need to alter build preferences then set them in
# the template defined in options_v2.jam.
#

import feature ;
import testing ;
import notfile ;

project
    : requirements
      <toolset>gcc:<cxxflags>-Wno-deprecated-declarations
      <library>/boost/core//boost_core
;


import modules ;
import-search /boost/config/checks ;
import config : requires ;

local is_unix = [ modules.peek : UNIX ] ;

lib atomic ;
lib pthread ;
lib rt ;

exe has_atomic_lib : config_info.cpp atomic ;
explicit has_atomic_lib ;
exe has_pthread_lib : config_info.cpp pthread ;
explicit has_pthread_lib ;
exe has_rt_lib : config_info.cpp rt ;
explicit has_rt_lib ;
obj check_memory : check_memory.cpp ;
explicit check_memory ;
obj has_clr : has_clr.cpp ;
explicit has_clr ;

test-suite config
  :
    [ compile config_test_c.c ]
    [ run config_test.cpp
          : #args
          : #input-files
          : #requirements
          <threading>multi
          [ check-target-builds has_atomic_lib : <source>atomic ]
          [ check-target-builds has_pthread_lib : <source>pthread ]
          [ check-target-builds has_rt_lib : <source>rt ]
          : config_test_threaded
    ]
    [ run config_test.cpp
          : #args
          : #input-files
          : #requirements
          <threading>single <toolset>msvc:<runtime-link>static <toolset>msvc:<link>static
          [ check-target-builds has_atomic_lib : <source>atomic ]
          [ check-target-builds has_pthread_lib : <source>pthread ]
          [ check-target-builds has_rt_lib : <source>rt ]
          [ check-target-builds has_clr : : <build>no ]
    ]
    [ run config_test.cpp
          : #args
          : #input-files
          : #requirements
          <rtti>off
          <toolset>gcc-4.4.7,<cxxstd>0x:<build>no # <memory> does not compile with -fno-rtti
          <toolset>embarcadero:<build>no          # <memory> does not compile with -fno-rtti
          [ check-target-builds has_atomic_lib : <source>atomic ]
          [ check-target-builds has_pthread_lib : <source>pthread ]
          [ check-target-builds has_rt_lib : <source>rt ]
          [ check-target-builds check_memory : : <build>no ]
          : config_test_no_rtti
    ]
    [ run config_test.cpp
          : #args
          : #input-files
          : #requirements
          <exception-handling>off
          <target-os>vxworks:<build>no      # vx requires complete library rebuild to turn off exceptions
          [ check-target-builds has_atomic_lib : <source>atomic ]
          [ check-target-builds has_pthread_lib : <source>pthread ]
          [ check-target-builds has_rt_lib : <source>rt ]
          : config_test_no_except
    ]
     [ run config_info.cpp : : : <test-info>always_show_run_output <threading>single <toolset>msvc:<runtime-link>static <toolset>msvc:<link>static <toolset>msvc:<warnings-as-errors>on <toolset>gcc:<warnings-as-errors>on <toolset>clang:<warnings-as-errors>on [ check-target-builds has_clr : : <build>no ] ]
     [ run config_info.cpp : : : <test-info>always_show_run_output <threading>multi <toolset>msvc:<warnings-as-errors>on <toolset>gcc:<warnings-as-errors>on <toolset>clang:<warnings-as-errors>on : config_info_threaded ]
     [ run config_info.cpp : : : <test-info>always_show_run_output <rtti>off <toolset>msvc:<warnings-as-errors>on <toolset>gcc:<warnings-as-errors>on <toolset>clang:<warnings-as-errors>on [ check-target-builds has_clr : : <build>no ] : config_info_no_rtti ]
     [ run config_info.cpp : : : <test-info>always_show_run_output <exception-handling>off
          <target-os>vxworks:<build>no
          : config_info_no_except ]
     [ run math_info.cpp : : : <library>/boost/type_traits//boost_type_traits <test-info>always_show_run_output <toolset>borland:<runtime-link>static <toolset>borland:<link>static ]
     [ run abi/abi_test.cpp abi/main.cpp ]
     [ run limits_test.cpp : : : <library>/boost/detail//boost_detail ]
     [ run link/main.cpp link//link_test
          : #args
          : #input-files
          : #requirements
          <runtime-link>shared
          <threading>single
          <define>BOOST_DYN_LINK=1
          <define>BOOST_CONFIG_NO_LIB=1
          <target-os>vxworks:<link>shared
          :
          config_link_test
    ]
    [ compile-fail threads/test_thread_fail1.cpp ]
    [ compile-fail threads/test_thread_fail2.cpp ]
    [ compile boost_fallthrough_test.cpp : [ check-target-builds has_clang_implicit_fallthrough "Clang implicit fallthrough" : <toolset>clang:<cxxflags>"-std=c++11 -Wimplicit-fallthrough" <warnings-as-errors>on <warnings>all ] ]
    [ compile helper_macro_test.cpp ]
    [ run cstdint_test.cpp : : : <warnings>all <toolset>gcc:<cxxflags>"-Wno-long-long -Wextra" <toolset>darwin:<cxxflags>-Wno-long-long ]
    [ run cstdint_test2.cpp : : : <warnings>all <toolset>gcc:<cxxflags>"-Wno-long-long -Wextra" <toolset>darwin:<cxxflags>-Wno-long-long ]
    [ compile cstdint_include_test.cpp : <warnings>all <toolset>gcc:<cxxflags>-Wextra ]
    [ run config_build_check.cpp : : : [ requires int128 cxx11_constexpr cxx11_user_defined_literals cpp_lib_complex_udls cpp_range_based_for_17 ] ]
    [ run helper_macros_test.cpp ]
    [ compile pragma_message_test.cpp ]
    [ compile header_deprecated_test.cpp ]
    [ compile symbol_deprecated_test.cpp ]
    [ compile boost_override_test.cpp ]

    [ run static_assert_test.cpp ]
    [ compile-fail static_assert_test_fail_1.cpp ]
    [ compile-fail static_assert_test_fail_2.cpp ]
    [ compile-fail static_assert_test_fail_3.cpp ]
    [ compile-fail static_assert_test_fail_4.cpp ]
    [ compile-fail static_assert_test_fail_5.cpp ]
    [ compile-fail static_assert_test_fail_6.cpp ]
    [ compile-fail static_assert_test_fail_7.cpp ]
    [ compile-fail static_assert_test_fail_8.cpp ]
    [ compile-fail static_assert_test_fail_9.cpp ]
    [ compile-fail static_assert_test_fail_10.cpp ]

    [ build-project ../example ]
  ;

obj has_clang_implicit_fallthrough : cmd_line_check.cpp :
    <toolset>clang:<cxxflags>"-std=c++11 -Wimplicit-fallthrough" <warnings-as-errors>on <warnings>all ;

explicit has_clang_implicit_fallthrough ;

exe config_info_printer : config_info.cpp ;
explicit config_info_printer ;
exe math_info_printer : math_info.cpp : <library>/boost/type_traits//boost_type_traits ;
explicit math_info_printer ;

actions print-run
{
    echo With Standard Version $(STANDARD:E=default)
    echo =====================================================================
    $(>)
}

rule print-run ( target : sources * : properties * )
{
    STANDARD on $(target) = [ feature.get-values <cxxstd> : $(properties) ] ;
}

notfile print_config_info : @print-run : config_info_printer ;
explicit print_config_info ;
notfile print_math_info : @print-run : math_info_printer ;
explicit print_math_info ;

# Backwards compatibility:
exe config_info_travis : config_info.cpp ;
install config_info_travis_install : config_info_travis : <location>. ;
explicit config_info_travis_install ;
