1 | # (C) Copyright David Abrahams, 2001. |
---|
2 | # (C) Copyright Rene Rivera, 2003. |
---|
3 | # |
---|
4 | # See accompanying license for terms and conditions of use. |
---|
5 | # |
---|
6 | |
---|
7 | # First of all, check the jam version |
---|
8 | |
---|
9 | if $(JAM_VERSION:J="") < 030109 |
---|
10 | { |
---|
11 | ECHO "error: Boost.Jam version 3.1.9 or later required" ; |
---|
12 | EXIT ; |
---|
13 | } |
---|
14 | |
---|
15 | local required-rules = GLOB-RECURSIVELY ; |
---|
16 | |
---|
17 | for local r in $(required-rules) |
---|
18 | { |
---|
19 | if ! $(r) in [ RULENAMES ] |
---|
20 | { |
---|
21 | ECHO "error: builtin rule '$(r)' is not present" ; |
---|
22 | ECHO "error: you version of bjam is likely out of date" ; |
---|
23 | ECHO "error: please get a fresh version from CVS." ; |
---|
24 | EXIT ; |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | # Check that the builtin .ENVIRON module is present. We don't have a |
---|
29 | # builtin to check that a module is present, so we assume that the PATH |
---|
30 | # environment variable is always set and verify that the .ENVIRON module |
---|
31 | # has non-empty value of that variable. |
---|
32 | module .ENVIRON |
---|
33 | { |
---|
34 | local p = $(PATH) $(Path) $(path) ; |
---|
35 | if ! $(p) |
---|
36 | { |
---|
37 | ECHO "error: no builtin module .ENVIRON is found" ; |
---|
38 | ECHO "error: you version of bjam is likely out of date" ; |
---|
39 | ECHO "error: please get a fresh version from CVS." ; |
---|
40 | EXIT ; |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | |
---|
46 | # Bootstrap the module system. Then bring the import rule into the global module. |
---|
47 | # |
---|
48 | SEARCH on <module@>modules.jam = $(.bootstrap-file:D) ; |
---|
49 | module modules { include <module@>modules.jam ; } |
---|
50 | IMPORT modules : import : : import ; |
---|
51 | |
---|
52 | { |
---|
53 | # Add module subdirectories to the BOOST_BUILD_PATH, which allows |
---|
54 | # us to make an incremental refactoring step by moving modules to |
---|
55 | # the appropriate subdirectories, thereby achieving some physical |
---|
56 | # separation of different layers without changing all of our code |
---|
57 | # to specify subdirectories in import statements or use an extra |
---|
58 | # level of qualification on imported names. |
---|
59 | |
---|
60 | local subdirs = |
---|
61 | kernel # only the most-intrinsic modules: modules, errors |
---|
62 | util # low-level substrate: string/number handling, etc. |
---|
63 | build # essential elements of the build system architecture |
---|
64 | tools # toolsets for handling specific build jobs and targets. |
---|
65 | |
---|
66 | new # until we get everything sorted out, there is |
---|
67 | # still some code here |
---|
68 | |
---|
69 | . # build-system.jam lives here |
---|
70 | |
---|
71 | ; |
---|
72 | local whereami = [ NORMALIZE_PATH $(.bootstrap-file:DT) ] ; |
---|
73 | BOOST_BUILD_PATH += $(whereami:D)/$(subdirs) ; |
---|
74 | |
---|
75 | modules.poke .ENVIRON : BOOST_BUILD_PATH : $(BOOST_BUILD_PATH) ; |
---|
76 | } |
---|
77 | |
---|
78 | # Reload the modules, to clean up things. The modules module can tolerate |
---|
79 | # being included twice. |
---|
80 | # |
---|
81 | import modules ; |
---|
82 | |
---|
83 | # Check command-line args as soon as possible. For each option try |
---|
84 | # to load module named after option. Is that succeeds, invoke 'process' |
---|
85 | # rule in the module. The rule may return "true" to indicate that the |
---|
86 | # regular built process should not be attempted. |
---|
87 | # |
---|
88 | # Options take the general form of: --<name>[=<value>] [<value>] |
---|
89 | # |
---|
90 | local dont-build ; |
---|
91 | local args = $(ARGV) ; |
---|
92 | while $(args) |
---|
93 | { |
---|
94 | local arg = [ MATCH ^--(.*) : $(args[1]) ] ; |
---|
95 | while $(args[2-]) && ! $(arg) |
---|
96 | { |
---|
97 | args = $(args[2-]) ; |
---|
98 | arg = [ MATCH ^--(.*) : $(args[1]) ] ; |
---|
99 | } |
---|
100 | args = $(args[2-]) ; |
---|
101 | |
---|
102 | if $(arg) |
---|
103 | { |
---|
104 | local split = [ MATCH ^(([^-=]+)[^=]*)(=?)(.*)$ : $(arg) ] ; |
---|
105 | local full-name = $(split[1]) ; |
---|
106 | local prefix = $(split[2]) ; |
---|
107 | local values ; |
---|
108 | |
---|
109 | if $(split[3]) |
---|
110 | { |
---|
111 | values = $(split[4]) ; |
---|
112 | } |
---|
113 | if $(args) && ! [ MATCH ^(--).* : $(args[1]) ] |
---|
114 | { |
---|
115 | values += $(args[1]) ; |
---|
116 | args = $(args[2-]) ; |
---|
117 | } |
---|
118 | |
---|
119 | # look in options subdirectories of BOOST_BUILD_PATH for modules |
---|
120 | # matching the full option name and then its prefix. |
---|
121 | local plugin-dir = options ; |
---|
122 | local option-files = [ |
---|
123 | GLOB $(plugin-dir:D=$(BOOST_BUILD_PATH)) : $(full-name).jam $(prefix).jam |
---|
124 | ] ; |
---|
125 | |
---|
126 | if $(option-files) |
---|
127 | { |
---|
128 | # load the file into a module named for the option |
---|
129 | local f = $(option-files[1]) ; |
---|
130 | local module-name = --$(f:D=:S=) ; |
---|
131 | modules.load $(module-name) : $(f:D=) : $(f:D) ; |
---|
132 | |
---|
133 | # if there's a process rule, call it with the full option name |
---|
134 | # and its value (if any). If there was no "=" in the option, |
---|
135 | # the value will be empty. |
---|
136 | if process in [ RULENAMES $(module-name) ] |
---|
137 | { |
---|
138 | dont-build += |
---|
139 | [ modules.call-in $(module-name) : process --$(full-name) : $(values) ] ; |
---|
140 | } |
---|
141 | } |
---|
142 | } |
---|
143 | } |
---|
144 | |
---|
145 | if ! $(dont-build) |
---|
146 | { |
---|
147 | # Allow users to override the build system file from the |
---|
148 | # command-line (mostly for testing) |
---|
149 | local build-system = [ MATCH --build-system=(.*) : $(ARGV) ] ; |
---|
150 | build-system ?= build-system ; |
---|
151 | |
---|
152 | # Use last element in case of multiple command-line options |
---|
153 | import $(build-system[-1]) ; |
---|
154 | } |
---|