summaryrefslogtreecommitdiff
path: root/Jamfile
blob: 001d630e97aa3d1b3fdaf63f25e94dfb583e379f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#~ Copyright 2003, Rene Rivera.
#~ 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 --help in $(ARGV)
{
    ECHO "
Usage:
    bjam [options] [install|stage]

    * install               Installs to the configured location(s).
    * stage                 Stages the build products only to common stage location.

Options:
    --help                  This message.
    -sTOOLS=<toolsets>      Indicates the tools to build with.

Locations:
    --prefix=PREFIX         Install architecture independent files here.
                            Default; C:\\Boost on Win32
                            Default; /usr/local on Unix. Linux, etc.
    --exec-prefix=EPREFIX   Install architecture dependent files here.
                            Default; PREFIX
    --libdir=DIR            Install libraries here.
                            Default; EPREFIX/lib
    --includedir=DIR        Install source headers here.
                            Default; PREFIX/include
    --builddir=DIR          Build in this location instead of building
                            within the distribution tree. Recomended!
    --stagedir=DIR          When staging only, stage to the location.
                            Default; ./stage

Features:
    --without-<library>     Do not build, stage, or install the specified
                            <library>. By default all libraries attempt to build.
    --with-python-root[=PYTHON_ROOT]
                            Build Boost.Python libraries with the Python
                            devel packages located at PYTHON_ROOT.
                            Default PYTHON_ROOT; C:\\tools\\python on Win32.
                            Default PYTHON_ROOT; /usr/local on Unix, Linux, etc.
                            Default PYTHON_ROOT; /usr on Cygwin.
    --with-pydebug          Build Boost.Python libraries using the
                            Python debug runtime.
" ;
    EXIT "" ;
}

local with-install = ;
local with-stage = ;

# build only, or build+install
if install in $(ARGV)
{
    with-install = install ;
    with-stage = ;
}

# stage only? (no install, only build and stage to a common dir)
if stage in $(ARGV)
{
    with-stage = stage ;
    with-install = ;
}

# possible stage only location
local stage-locate = [ MATCH "^--stagedir=(.*)" : $(ARGV) ] ;
stage-locate ?= stage ;

# architecture independent files
local boost-locate = [ unless $(with-stage) : [ MATCH "^--prefix=(.*)" : $(ARGV) ] : $(stage-locate) ] ;
if $(NT) { boost-locate ?= C:\\Boost ; }
else if $(UNIX) { boost-locate ?= /usr/local ; }

# architecture dependent files
local exec-locate = [ MATCH "^--exec-prefix=(.*)" : $(ARGV) ] ;
exec-locate ?= $(boost-locate) ;

# object code libraries
local lib-locate = [ MATCH "^--libdir=(.*)" : $(ARGV) ] ;
lib-locate ?= $(exec-locate)/lib ;

# where to build
local all-locate = [ MATCH "^--builddir=(.*)" : $(ARGV) ] ;
ALL_LOCATE_TARGET ?= $(all-locate) ;

# source header files
local include-locate = [ MATCH "^--includedir=(.*)" : $(ARGV) ] ;
include-locate ?= $(boost-locate)/include ;

# location of python
local python-root = [ MATCH "^--with-python-root=(.*)" : $(ARGV) ] ;
PYTHON_ROOT ?= $(python-root) ;

# variant for pydebug build
local with-debug-python ;
if --with-pydebug in $(ARGV)
{
    with-debug-python = debug-python ;
}

# libraries to disable building, etc.
local without-libraries = [ MATCH "^--without-(.*)" : $(ARGV) ] ;

#
project-root ;

# bring in the rules for python
import python ;

#
local version-tag = [ MATCH "^([^.]+).([^.]+)" : $(BOOST_VERSION) ] ;
version-tag = $(version-tag:J="_") ;

#
install-subinclude
    [ MATCH ^(.*build[/\\:]$(JAMFILE))$ : [ glob-tree $(BOOST_ROOT)/libs : $(JAMFILE) ] ]
    : <exclude>$(without-libraries) ;

local lib-sources = [ install-sources lib ] ;

if $(lib-sources)
{
    local gNOWARN_INCOMPATIBLE_BUILDS = TRUE ;
    
    local lib-build =
        debug release
        [ cond $(with-debug-python) : debug-python ]
        [ cond $(NT) : <runtime-link>static/dynamic ]
        <threading>single/multi
        ;
    local lib-target =
        [ cond $(with-install) : install : all ]
        [ cond $(with-stage) : stage : all ]
        ;
    local lib-dest-files = [
        stage $(lib-locate:D=)
            :
                $(lib-sources)
            :
                <locate>$(lib-locate:D)
                common-variant-tag
                <target>$(lib-target)
            :
                $(lib-build)
                [ unless $(with-install) $(with-stage) : <suppress>true ]
        ] ;
    if ! $(gIN_LIB_INCLUDE)
    {
        local unversioned-files ;
        if $(with-install) || $(with-stage)
        {
            if $(NT)
            {
                local version-files = [ MATCH "(.*[.]lib)" : $(lib-dest-files) ] ;
                local noversion-files ;
                for local version-file in $(version-files)
                {
                    local noversion-file =
                        [ MATCH "(.*)-[0-9_]+([.]lib)" : $(version-file) ] ;
                    noversion-file = $(noversion-file[1])$(noversion-file[2]) ;
                    MakeLocate $(noversion-file) : [ FDirName [ split-path $(lib-locate) ] ] ;
                    HardLink $(noversion-file) : $(version-file) ;
                    noversion-files += $(noversion-file) ;
                }
                declare-fake-targets $(lib-target) : $(noversion-files) ;
            }
            else if $(UNIX)
            {
                local so-version-files = [ MATCH "(.*[.]so[.0-9]+)" : $(lib-dest-files) ] ;
                so-version-files ?= [ MATCH "(.*[.]so)" : $(lib-dest-files) ] ;
                local version-files = $(so-version-files) [ MATCH "(.*[.]a)" : $(lib-dest-files) ] ;
                local noversion-files ;
                for local version-file in $(version-files)
                {
                    local noversion-file =
                        [ MATCH "(.*)-[0-9_]+([.]so)[.0-9]*" : $(version-file) ]
                        [ MATCH "(.*)-[0-9_]+([.]a)" : $(version-file) ] ;
                    noversion-file = $(noversion-file[1])$(noversion-file[2]) ;
                    MakeLocate $(noversion-file) : [ FDirName [ split-path $(lib-locate) ] ] ;
                    HardLink $(noversion-file) : $(version-file) ;
                    noversion-files += $(noversion-file) ;
                }
                declare-fake-targets $(lib-target) : $(noversion-files) ;
            }
        }
    }
}

stage $(include-locate:D=)/boost-$(version-tag)
    :
        [ glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* ]
        [ glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h ]
    :
        <locate>$(include-locate:D)
        <tree-subdirs>$(BOOST_ROOT)
        [ cond $(with-install) : <target>install : <target>all ]
    :
        [ unless $(with-install) : <suppress>true ]
    ;