# Copyright 2003 John Maddock # Copyright 2010 Artyom Beilis # Copyright 2021 - 2022 Alexander Grund # # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt. import config : requires ; import configure ; import errors ; import feature ; import os ; import path ; import toolset ; path-constant TOP : .. ; project /boost/locale : source-location $(TOP)/src/boost/locale ; # Features feature.feature boost.locale.iconv : on off : optional propagated ; feature.feature boost.locale.icu : on off : optional propagated ; feature.feature boost.locale.posix : on off : optional propagated ; feature.feature boost.locale.std : on off : optional propagated ; feature.feature boost.locale.winapi : on off : optional propagated ; local rule debug-message ( message * ) { if --debug-configuration in [ modules.peek : ARGV ] { ECHO "notice:" "[locale]" $(message) ; } } # Configuration of libraries ## iconv # Iconv support may be builtin (i.e. in libc) exe has_iconv : $(TOP)/build/has_iconv.cpp ; explicit has_iconv ; ICONV_PATH = [ modules.peek : ICONV_PATH ] ; # There may also be an external iconv library lib iconv : : $(ICONV_PATH)/lib shared shared : : $(ICONV_PATH)/include ; explicit iconv ; # Separate pair of obj & exe rules so the CPP file is built with the iconv include path obj has_external_iconv_obj : $(TOP)/build/has_iconv.cpp iconv ; exe has_external_iconv : has_external_iconv_obj iconv ; explicit has_external_iconv ; exe accepts_shared_option : $(TOP)/build/option.cpp : -shared-libstdc++ -shared-libgcc -shared-libstdc++ -shared-libgcc ; # Xlocale exe has_xlocale : $(TOP)/build/has_xlocale.cpp ; explicit has_xlocale ; #end xlocale if [ modules.peek : ICU_LINK ] { errors.user-error : "The ICU_LINK option is no longer supported by the Boost.Locale build - please refer to the documentation for equivalent options" ; } if [ modules.peek : ICU_LINK_LOCALE ] { errors.user-error : "The ICU_LINK_LOCALE option is no longer supported by the Boost.Locale build - please refer to the documentation for equivalent options" ; } # Specify the root path to the installed ICU libraries via # - Environment variable: ICU_PATH # - `b2 .. -s ICU_PATH=x` # - In project-config.jam as `path-constant ICU_PATH : x ; .icu-path = [ modules.peek : ICU_PATH ] ; # -sICU_PATH=x or env variable .icu-path ?= $(ICU_PATH) ; # path-constant if $(.icu-path) { .icu-path = [ path.make $(.icu-path) ] ; # Normalize debug-message ICU path set to "$(.icu-path)" ; } rule path_options ( properties * ) { local result ; if 64 in $(properties) && msvc in $(properties) { debug-message Search 64 bit ICU in "$(.icu-path)/lib64" ; result = $(.icu-path)/bin64 $(.icu-path)/lib64 ; } else { debug-message Search ICU in "$(.icu-path)/lib" ; result = $(.icu-path)/bin $(.icu-path)/lib ; } return $(result) ; } if [ modules.peek : ICU_ICUUC_NAME ] { ICU_ICUUC_NAME = [ modules.peek : ICU_ICUUC_NAME ] ; } if [ modules.peek : ICU_ICUDT_NAME ] { ICU_ICUDT_NAME = [ modules.peek : ICU_ICUDT_NAME ] ; } if [ modules.peek : ICU_ICUIN_NAME ] { ICU_ICUIN_NAME = [ modules.peek : ICU_ICUIN_NAME ] ; } if $(ICU_ICUUC_NAME) { lib icuuc : : $(ICU_ICUUC_NAME) @path_options ; debug-message Using "$(ICU_ICUUC_NAME)" for library "icuuc" ; } else { lib icuuc : : shared @path_options ; lib icuuc : : msvc debug icuucd shared @path_options ; lib icuuc : : intel windows debug icuucd shared @path_options ; lib icuuc : : sicuuc static @path_options ; lib icuuc : : msvc debug sicuucd static @path_options ; lib icuuc : : intel windows debug sicuucd static @path_options ; lib icuuc : : this_is_an_invalid_library_name ; } if $(ICU_ICUDT_NAME) { lib icudt : : $(ICU_ICUDT_NAME) @path_options ; debug-message Using "$(ICU_ICUDT_NAME)" for library "icudt" ; } else { lib icudt : : icudata shared @path_options ; lib icudt : : icudt msvc shared @path_options ; lib icudt : : icudt intel windows shared @path_options ; lib icudt : : sicudata static @path_options ; lib icudt : : sicudt msvc static @path_options ; lib icudt : : sicudt intel windows static @path_options ; lib icudt : : this_is_an_invalid_library_name ; } if $(ICU_ICUIN_NAME) { lib icuin : : $(ICU_ICUIN_NAME) @path_options ; debug-message Using "$(ICU_ICUIN_NAME)" for library "icuin" ; } else { lib icuin : : icui18n shared @path_options ; lib icuin : : msvc debug icuind shared @path_options ; lib icuin : : msvc icuin shared @path_options ; lib icuin : : intel windows debug icuind shared @path_options ; lib icuin : : intel windows icuin shared @path_options ; lib icuin : : sicui18n static @path_options ; lib icuin : : msvc debug sicuind static @path_options ; lib icuin : : msvc sicuin static @path_options ; lib icuin : : intel windows debug sicuind static @path_options ; lib icuin : : intel windows sicuin static @path_options ; lib icuin : : this_is_an_invalid_library_name ; } ICU_OPTS = $(.icu-path)/include shared:icuuc/shared shared:icudt/shared shared:icuin/shared static:icuuc static:icudt static:icuin windows,clang:"advapi32.lib" static:U_STATIC_IMPLEMENTATION=1 ; exe has_icu : $(TOP)/build/has_icu_test.cpp : $(ICU_OPTS) ; explicit has_icu ; # This function is called whenever the 'boost_locale' metatarget # below is generated and figures out what external components we have, # what the user wants, and what sources have to be compiled in the end. rule configure-full ( properties * : flags-only ) { local result ; local flags-result ; local found-iconv ; # The system Iconv on Solaris may have bugs, while the GNU Iconv is fine. # So enable by default only if not on Solaris. if on in $(properties) || ( ! in $(properties:G) && ! solaris in $(properties) ) { # See if iconv is bundled with standard library. if [ configure.builds has_iconv : $(properties) : "iconv (libc)" ] { found-iconv = true ; } else if [ configure.builds has_external_iconv : $(properties) : "iconv (separate)" ] { found-iconv = true ; result += iconv ; } } if $(found-iconv) { flags-result += BOOST_LOCALE_WITH_ICONV=1 ; } local found-icu ; if ! off in $(properties) { if [ configure.builds has_icu : $(properties) : "icu" ] { found-icu = true ; flags-result += BOOST_LOCALE_WITH_ICU=1 $(ICU_OPTS) ; ICU_SOURCES = boundary codecvt collator conversion date_time formatter formatters_cache icu_backend numeric time_zone ; result += icu/$(ICU_SOURCES).cpp /boost/thread//boost_thread ; } } if ! $(found-iconv) && ! $(found-icu) && ! windows in $(properties) && ! cygwin in $(properties) { ECHO "- Boost.Locale needs either iconv or ICU library to be built." ; result += no ; } if ! in $(properties:G) { if sun in $(properties) { properties += off ; } else { properties += on ; } } if off in $(properties) { flags-result += BOOST_LOCALE_NO_STD_BACKEND=1 ; } else { STD_SOURCES = codecvt collate converter numeric std_backend ; result += std/$(STD_SOURCES).cpp ; } if ! in $(properties:G) { if windows in $(properties) || cygwin in $(properties) { properties += on ; } else { properties += off ; } } if windows in $(properties) && gcc in $(properties) && shared in $(properties) && [ configure.builds accepts_shared_option : $(properties) : "g++ -shared-* supported" ] { flags-result += -shared-libstdc++ -shared-libgcc -shared-libstdc++ -shared-libgcc ; } if off in $(properties) { flags-result += BOOST_LOCALE_NO_WINAPI_BACKEND=1 ; } else { WINAPI_SOURCES = collate converter numeric win_backend ; result += win32/$(WINAPI_SOURCES).cpp ; } if ( ! off in $(properties) || ! off in $(properties) ) && ( windows in $(properties) || cygwin in $(properties) ) { result += win32/lcid.cpp ; } if ! in $(properties:G) { if linux in $(properties) || darwin in $(properties) || ( freebsd in $(properties) && [ configure.builds has_xlocale : $(properties) : "xlocale supported" ] ) { properties += on ; } else { properties += off ; } } if off in $(properties) { flags-result += BOOST_LOCALE_NO_POSIX_BACKEND=1 ; } else { POSIX_SOURCES = collate converter numeric codecvt posix_backend ; result += posix/$(POSIX_SOURCES).cpp ; } if on in $(properties) || on in $(properties) || on in $(properties) { result += util/gregorian.cpp ; } if "$(flags-only)" = "flags" { return $(flags-result) ; } else { result += $(flags-result) ; return $(result) ; } } rule configure ( properties * ) { local result = [ configure-full $(properties) : "all" ] ; return $(result) ; } rule configure-flags ( properties * ) { local result ; result = [ configure-full $(properties) : "flags" ] ; return $(result) ; } alias build_flags : : : : @configure-flags ; local cxx_requirements = [ requires cxx11_auto_declarations cxx11_decltype cxx11_defaulted_functions cxx11_defaulted_moves cxx11_hdr_functional cxx11_hdr_type_traits cxx11_noexcept cxx11_nullptr cxx11_override cxx11_range_based_for cxx11_rvalue_references cxx11_scoped_enums cxx11_smart_ptr cxx11_static_assert ] ; boost-lib locale : encoding/codepage.cpp shared/date_time.cpp shared/format.cpp shared/formatting.cpp shared/generator.cpp shared/iconv_codecvt.cpp shared/ids.cpp shared/localization_backend.cpp shared/message.cpp shared/mo_lambda.cpp util/codecvt_converter.cpp util/default_locale.cpp util/encoding.cpp util/info.cpp util/locale_data.cpp : $(cxx_requirements) BOOST_LOCALE_SOURCE # Don't link explicitly, not required BOOST_THREAD_NO_LIB=1 $(TOP)/src multi windows:_CRT_SECURE_NO_WARNINGS windows:_SCL_SECURE_NO_WARNINGS # Meanwhile remove this @configure : : $(cxx_requirements) ;