summaryrefslogtreecommitdiff
path: root/Jamfile.v2
blob: 1e43193fcfdce7530f3601835a10046446bdb72c (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
#
# This is Boost Jamfile for Boost.Build V2.
# 
# Pass --v2 option to bjam to use this file. For example:
#
#    bjam --v2 link=static
#

# TODO:
#  - handle boost version


import modules ;
import set ;
import stage ;

constant BOOST_VERSION : 1.33.0 ;

project boost
    : requirements <include>.
      # disable auto-linking for all targets here,
      # primarily because it caused troubles with V2
      <define>BOOST_ALL_NO_LIB=1
      # Used to encode variant in target name. See the
      # 'tag' rule below.
      <tag>@$(__name__).tag
    : usage-requirements <include>.
    : build-dir bin.v2  
    ;

# The code here selects the libraries that must be built and builds
# and creates two targets:
# 'stage', which builds only libraries and placed them in one location
# 'install', which places both libraries and headers in system location



rule libraries-to-install ( existing-libraries * )
{
   local argv = [ modules.peek : ARGV ] ;
   local with-parameter = [ MATCH --with-(.*) : $(argv) ] ;
   local without-parameter = [ MATCH --without-(.*) : $(argv) ] ;

   # Do some checks
   if $(with-parameter) && $(without-parameter)
   {
       ECHO "error: both --with-<library> and --without-<library> specified" ;
       EXIT ;
   }
   
   local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ;
   if $(wrong)
   {
       ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ;
       EXIT ;
   }
   local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ;
   if $(wrong)
   {
       ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ;
       EXIT ;
   }

   if $(with-parameter)
   {
       return [ set.intersection $(existing-libraries) : $(with-parameter) ] ;
   }
   else
   {
       return [ set.difference $(existing-libraries) : $(without-parameter) ] ;
   }         
}

# The following is a copy of V1 logic. We don't yet support
# selecting versioned/unversioned install and changing the build
# directory.

ARGV = [ modules.peek : ARGV ] ;

# what kind of layout are we doing?
layout = [ MATCH "^--layout=(.*)" : $(ARGV) ] ;
layout ?= versioned ;
layout-$(layout) = true ;

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

# architecture independent files
local boost-locate ;
if ! $(with-stage)
{
    boost-locate = [ MATCH "^--prefix=(.*)" : $(ARGV) ] ;
}
else
{
    boost-locate = $(stage-locate) ;
}

if [ modules.peek : NT ] { boost-locate ?= C:\\Boost ; }
else if [ modules.peek : 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) ;


# Select the libraries to install.
libraries = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ] ] ;
libraries = [ libraries-to-install $(libraries) ] ;


# This rule is called by Boost.Build to determine the name of 
# target. We use it to encode build variant, compiler name and
# boost version in the target name 
rule tag ( name : type ? : property-set )
{
    if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB
    {        
        if $(layout) = versioned
        {
            name = [ stage.add-variant-and-compiler $(name) 
              : $(type) : $(property-set) ] ;
            
            # On NT, library with version suffix won't be recognized
            # by linkers. On CYGWIN, we get strage duplicate symbol
            # errors when library is generated with version suffix.
            if [ $(property-set).get <os> ] in NT CYGWIN
            {
                return $(name:B)_$(BOOST_VERSION)$(name:S) ;
            }
            else
            {
                return $(name:B)_$(BOOST_VERSION)$(name:S).$(BOOST_VERSION)  ;
            }                                                  
        }
        else
        {
            return [ stage.add-variant-and-compiler $(name) 
              : $(type) : $(property-set) ] ;
        }        
    }                   
}

# Install to system location.

alias install : install-libs install-headers ;

install install-libs : libs/$(libraries)/build   
  : <so-version>1.33.0 
    <location>$(lib-locate) 
  ;

local patterns = *.hpp *.ipp *.h *.inc ;
local dirs = boost boost/* boost/*/* ;
install install-headers : 
  [ glob $(dirs)/$(patterns) ]
  :  
  <location>$(include-locate)
  <install-source-root>.
  ;  

# Install just library.
install stage : libs/$(libraries)/build 
  : <location>$(stage-locate)
  ;

explicit install install-libs install-headers stage ;        

# Just build the libraries, don't install them anywhere.
# This is what happend with just "bjam --v2".
alias build_all : libs/$(libraries)/build ;


# Make project ids of all libraries known.

for local l in $(libraries)
{
    use-project /boost/$(l) : libs/$(l)/build ;
}