# Copyright 2003 John Maddock # Copyright 2010 Artyom Beilis # Copyright 2021 - 2024 Alexander Grund # # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt. import-search /boost/config/checks ; import config : requires ; import configure ; import errors ; import os ; import path ; import toolset ; path-constant TOP : .. ; constant boost_dependencies_private : /boost/charconv//boost_charconv /boost/predef//boost_predef /boost/thread//boost_thread ; project : source-location $(TOP)/src ; 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 searched-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 icu_search_paths ( 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) { searched-lib icuuc : : $(ICU_ICUUC_NAME) @icu_search_paths ; debug-message Using "$(ICU_ICUUC_NAME)" for library "icuuc" ; } else { searched-lib icuuc : : icuuc shared @icu_search_paths ; searched-lib icuuc : : msvc debug icuucd shared @icu_search_paths ; searched-lib icuuc : : intel windows debug icuucd shared @icu_search_paths ; searched-lib icuuc : : sicuuc static @icu_search_paths ; searched-lib icuuc : : msvc debug sicuucd static @icu_search_paths ; searched-lib icuuc : : intel windows debug sicuucd static @icu_search_paths ; searched-lib icuuc : : this_is_an_invalid_library_name ; } if $(ICU_ICUDT_NAME) { searched-lib icudt : : $(ICU_ICUDT_NAME) @icu_search_paths ; debug-message Using "$(ICU_ICUDT_NAME)" for library "icudt" ; } else { searched-lib icudt : : icudata shared @icu_search_paths ; searched-lib icudt : : msvc icudt shared @icu_search_paths ; searched-lib icudt : : intel windows icudt shared @icu_search_paths ; searched-lib icudt : : sicudata static @icu_search_paths ; searched-lib icudt : : msvc sicudt static @icu_search_paths ; searched-lib icudt : : intel windows sicudt static @icu_search_paths ; searched-lib icudt : : this_is_an_invalid_library_name ; } if $(ICU_ICUIN_NAME) { searched-lib icuin : : $(ICU_ICUIN_NAME) @icu_search_paths ; debug-message Using "$(ICU_ICUIN_NAME)" for library "icuin" ; } else { searched-lib icuin : : icui18n shared @icu_search_paths ; searched-lib icuin : : msvc debug icuind shared @icu_search_paths ; searched-lib icuin : : msvc icuin shared @icu_search_paths ; searched-lib icuin : : intel windows debug icuind shared @icu_search_paths ; searched-lib icuin : : intel windows icuin shared @icu_search_paths ; searched-lib icuin : : sicui18n static @icu_search_paths ; searched-lib icuin : : msvc debug sicuind static @icu_search_paths ; searched-lib icuin : : msvc sicuin static @icu_search_paths ; searched-lib icuin : : intel windows debug sicuind static @icu_search_paths ; searched-lib icuin : : intel windows sicuin static @icu_search_paths ; searched-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 ; # Separate pair of obj & exe rules so the CPP file is built with the changed include paths obj has_iconv_with_icu_obj : $(TOP)/build/has_iconv.cpp : $(ICU_OPTS) ; exe has_iconv_with_icu : has_external_iconv_with_icu_obj : $(ICU_OPTS) ; explicit has_iconv_with_icu ; obj has_external_iconv_with_icu_obj : $(TOP)/build/has_iconv.cpp iconv : $(ICU_OPTS) ; exe has_external_iconv_with_icu : has_external_iconv_with_icu_obj iconv : $(ICU_OPTS) ; explicit has_external_iconv_with_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 ; if ! in $(properties:G) { # The system Iconv on Solaris may have bugs, while the GNU Iconv is fine. # So disable it by default if on Solaris. if solaris in $(properties) { properties += off ; } } local internal_iconv_target = has_iconv ; local external_iconv_target = has_external_iconv ; 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) ; local ICU_SOURCES = boundary codecvt collator conversion date_time formatter formatters_cache icu_backend numeric ; result += icu/$(ICU_SOURCES).cpp /boost/thread//boost_thread ; # ICU might introduce an own iconv, so check for that. internal_iconv_target = has_iconv_with_icu ; external_iconv_target = has_external_iconv_with_icu ; } } local found-iconv ; if ! off in $(properties) { # See if iconv is bundled with standard library. if [ configure.builds $(internal_iconv_target) : $(properties) : "iconv (libc)" ] { found-iconv = true ; } else if [ configure.builds $(external_iconv_target) : $(properties) : "iconv (separate)" ] { found-iconv = true ; result += iconv ; } } if $(found-iconv) { flags-result += BOOST_LOCALE_WITH_ICONV=1 ; } 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 { local 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 { local 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 { local 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 = [ configure-full $(properties) : "flags" ] ; return $(result) ; } alias build_flags : : : : @configure-flags ; local cxx_requirements = [ requires cxx11_defaulted_moves cxx11_hdr_type_traits cxx11_override ] ; lib boost_locale : sources 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 : requirements $(boost_dependencies_private)/off $(boost_dependencies)/off $(cxx_requirements) shared:BOOST_LOCALE_DYN_LINK=1 BOOST_LOCALE_SOURCE multi windows:_CRT_SECURE_NO_WARNINGS windows:_SCL_SECURE_NO_WARNINGS # Meanwhile remove this @configure : usage-requirements $(boost_dependencies)/off $(cxx_requirements) shared:BOOST_LOCALE_DYN_LINK=1 BOOST_LOCALE_NO_LIB=1 ;