• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# copyright John Maddock 2003, Artyom Beilis 2010
2# Distributed under the Boost Software License, Version 1.0.
3# (See accompanying file LICENSE_1_0.txt or copy at
4# http://www.boost.org/LICENSE_1_0.txt.
5
6
7
8project /boost/locale
9    : source-location ../src
10    ;
11
12import configure ;
13import os ;
14import toolset ;
15import project ;
16import feature ;
17# Features
18
19feature.feature boost.locale.iconv : on off : optional propagated ;
20feature.feature boost.locale.icu : on off :  optional propagated ;
21feature.feature boost.locale.posix : on off : optional propagated ;
22feature.feature boost.locale.std : on off : optional propagated ;
23feature.feature boost.locale.winapi : on off : optional propagated ;
24
25# Configuration of libraries
26
27## iconv
28
29obj has_iconv_libc_obj : ../build/has_iconv.cpp ;
30exe has_iconv : has_iconv_libc_obj ;
31explicit has_iconv ;
32
33ICONV_PATH = [ modules.peek : ICONV_PATH ] ;
34
35lib iconv
36  :
37  : <search>$(ICONV_PATH)/lib <link>shared <runtime-link>shared
38  :
39  : <include>$(ICONV_PATH)/include
40  ;
41
42explicit iconv ;
43
44obj has_iconv_libc_ext : ../build/has_iconv.cpp iconv ;
45exe has_external_iconv : has_iconv_libc_ext iconv ;
46explicit has_external_iconv ;
47
48exe accepts_shared_option   : ../build/option.cpp
49                            :   <cxxflags>-shared-libstdc++
50                                <cxxflags>-shared-libgcc
51                                <linkflags>-shared-libstdc++
52                                <linkflags>-shared-libgcc
53                            ;
54
55# Xlocale
56obj has_xlocale_obj : ../build/has_xlocale.cpp ;
57exe has_xlocale : has_xlocale_obj ;
58explicit has_xlocale ;
59
60#end xlocale
61
62
63ICU_PATH =  [ modules.peek : ICU_PATH ] ;
64ICU_LINK =  [ modules.peek : ICU_LINK ] ;
65
66if $(ICU_LINK)
67{
68    ICU_OPTS = <include>$(ICU_PATH)/include <linkflags>$(ICU_LINK) <dll-path>$(ICU_PATH)/bin <runtime-link>shared ;
69    ICU64_OPTS = <include>$(ICU_PATH)/include <linkflags>$(ICU_LINK) <dll-path>$(ICU_PATH)/bin64 <runtime-link>shared ;
70}
71else
72{
73    searched-lib icuuc : :  <name>icuuc
74                            <search>$(ICU_PATH)/lib
75                            <link>shared
76                            <runtime-link>shared ;
77
78    searched-lib icuuc : :  <toolset>msvc
79                            <variant>debug
80                            <name>icuucd
81                            <search>$(ICU_PATH)/lib
82                            <link>shared
83                            <runtime-link>shared ;
84
85    searched-lib icuuc : :  <name>this_is_an_invalid_library_name ;
86
87    searched-lib icudt : :  <search>$(ICU_PATH)/lib
88                            <name>icudata
89                            <link>shared
90                            <runtime-link>shared ;
91
92    searched-lib icudt : :  <search>$(ICU_PATH)/lib
93                            <name>icudt
94                            <toolset>msvc
95                            <link>shared
96                            <runtime-link>shared ;
97
98    searched-lib icudt : :  <name>this_is_an_invalid_library_name ;
99
100    searched-lib icuin : :  <search>$(ICU_PATH)/lib
101                            <name>icui18n
102                            <link>shared
103                            <runtime-link>shared ;
104
105    searched-lib icuin : :  <toolset>msvc
106                            <variant>debug
107                            <name>icuind
108                            <search>$(ICU_PATH)/lib
109                            <link>shared
110                            <runtime-link>shared ;
111
112    searched-lib icuin : :  <toolset>msvc
113                            <variant>release
114                            <name>icuin
115                            <search>$(ICU_PATH)/lib
116                            <link>shared
117                            <runtime-link>shared ;
118
119    searched-lib icuin : :  <name>this_is_an_invalid_library_name ;
120
121    explicit icuuc icudt icuin ;
122
123    ICU_OPTS =   <include>$(ICU_PATH)/include
124      <library>icuuc/<link>shared/<runtime-link>shared
125      <library>icudt/<link>shared/<runtime-link>shared
126      <library>icuin/<link>shared/<runtime-link>shared
127      <dll-path>$(ICU_PATH)/bin
128        <runtime-link>shared ;
129
130
131
132    searched-lib icuuc_64 : :   <name>icuuc
133                                <search>$(ICU_PATH)/lib64
134                                <link>shared
135                                <runtime-link>shared ;
136
137    searched-lib icuuc_64 : :   <toolset>msvc
138                                <variant>debug
139                                <name>icuucd
140                                <search>$(ICU_PATH)/lib64
141                                <link>shared
142                                <runtime-link>shared ;
143
144    searched-lib icuuc_64 : :   <name>this_is_an_invalid_library_name ;
145
146    searched-lib icudt_64 : :   <search>$(ICU_PATH)/lib64
147                                <name>icudata
148                                <link>shared
149                                <runtime-link>shared ;
150
151    searched-lib icudt_64 : :   <search>$(ICU_PATH)/lib64
152                                <name>icudt
153                                <toolset>msvc
154                                <link>shared
155                                <runtime-link>shared ;
156
157    searched-lib icudt_64 : :   <name>this_is_an_invalid_library_name ;
158
159    searched-lib icuin_64 : :   <search>$(ICU_PATH)/lib64
160                                <name>icui18n
161                                <link>shared
162                                <runtime-link>shared ;
163
164    searched-lib icuin_64 : :   <toolset>msvc
165                                <variant>debug
166                                <name>icuind
167                                <search>$(ICU_PATH)/lib64
168                                <link>shared
169                                <runtime-link>shared ;
170
171    searched-lib icuin_64 : :   <toolset>msvc
172                                <variant>release
173                                <name>icuin
174                                <search>$(ICU_PATH)/lib64
175                                <link>shared
176                                <runtime-link>shared ;
177
178    searched-lib icuin_64 : :   <name>this_is_an_invalid_library_name ;
179
180    explicit icuuc_64 icudt_64 icuin_64 ;
181
182    ICU64_OPTS =   <include>$(ICU_PATH)/include
183      <library>icuuc_64/<link>shared/<runtime-link>shared
184      <library>icudt_64/<link>shared/<runtime-link>shared
185      <library>icuin_64/<link>shared/<runtime-link>shared
186      <dll-path>$(ICU_PATH)/bin64
187        <runtime-link>shared ;
188
189
190}
191
192obj has_icu_obj     : ../build/has_icu_test.cpp : $(ICU_OPTS)   ;
193obj has_icu64_obj   : ../build/has_icu_test.cpp : $(ICU64_OPTS) ;
194
195exe has_icu   : has_icu_obj   : $(ICU_OPTS)   ;
196exe has_icu64 : has_icu64_obj : $(ICU64_OPTS) ;
197
198explicit has_icu has_icu64 ;
199
200
201# This function is called whenever the 'boost_locale' metatarget
202# below is generated and figures what external components we have,
203# what user wants, and what sources have to be compiled in the end.
204rule configure-full ( properties * : flags-only )
205{
206
207    local result ;
208    local flags-result ;
209
210    local found-iconv ;
211
212    if <boost.locale.iconv>on in $(properties)
213      || ! <boost.locale.iconv> in $(properties:G)
214        && ! <target-os>solaris in $(properties)
215    {
216        # See if iconv is bundled with standard library.
217        if [ configure.builds has_iconv : $(properties) : "iconv (libc)" ]
218        {
219            found-iconv = true ;
220        }
221        else
222        {
223            if [ configure.builds has_external_iconv : $(properties) : "iconv (separate)" ]
224            {
225                found-iconv = true ;
226                result += <library>iconv ;
227            }
228        }
229    }
230    if $(found-iconv)
231    {
232        flags-result += <define>BOOST_LOCALE_WITH_ICONV=1 ;
233    }
234
235    local found-icu ;
236
237    if ! <boost.locale.icu>off in $(properties)
238    {
239        if [ configure.builds has_icu : $(properties) : "icu" ]
240        {
241            found-icu = true ;
242            flags-result += <define>BOOST_LOCALE_WITH_ICU=1 $(ICU_OPTS) ;
243        }
244        else if [ configure.builds has_icu64 : $(properties) : "icu (lib64)" ]
245        {
246            found-icu = true ;
247            flags-result += <define>BOOST_LOCALE_WITH_ICU=1 $(ICU64_OPTS) ;
248        }
249
250        if $(found-icu)
251        {
252            ICU_SOURCES =
253                boundary
254                codecvt
255                collator
256                conversion
257                date_time
258                formatter
259                icu_backend
260                numeric
261                time_zone
262                ;
263
264            result += <source>icu/$(ICU_SOURCES).cpp
265                      <library>../../thread/build//boost_thread
266                      ;
267        }
268
269    }
270
271    if ! $(found-iconv) && ! $(found-icu) && ! <target-os>windows in $(properties) && ! <target-os>cygwin in $(properties)
272    {
273        ECHO "- Boost.Locale needs either iconv or ICU library to be built." ;
274        result += <build>no ;
275    }
276
277    if ! <boost.locale.std> in $(properties:G)
278    {
279        if <toolset>sun in $(properties)
280        {
281            properties += <boost.locale.std>off ;
282        }
283        else
284        {
285            properties += <boost.locale.std>on ;
286        }
287    }
288
289    if <boost.locale.std>off in $(properties)
290    {
291        flags-result += <define>BOOST_LOCALE_NO_STD_BACKEND=1 ;
292    }
293    else
294    {
295        STD_SOURCES =
296          codecvt
297          collate
298          converter
299          numeric
300          std_backend
301          ;
302        result += <source>std/$(STD_SOURCES).cpp ;
303    }
304
305    if ! <boost.locale.winapi> in $(properties:G)
306    {
307        if <target-os>windows in $(properties)
308          || <target-os>cygwin in $(properties)
309        {
310            properties += <boost.locale.winapi>on ;
311        }
312        else
313        {
314            properties += <boost.locale.winapi>off ;
315        }
316    }
317    if  <target-os>windows in $(properties)
318        && <toolset>gcc in $(properties)
319        && <link>shared in $(properties)
320        && [ configure.builds accepts_shared_option : $(properties) : "g++ -shared-* supported" ]
321    {
322        flags-result += <cxxflags>-shared-libstdc++
323                        <cxxflags>-shared-libgcc
324                        <linkflags>-shared-libstdc++
325                        <linkflags>-shared-libgcc
326                        ;
327    }
328
329    if <boost.locale.winapi>off in $(properties)
330    {
331        flags-result += <define>BOOST_LOCALE_NO_WINAPI_BACKEND=1 ;
332    }
333    else
334    {
335        WINAPI_SOURCES =
336            collate
337            converter
338            numeric
339            win_backend
340          ;
341        result += <source>win32/$(WINAPI_SOURCES).cpp ;
342    }
343
344    if ( ! <boost.locale.winapi>off in $(properties) || ! <boost.locale.std>off in $(properties) )
345       && ( <target-os>windows in $(properties) || <target-os>cygwin in $(properties) )
346    {
347        result += <source>win32/lcid.cpp ;
348    }
349
350    if ! <boost.locale.posix> in $(properties:G)
351    {
352        if <target-os>linux in $(properties)
353            || <target-os>darwin in $(properties)
354            || ( <target-os>freebsd in $(properties) && [ configure.builds has_xlocale : $(properties) : "xlocale supported" ] )
355        {
356            properties += <boost.locale.posix>on ;
357        }
358        else
359        {
360            properties += <boost.locale.posix>off ;
361        }
362    }
363
364    if <boost.locale.posix>off in $(properties)
365    {
366        flags-result += <define>BOOST_LOCALE_NO_POSIX_BACKEND=1 ;
367    }
368    else
369    {
370        POSIX_SOURCES =
371          collate
372          converter
373          numeric
374          codecvt
375          posix_backend
376          ;
377        result += <source>posix/$(POSIX_SOURCES).cpp ;
378    }
379
380    if <boost.locale.posix>on in $(properties) || <boost.locale.std>on in $(properties) || <boost.locale.winapi>on in $(properties)
381    {
382        result += <source>util/gregorian.cpp ;
383    }
384
385    result += <library>../../system/build//boost_system ;
386
387
388    if "$(flags-only)" = "flags"
389    {
390        return $(flags-result) ;
391    }
392    else {
393        result += $(flags-result) ;
394        return $(result) ;
395    }
396}
397
398rule configure ( properties * )
399{
400    local result = [ configure-full $(properties) : "all" ] ;
401    return $(result) ;
402
403}
404
405rule configure-flags ( properties * )
406{
407    local result ;
408    result = [ configure-full $(properties) : "flags" ] ;
409    return $(result) ;
410
411}
412
413
414alias build_options : : : : <conditional>@configure ;
415alias build_flags : : : : <conditional>@configure-flags ;
416
417lib boost_locale
418    :
419        encoding/codepage.cpp
420        shared/date_time.cpp
421        shared/format.cpp
422        shared/formatting.cpp
423        shared/generator.cpp
424        shared/ids.cpp
425        shared/localization_backend.cpp
426        shared/message.cpp
427        shared/mo_lambda.cpp
428        util/codecvt_converter.cpp
429        util/default_locale.cpp
430        util/info.cpp
431        util/locale_data.cpp
432    :
433      # Don't link explicitly, not required
434      <define>BOOST_THREAD_NO_LIB=1
435      <link>shared:<define>BOOST_LOCALE_DYN_LINK=1
436      <threading>multi
437      # Meanwhile remove this
438      <conditional>@configure
439    ;
440
441boost-install boost_locale ;
442
443
444# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
445
446