| 1 |
# Hamigaki Library Root Jamfile |
| 2 |
# |
| 3 |
# Copyright Takeshi Mouri 2007. |
| 4 |
# Distributed under the Boost Software License, Version 1.0. |
| 5 |
# (See accompanying file LICENSE_1_0.txt or copy at |
| 6 |
# http://www.boost.org/LICENSE_1_0.txt) |
| 7 |
# |
| 8 |
# Original Copyright |
| 9 |
# ============================================================================> |
| 10 |
# Copyright Vladimir Prus 2002-2006. |
| 11 |
# Copyright Dave Abrahams 2005-2006. |
| 12 |
# Copyright Rene Rivera 2005-2006. |
| 13 |
# Copyright Douglas Gregor 2005. |
| 14 |
# |
| 15 |
# Distributed under the Boost Software License, Version 1.0. |
| 16 |
# (See accompanying file LICENSE_1_0.txt or copy at |
| 17 |
# http://www.boost.org/LICENSE_1_0.txt) |
| 18 |
# <============================================================================ |
| 19 |
|
| 20 |
# Usage: |
| 21 |
# |
| 22 |
# bjam [options] [install|stage] |
| 23 |
# |
| 24 |
# Builds and installs Boost. |
| 25 |
# |
| 26 |
# Targets and Related Options: |
| 27 |
# |
| 28 |
# install Install headers and compiled library files to the |
| 29 |
# ======= configured locations (below). |
| 30 |
# |
| 31 |
# --prefix=<PREFIX> Install architecture independent files here. |
| 32 |
# Default; C:\Boost on Win32 |
| 33 |
# Default; /usr/local on Unix. Linux, etc. |
| 34 |
# |
| 35 |
# --exec-prefix=<EPREFIX> Install architecture dependent files here. |
| 36 |
# Default; <PREFIX> |
| 37 |
# |
| 38 |
# --libdir=<DIR> Install library files here. |
| 39 |
# Default; <EPREFIX>/lib |
| 40 |
# |
| 41 |
# --includedir=<HDRDIR> Install header files here. |
| 42 |
# Default; <PREFIX>/include |
| 43 |
# |
| 44 |
# stage Build and install only compiled library files |
| 45 |
# ===== to the stage directory. |
| 46 |
# |
| 47 |
# --stagedir=<STAGEDIR> Install library files here |
| 48 |
# Default; ./stage |
| 49 |
# |
| 50 |
# Other Options: |
| 51 |
# |
| 52 |
# --builddir=DIR Build in this location instead of building |
| 53 |
# within the distribution tree. Recommended! |
| 54 |
# |
| 55 |
# --toolset=toolset Indicates the toolset to build with. |
| 56 |
# |
| 57 |
# --show-libraries Displays the list of Boost libraries that require |
| 58 |
# build and installation steps, then exit. |
| 59 |
# |
| 60 |
# --layout=<layout> Determines whether to choose library names |
| 61 |
# and header locations such that multiple |
| 62 |
# versions of Boost or multiple compilers can |
| 63 |
# be used on the same system. |
| 64 |
# |
| 65 |
# versioned (default) - Names of hamigaki |
| 66 |
# binaries include the Boost version |
| 67 |
# number and the name and version of the |
| 68 |
# compiler. Boost headers are installed |
| 69 |
# in a subdirectory of <HDRDIR> whose |
| 70 |
# name contains the Boost version |
| 71 |
# number. |
| 72 |
# |
| 73 |
# system - Binaries names do not include |
| 74 |
# the Boost version number or the name |
| 75 |
# and version number of the compiler. |
| 76 |
# Boost headers are installed directly |
| 77 |
# into <HDRDIR>. This option is |
| 78 |
# intended for system integrators who |
| 79 |
# are building distribution packages. |
| 80 |
# |
| 81 |
# --buildid=ID Adds the specified ID to the name of built |
| 82 |
# libraries. The default is to not add anything. |
| 83 |
# |
| 84 |
# --help This message. |
| 85 |
# |
| 86 |
# --with-<library> Build and install the specified <library> |
| 87 |
# If this option is used, only libraries |
| 88 |
# specified using this option will be built. |
| 89 |
# |
| 90 |
# --without-<library> Do not build, stage, or install the specified |
| 91 |
# <library>. By default, all libraries are built. |
| 92 |
|
| 93 |
# TODO: |
| 94 |
# - handle hamigaki version |
| 95 |
# - handle python options such as pydebug |
| 96 |
|
| 97 |
import modules ; |
| 98 |
import set ; |
| 99 |
import stage ; |
| 100 |
import package ; |
| 101 |
import path ; |
| 102 |
import common ; |
| 103 |
import os ; |
| 104 |
import regex ; |
| 105 |
import errors ; |
| 106 |
import "class" : new ; |
| 107 |
import common ; |
| 108 |
import hamigaki-version ; |
| 109 |
|
| 110 |
constant HAMIGAKI_VERSION : [ hamigaki-version.version ] ; |
| 111 |
|
| 112 |
local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(HAMIGAKI_VERSION) ] ; |
| 113 |
if $(version-tag[3]) = 0 |
| 114 |
{ |
| 115 |
version-tag = $(version-tag[1-2]) ; |
| 116 |
} |
| 117 |
|
| 118 |
constant HAMIGAKI_VERSION_TAG : $(version-tag:J="_") ; |
| 119 |
|
| 120 |
local default-build ; |
| 121 |
if $(__file__:D) = "" |
| 122 |
{ |
| 123 |
default-build = |
| 124 |
debug release |
| 125 |
<threading>single <threading>multi |
| 126 |
<link>shared <link>static |
| 127 |
; |
| 128 |
|
| 129 |
if [ os.name ] = NT |
| 130 |
{ |
| 131 |
default-build += <runtime-link>shared <runtime-link>static ; |
| 132 |
} |
| 133 |
} |
| 134 |
else |
| 135 |
{ |
| 136 |
default-build = |
| 137 |
debug |
| 138 |
; |
| 139 |
} |
| 140 |
|
| 141 |
|
| 142 |
rule handle-static-runtime ( properties * ) |
| 143 |
{ |
| 144 |
# This property combination is dangerous. |
| 145 |
# Ideally, we'd add constraint to default build, |
| 146 |
# so that user can build with property combination |
| 147 |
# by hand. But we don't have any 'constraint' mechanism |
| 148 |
# for default-build, so disable such builds in requirements. |
| 149 |
|
| 150 |
# For CW, static runtime is needed so that |
| 151 |
# std::locale works. |
| 152 |
if <link>shared in $(properties) |
| 153 |
&& <runtime-link>static in $(properties) |
| 154 |
&& ! ( <toolset>cw in $(properties) ) |
| 155 |
{ |
| 156 |
return <build>no ; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
project hamigaki |
| 162 |
: requirements |
| 163 |
<include>. |
| 164 |
<library>/boost-lib//headers |
| 165 |
<toolset>msvc-8.0:<cxxflags>-wd4819 |
| 166 |
<toolset>msvc-8.0:<cxxflags>-wd4996 |
| 167 |
# disable auto-linking for all targets here, |
| 168 |
# primarily because it caused troubles with V2 |
| 169 |
<define>BOOST_ALL_NO_LIB=1 |
| 170 |
# Used to encode variant in target name. See the |
| 171 |
# 'tag' rule below. |
| 172 |
<tag>@$(__name__).tag |
| 173 |
<conditional>@handle-static-runtime |
| 174 |
|
| 175 |
: usage-requirements |
| 176 |
<include>. |
| 177 |
: build-dir bin.v2 |
| 178 |
: default-build $(default-build) |
| 179 |
; |
| 180 |
|
| 181 |
# Setup convenient aliases for all libraries. |
| 182 |
|
| 183 |
all-libraries = |
| 184 |
[ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ] ] |
| 185 |
; |
| 186 |
|
| 187 |
alias headers : : : : <include>. ; |
| 188 |
|
| 189 |
|
| 190 |
# Decides which libraries are to be installed by looking at --with-<library> |
| 191 |
# --without-<library> arguments. Returns the list of directories under "libs" |
| 192 |
# which must be built at installed. |
| 193 |
rule libraries-to-install ( existing-libraries * ) |
| 194 |
{ |
| 195 |
local argv = [ modules.peek : ARGV ] ; |
| 196 |
local with-parameter = [ MATCH --with-(.*) : $(argv) ] ; |
| 197 |
local without-parameter = [ MATCH --without-(.*) : $(argv) ] ; |
| 198 |
|
| 199 |
# Do some checks |
| 200 |
if $(with-parameter) && $(without-parameter) |
| 201 |
{ |
| 202 |
ECHO "error: both --with-<library> and --without-<library> specified" ; |
| 203 |
EXIT ; |
| 204 |
} |
| 205 |
|
| 206 |
local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ; |
| 207 |
if $(wrong) |
| 208 |
{ |
| 209 |
ECHO "error: wrong library name '$(wrong[1])' in the --with-<library> option." ; |
| 210 |
EXIT ; |
| 211 |
} |
| 212 |
local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ; |
| 213 |
if $(wrong) |
| 214 |
{ |
| 215 |
ECHO "error: wrong library name '$(wrong[1])' in the --without-<library> option." ; |
| 216 |
EXIT ; |
| 217 |
} |
| 218 |
|
| 219 |
if $(with-parameter) |
| 220 |
{ |
| 221 |
return [ set.intersection $(existing-libraries) : $(with-parameter) ] ; |
| 222 |
} |
| 223 |
else |
| 224 |
{ |
| 225 |
return [ set.difference $(existing-libraries) : $(without-parameter) ] ; |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
# what kind of layout are we doing? |
| 230 |
layout = [ MATCH "^--layout=(.*)" : [ modules.peek : ARGV ] ] ; |
| 231 |
layout ?= versioned ; |
| 232 |
layout-$(layout) = true ; |
| 233 |
|
| 234 |
# possible stage only location |
| 235 |
local stage-locate = [ MATCH "^--stagedir=(.*)" : [ modules.peek : ARGV ] ] ; |
| 236 |
stage-locate ?= stage ; |
| 237 |
|
| 238 |
path-constant HAMIGAKI_STAGE_LOCATE : $(stage-locate) ; |
| 239 |
|
| 240 |
|
| 241 |
# location of python |
| 242 |
local python-root = [ MATCH "^--with-python-root=(.*)" : [ modules.peek : ARGV ] ] ; |
| 243 |
PYTHON_ROOT ?= $(python-root) ; |
| 244 |
|
| 245 |
# Select the libraries to install. |
| 246 |
libraries = [ libraries-to-install $(all-libraries) ] ; |
| 247 |
|
| 248 |
if --show-libraries in [ modules.peek : ARGV ] |
| 249 |
{ |
| 250 |
ECHO "The following libraries require building:" ; |
| 251 |
for local l in $(libraries) |
| 252 |
{ |
| 253 |
ECHO " - $(l)" ; |
| 254 |
} |
| 255 |
EXIT ; |
| 256 |
} |
| 257 |
|
| 258 |
# Custom build ID. |
| 259 |
local build-id = [ MATCH "^--buildid=(.*)" : [ modules.peek : ARGV ] ] ; |
| 260 |
if $(build-id) |
| 261 |
{ |
| 262 |
constant BUILD_ID : [ regex.replace $(build-id) "[*\\/:.\"\' ]" "_" ] ; |
| 263 |
} |
| 264 |
|
| 265 |
# This rule is called by Boost.Build to determine the name of |
| 266 |
# target. We use it to encode build variant, compiler name and |
| 267 |
# hamigaki version in the target name |
| 268 |
rule tag ( name : type ? : property-set ) |
| 269 |
{ |
| 270 |
if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB |
| 271 |
{ |
| 272 |
if $(layout) = versioned |
| 273 |
{ |
| 274 |
local result = [ common.format-name |
| 275 |
<base> <toolset> <threading> <runtime> -$(HAMIGAKI_VERSION_TAG) |
| 276 |
-$(BUILD_ID) |
| 277 |
: $(name) : $(type) : $(property-set) ] ; |
| 278 |
|
| 279 |
# Optionally add version suffix. |
| 280 |
# On NT, library with version suffix won't be recognized |
| 281 |
# by linkers. On CYGWIN, we get strage duplicate symbol |
| 282 |
# errors when library is generated with version suffix. |
| 283 |
# On OSX, version suffix is not needed -- the linker expets |
| 284 |
# libFoo.1.2.3.dylib format. |
| 285 |
# AIX linkers don't accept version suffixes either. |
| 286 |
if $(type) = SHARED_LIB && |
| 287 |
! ( [ $(property-set).get <target-os> ] in windows cygwin darwin aix ) |
| 288 |
{ |
| 289 |
result = $(result).$(HAMIGAKI_VERSION) ; |
| 290 |
} |
| 291 |
|
| 292 |
return $(result) ; |
| 293 |
} |
| 294 |
else |
| 295 |
{ |
| 296 |
return [ common.format-name |
| 297 |
<base> <threading> <runtime> -$(BUILD_ID) |
| 298 |
: $(name) : $(type) : $(property-set) ] ; |
| 299 |
} |
| 300 |
} |
| 301 |
} |
| 302 |
|
| 303 |
# Install to system location. |
| 304 |
|
| 305 |
local install-requirements = |
| 306 |
<install-source-root>hamigaki |
| 307 |
; |
| 308 |
if $(layout-versioned) |
| 309 |
{ |
| 310 |
install-requirements += <install-header-subdir>hamigaki-$(HAMIGAKI_VERSION_TAG)/hamigaki ; |
| 311 |
} |
| 312 |
else |
| 313 |
{ |
| 314 |
install-requirements += <install-header-subdir>hamigaki ; |
| 315 |
} |
| 316 |
if [ modules.peek : NT ] |
| 317 |
{ |
| 318 |
install-requirements += <install-default-prefix>C:/Hamigaki ; |
| 319 |
} |
| 320 |
else if [ modules.peek : UNIX ] |
| 321 |
{ |
| 322 |
install-requirements += <install-default-prefix>/usr/local ; |
| 323 |
} |
| 324 |
|
| 325 |
local headers = |
| 326 |
[ path.glob-tree hamigaki : *.hpp *.ipp *.h *.inc : CVS .svn ] |
| 327 |
; |
| 328 |
|
| 329 |
|
| 330 |
# Complete install |
| 331 |
package.install install-proper |
| 332 |
: $(install-requirements) <install-no-version-symlinks>on |
| 333 |
: |
| 334 |
: libs/$(libraries)/build |
| 335 |
: $(headers) |
| 336 |
; |
| 337 |
explicit install-proper ; |
| 338 |
|
| 339 |
# Install just library. |
| 340 |
install stage-proper |
| 341 |
: libs/$(libraries)/build |
| 342 |
: <location>$(stage-locate)/lib |
| 343 |
<install-dependencies>on <install-type>LIB |
| 344 |
<install-no-version-symlinks>on |
| 345 |
; |
| 346 |
explicit stage-proper ; |
| 347 |
|
| 348 |
|
| 349 |
if $(layout-versioned) |
| 350 |
&& ( [ modules.peek : NT ] || [ modules.peek : UNIX ] ) |
| 351 |
{ |
| 352 |
rule make-unversioned-links ( project name ? : property-set : sources * ) |
| 353 |
{ |
| 354 |
local result ; |
| 355 |
local filtered ; |
| 356 |
local pattern ; |
| 357 |
local nt = [ modules.peek : NT ] ; |
| 358 |
|
| 359 |
# Collect the libraries that have the version number in 'filtered'. |
| 360 |
for local s in $(sources) |
| 361 |
{ |
| 362 |
local m ; |
| 363 |
if $(nt) |
| 364 |
{ |
| 365 |
m = [ MATCH "(.*[.]lib)" : [ $(s).name ] ] ; |
| 366 |
} |
| 367 |
else |
| 368 |
{ |
| 369 |
m = [ MATCH "(.*[.]so[.0-9]+)" "(.*[.]a)" : [ $(s).name ] ] ; |
| 370 |
} |
| 371 |
if $(m) |
| 372 |
{ |
| 373 |
filtered += $(s) ; |
| 374 |
} |
| 375 |
} |
| 376 |
|
| 377 |
# Create hardlinks without version. |
| 378 |
for local s in $(filtered) |
| 379 |
{ |
| 380 |
local name = [ $(s).name ] ; |
| 381 |
local ea = [ $(s).action ] ; |
| 382 |
local ep = [ $(ea).properties ] ; |
| 383 |
local a = [ |
| 384 |
new non-scanning-action $(s) : common.hard-link : $(ep) ] ; |
| 385 |
|
| 386 |
local noversion-file ; |
| 387 |
if $(nt) |
| 388 |
{ |
| 389 |
noversion-file = [ MATCH "(.*)-[0-9_]+([.]lib)" : $(name) ] ; |
| 390 |
} |
| 391 |
else |
| 392 |
{ |
| 393 |
noversion-file = |
| 394 |
[ MATCH "(.*)-[0-9_]+([.]so)[.0-9]*" : $(name) ] |
| 395 |
[ MATCH "(.*)-[0-9_]+([.]a)" : $(name) ] |
| 396 |
[ MATCH "(.*)-[0-9_]+([.]dll[.]a)" : $(name) ] ; |
| 397 |
} |
| 398 |
|
| 399 |
local new-name = |
| 400 |
$(noversion-file[1])$(noversion-file[2]) ; |
| 401 |
result += [ new file-target $(new-name) exact : [ $(s).type ] : $(project) |
| 402 |
: $(a) ] ; |
| 403 |
|
| 404 |
} |
| 405 |
return $(result) ; |
| 406 |
} |
| 407 |
|
| 408 |
generate stage-unversioned : stage-proper : |
| 409 |
<generating-rule>@make-unversioned-links ; |
| 410 |
explicit stage-unversioned ; |
| 411 |
|
| 412 |
generate install-unversioned : install-proper : |
| 413 |
<generating-rule>@make-unversioned-links ; |
| 414 |
explicit install-unversioned ; |
| 415 |
} |
| 416 |
else |
| 417 |
{ |
| 418 |
# Create do-nothing aliases |
| 419 |
alias stage-unversioned ; |
| 420 |
alias install-unversioned ; |
| 421 |
} |
| 422 |
|
| 423 |
alias install : install-proper install-unversioned ; |
| 424 |
alias stage : stage-proper stage-unversioned ; |
| 425 |
explicit install ; |
| 426 |
explicit stage ; |
| 427 |
|
| 428 |
|
| 429 |
# Just build the libraries, don't install them anywhere. |
| 430 |
# This is what happens with just "bjam --v2". |
| 431 |
alias build_all : libs/$(libraries)/build ; |
| 432 |
|
| 433 |
# This rule should be called from libraries' Jamfiles and will |
| 434 |
# create two targets, "install" and "stage", that will install |
| 435 |
# or stage that library. The --prefix option is respected, by |
| 436 |
# --with and --without options, naturally, are ignored. |
| 437 |
# |
| 438 |
# - libraries -- list of library targets to install. |
| 439 |
rule hamigaki-install ( libraries * ) |
| 440 |
{ |
| 441 |
package.install install |
| 442 |
: <dependency>/hamigaki//install-headers $(install-requirements) |
| 443 |
: # No binaries |
| 444 |
: $(libraries) |
| 445 |
: # No headers, it's handled by the dependency |
| 446 |
; |
| 447 |
|
| 448 |
install stage : $(libraries) : <location>$(HAMIGAKI_STAGE_LOCATE) ; |
| 449 |
|
| 450 |
local c = [ project.current ] ; |
| 451 |
local project-module = [ $(c).project-module ] ; |
| 452 |
module $(project-module) |
| 453 |
{ |
| 454 |
explicit stage ; |
| 455 |
} |
| 456 |
} |
| 457 |
|
| 458 |
# Make project ids of all libraries known. |
| 459 |
for local l in $(libraries) |
| 460 |
{ |
| 461 |
use-project /hamigaki/$(l) : libs/$(l)/build ; |
| 462 |
} |