]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/util/os.jam
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / build / src / util / os.jam
1 # Copyright 2001, 2002, 2003, 2005 Dave Abrahams
2 # Copyright 2006 Rene Rivera
3 # Copyright 2003, 2005 Vladimir Prus
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
6
7 import modules ;
8 import string ;
9
10
11 # Return the value(s) of the given environment variable(s) at the time bjam was
12 # invoked.
13 rule environ ( variable-names + )
14 {
15 local result ;
16 for local var-name in $(variable-names)
17 {
18 # We check the various cases of the var name for a value to account
19 # for programs that change the casing of env vars. One such program
20 # is Python that upper-cases env var names on import, and resports
21 # them as upper-case instead of keeping the original case.
22 local value ;
23 value ?= [ modules.peek .ENVIRON : $(var-name) ] ;
24 value ?= [ modules.peek .ENVIRON : $(var-name:U) ] ;
25 value ?= [ modules.peek .ENVIRON : $(var-name:L) ] ;
26 result += $(value) ;
27 }
28 return $(result) ;
29 }
30
31 .name = [ modules.peek : OS ] ;
32 .platform = [ modules.peek : OSPLAT ] ;
33 .version = [ modules.peek : OSVER ] ;
34
35
36 local rule constant ( c : os ? )
37 {
38 os ?= $(.name) ;
39 # First look for a platform-specific name, then the general value.
40 local variables = .$(c)-$(os) .$(c) ;
41 local result = $($(variables)) ;
42 return $(result[1]) ;
43 }
44
45 rule get-constant ( os ? )
46 {
47 # Find the name of the constant being accessed, which is equal to the name
48 # used to invoke us.
49 local bt = [ BACKTRACE 1 ] ;
50 local rulename = [ MATCH ([^.]*)$ : $(bt[4]) ] ;
51 return [ constant $(rulename) : $(os) ] ;
52 }
53
54
55 # export all the common constants
56 .constants = name platform version shared-library-path-variable path-separator executable-path-variable executable-suffix ;
57 for local constant in $(.constants)
58 {
59 IMPORT $(__name__) : get-constant : $(__name__) : $(constant) ;
60 }
61 EXPORT $(__name__) : $(.constants) ;
62
63 .executable-path-variable-NT = PATH ;
64 # On Windows the case and capitalization of PATH is not always predictable, so
65 # let's find out what variable name was really set.
66 if $(.name) = NT
67 {
68 for local n in [ VARNAMES .ENVIRON ]
69 {
70 if $(n:L) = path
71 {
72 .executable-path-variable-NT = $(n) ;
73 }
74 }
75 }
76
77 # Specific constants for various platforms. There's no need to define any
78 # constant whose value would be the same as the default, below.
79 .shared-library-path-variable-NT = $(.executable-path-variable-NT) ;
80 .path-separator-NT = ";" ;
81 .path-separator-VXWORKS = ";" ;
82 .expand-variable-prefix-NT = % ;
83 .expand-variable-suffix-NT = % ;
84 .executable-suffix-NT = .exe ;
85
86 .shared-library-path-variable-CYGWIN = PATH ;
87
88 .shared-library-path-variable-MACOSX = DYLD_LIBRARY_PATH ;
89
90 .shared-library-path-variable-AIX = LIBPATH ;
91
92 .shared-library-path-variable-HAIKU = LIBRARY_PATH ;
93
94 .shared-library-path-variable-VMS = PATH ;
95 .path-separator-VMS = "," ;
96 .expand-variable-prefix-VMS = '' ;
97 .expand-variable-suffix-VMS = ' ;
98 .executable-suffix-VMS = .exe ;
99
100 # VxWorks uses the default LD_LIBRARY_PATH, but we need an alternate
101 # name on the cross build host to propigate to the target system
102 .shared-library-path-variable-VXWORKS = VSB_LD_LIBRARY_PATH ;
103
104 # Default constants
105 .shared-library-path-variable = LD_LIBRARY_PATH ;
106 .path-separator = ":" ;
107 .expand-variable-prefix = $ ;
108 .expand-variable-suffix = "" ;
109 .executable-path-variable = PATH ;
110 .executable-suffix = "" ;
111
112
113 # Return a list of the directories in the PATH. Yes, that information is (sort
114 # of) available in the global module, but jam code can change those values, and
115 # it isn't always clear what case/capitalization to use when looking. This rule
116 # is a more reliable way to get there.
117 rule executable-path ( )
118 {
119 return [ string.words [ environ [ constant executable-path-variable ] ]
120 : [ constant path-separator ] ] ;
121 }
122
123
124 # Initialize the list of home directories for the current user depending on the
125 # OS.
126 if $(.name) = NT
127 {
128 local home = [ environ HOMEDRIVE HOMEPATH ] ;
129 .home-directories = $(home[1])$(home[2]) [ environ HOME ] [ environ USERPROFILE ] ;
130 }
131 else
132 {
133 .home-directories = [ environ HOME ] ;
134 }
135
136
137 # Can't use 'constant' mechanism because it only returns 1-element values.
138 rule home-directories ( )
139 {
140 return $(.home-directories) ;
141 }
142
143
144 # Return the string needed to represent the expansion of the named shell
145 # variable.
146 rule expand-variable ( variable )
147 {
148 local prefix = [ constant expand-variable-prefix ] ;
149 local suffix = [ constant expand-variable-suffix ] ;
150 return $(prefix)$(variable)$(suffix) ;
151 }
152
153
154 # Returns true if running on windows, whether in cygwin or not.
155 rule on-windows ( )
156 {
157 local result ;
158 if [ modules.peek : NT ]
159 {
160 result = true ;
161 }
162 else if [ modules.peek : UNIX ]
163 {
164 switch [ modules.peek : JAMUNAME ]
165 {
166 case CYGWIN* :
167 {
168 result = true ;
169 }
170 }
171 }
172 return $(result) ;
173 }
174
175
176 rule on-vms ( )
177 {
178 local result ;
179 if [ modules.peek : VMS ]
180 {
181 result = true ;
182 }
183 return $(result) ;
184 }
185
186
187 if ! [ on-windows ] && ! [ on-vms ]
188 {
189 .on-unix = 1 ;
190 }
191
192
193 rule on-unix
194 {
195 return $(.on-unix) ;
196 }
197
198
199 rule __test__
200 {
201 import assert ;
202 if ! ( --quiet in [ modules.peek : ARGV ] )
203 {
204 ECHO os: name= [ name ] ;
205 ECHO os: version= [ version ] ;
206 }
207 assert.true name ;
208 }