1# Copyright 2003 Dave Abrahams 2# Copyright 2003, 2005, 2006 Rene Rivera 3# Copyright 2003, 2005, 2006 Vladimir Prus 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# First of all, check the jam version. 9if $(JAM_VERSION:J="") < 030112 10{ 11 ECHO "error: Boost.Jam version 3.1.12 or later required" ; 12 EXIT ; 13} 14 15local required-rules = GLOB-RECURSIVELY HAS_NATIVE_RULE ; 16for local r in $(required-rules) 17{ 18 if ! $(r) in [ RULENAMES ] 19 { 20 ECHO "error: builtin rule '$(r)' is not present" ; 21 ECHO "error: your version of bjam is likely out of date" ; 22 ECHO "error: please get a fresh version from SVN." ; 23 EXIT ; 24 } 25} 26 27local native = regex transform 2 ; 28while $(native) 29{ 30 if ! [ HAS_NATIVE_RULE $(native[1]) : $(native[2]) : $(native[3]) ] 31 { 32 ECHO "error: missing native rule '$(native[1]).$(native[2])'" ; 33 ECHO "error: or interface version of that rule is too low" ; 34 ECHO "error: your version of bjam is likely out of date" ; 35 ECHO "error: please get a fresh version from SVN." ; 36 EXIT ; 37 } 38 native = $(native[4-]) ; 39} 40 41 42# Check that the builtin .ENVIRON module is present. We do not have a builtin to 43# check that a module is present, so we assume that the PATH environment 44# variable is always set and verify that the .ENVIRON module has a non-empty 45# value of that variable. 46module .ENVIRON 47{ 48 local p = $(PATH) $(Path) $(path) ; 49 if ! $(p) 50 { 51 ECHO "error: no builtin module .ENVIRON is found" ; 52 ECHO "error: your version of bjam is likely out of date" ; 53 ECHO "error: please get a fresh version from SVN." ; 54 EXIT ; 55 } 56} 57 58# Check that @() functionality is present. Similarly to modules, we do not have 59# a way to test this directly. Instead we check that $(TMPNAME) functionality is 60# present which was added at roughly the same time (more precisely, it was added 61# just before). 62{ 63 if ! $(TMPNAME) 64 { 65 ECHO "error: no @() functionality found" ; 66 ECHO "error: your version of b2 is likely out of date" ; 67 ECHO "error: please get a fresh version from SVN." ; 68 EXIT ; 69 } 70} 71 72# Make sure that \n escape is available. 73if "\n" = "n" 74{ 75 if $(OS) = CYGWIN 76 { 77 ECHO "warning: escape sequences are not supported" ; 78 ECHO "warning: this will cause major misbehaviour on cygwin" ; 79 ECHO "warning: your version of b2 is likely out of date" ; 80 ECHO "warning: please get a fresh version from SVN." ; 81 } 82} 83 84 85# Bootstrap the module system. Then bring the import rule into the global module. 86# 87SEARCH on <module@>modules.jam = $(.bootstrap-file:D) ; 88module modules { include <module@>modules.jam ; } 89IMPORT modules : import : : import ; 90 91{ 92 # Add module subdirectories to the BOOST_BUILD_PATH, which allows us to make 93 # incremental refactoring steps by moving modules to appropriate 94 # subdirectories, thereby achieving some physical separation of different 95 # layers without changing all of our code to specify subdirectories in 96 # import statements or use an extra level of qualification on imported 97 # names. 98 99 local subdirs = 100 kernel # only the most-intrinsic modules: modules, errors 101 util # low-level substrate: string/number handling, etc. 102 build # essential elements of the build system architecture 103 tools # toolsets for handling specific build jobs and targets. 104 contrib # user contributed (unreviewed) modules 105 . # build-system.jam lives here 106 ; 107 local whereami = [ NORMALIZE_PATH $(.bootstrap-file:DT) ] ; 108 BOOST_BUILD_PATH += $(whereami:D)/$(subdirs) ; 109 110 modules.poke .ENVIRON : BOOST_BUILD_PATH : $(BOOST_BUILD_PATH) ; 111 112 modules.poke : EXTRA_PYTHONPATH : $(whereami) ; 113} 114 115# Reload the modules, to clean up things. The modules module can tolerate being 116# imported twice. 117# 118import modules ; 119 120# Process option plugins first to allow them to prevent loading the rest of the 121# build system. 122# 123import option ; 124local dont-build = [ option.process ] ; 125 126# Should we skip building, i.e. loading the build system, according to the 127# options processed? 128# 129if ! $(dont-build) 130{ 131 if ! --python in $(ARGV) 132 { 133 # Allow users to override the build system file from the command-line 134 # (mostly for testing). 135 local build-system = [ MATCH --build-system=(.*) : $(ARGV) ] ; 136 build-system ?= build-system ; 137 138 # Use last element in case of multiple command-line options. 139 import $(build-system[-1]) ; 140 } 141 else 142 { 143 144 # Define additional interface exposed to Python code. Python code will 145 # also have access to select bjam builtins in the 'bjam' module, but 146 # some things are easier to define outside C. 147 module python_interface 148 { 149 rule load ( module-name : location ) 150 { 151 USER_MODULE $(module-name) ; 152 # Make all rules in the loaded module available in the global 153 # namespace, so that we do not have to bother specifying the 154 # "correct" module when calling from Python. 155 module $(module-name) 156 { 157 __name__ = $(1) ; 158 include $(2) ; 159 local rules = [ RULENAMES $(1) ] ; 160 IMPORT $(1) : $(rules) : $(1) : $(1).$(rules) ; 161 } 162 } 163 164 rule peek ( module-name ? : variables + ) 165 { 166 module $(<) 167 { 168 return $($(>)) ; 169 } 170 } 171 172 rule set-variable ( module-name : name : value * ) 173 { 174 module $(<) 175 { 176 $(>) = $(3) ; 177 } 178 } 179 180 rule set-top-level-targets ( targets * ) 181 { 182 DEPENDS all : $(targets) ; 183 } 184 185 rule call-in-module ( m : rulename : * ) 186 { 187 module $(m) 188 { 189 return [ $(2) $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) 190 : $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : $(16) 191 : $(17) : $(18) : $(19) ] ; 192 } 193 } 194 195 196 rule set-update-action ( action : targets * : sources * : 197 properties * ) 198 { 199 $(action) $(targets) : $(sources) : $(properties) ; 200 } 201 202 rule set-update-action-in-module ( m : action : targets * : 203 sources * : properties * ) 204 { 205 module $(m) 206 { 207 $(2) $(3) : $(4) : $(5) ; 208 } 209 } 210 211 rule set-target-variable ( targets + : variable : value * : append ? 212 ) 213 { 214 if $(append) 215 { 216 $(variable) on $(targets) += $(value) ; 217 } 218 else 219 { 220 $(variable) on $(targets) = $(value) ; 221 } 222 } 223 224 rule get-target-variable ( targets + : variable ) 225 { 226 return [ on $(targets) return $($(variable)) ] ; 227 } 228 229 rule import-rules-from-parent ( parent-module : this-module : 230 user-rules * ) 231 { 232 IMPORT $(parent-module) : $(user-rules) : $(this-module) : 233 $(user-rules) ; 234 EXPORT $(this-module) : $(user-rules) ; 235 } 236 237 rule mark-included ( targets * : includes * ) 238 { 239 NOCARE $(includes) ; 240 INCLUDES $(targets) : $(includes) ; 241 ISFILE $(includes) ; 242 } 243 } 244 245 PYTHON_IMPORT_RULE bootstrap : bootstrap : PyBB : bootstrap ; 246 modules.poke PyBB : root : [ NORMALIZE_PATH $(.bootstrap-file:DT)/.. ] ; 247 248 module PyBB 249 { 250 local ok = [ bootstrap $(root) ] ; 251 if ! $(ok) 252 { 253 EXIT ; 254 } 255 } 256 257 258 #PYTHON_IMPORT_RULE boost.build.build_system : main : PyBB : main ; 259 260 #module PyBB 261 #{ 262 # main ; 263 #} 264 } 265} 266