]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/util/os.jam
add subtree-ish sources for 12.0.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 return [ modules.peek .ENVIRON : $(variable-names) ] ;
16 }
17
18 .name = [ modules.peek : OS ] ;
19 .platform = [ modules.peek : OSPLAT ] ;
20 .version = [ modules.peek : OSVER ] ;
21
22
23 local rule constant ( c : os ? )
24 {
25 os ?= $(.name) ;
26 # First look for a platform-specific name, then the general value.
27 local variables = .$(c)-$(os) .$(c) ;
28 local result = $($(variables)) ;
29 return $(result[1]) ;
30 }
31
32 rule get-constant ( os ? )
33 {
34 # Find the name of the constant being accessed, which is equal to the name
35 # used to invoke us.
36 local bt = [ BACKTRACE 1 ] ;
37 local rulename = [ MATCH ([^.]*)$ : $(bt[4]) ] ;
38 return [ constant $(rulename) : $(os) ] ;
39 }
40
41
42 # export all the common constants
43 .constants = name platform version shared-library-path-variable path-separator executable-path-variable executable-suffix ;
44 for local constant in $(.constants)
45 {
46 IMPORT $(__name__) : get-constant : $(__name__) : $(constant) ;
47 }
48 EXPORT $(__name__) : $(.constants) ;
49
50 .executable-path-variable-NT = PATH ;
51 # On Windows the case and capitalization of PATH is not always predictable, so
52 # let's find out what variable name was really set.
53 if $(.name) = NT
54 {
55 for local n in [ VARNAMES .ENVIRON ]
56 {
57 if $(n:L) = path
58 {
59 .executable-path-variable-NT = $(n) ;
60 }
61 }
62 }
63
64 # Specific constants for various platforms. There's no need to define any
65 # constant whose value would be the same as the default, below.
66 .shared-library-path-variable-NT = $(.executable-path-variable-NT) ;
67 .path-separator-NT = ";" ;
68 .expand-variable-prefix-NT = % ;
69 .expand-variable-suffix-NT = % ;
70 .executable-suffix-NT = .exe ;
71
72 .shared-library-path-variable-CYGWIN = PATH ;
73
74 .shared-library-path-variable-MACOSX = DYLD_LIBRARY_PATH ;
75
76 .shared-library-path-variable-AIX = LIBPATH ;
77
78 .shared-library-path-variable-HAIKU = LIBRARY_PATH ;
79
80 .shared-library-path-variable-VMS = PATH ;
81 .path-separator-VMS = "," ;
82 .expand-variable-prefix-VMS = '' ;
83 .expand-variable-suffix-VMS = ' ;
84 .executable-suffix-VMS = .exe ;
85
86 # Default constants
87 .shared-library-path-variable = LD_LIBRARY_PATH ;
88 .path-separator = ":" ;
89 .expand-variable-prefix = $ ;
90 .expand-variable-suffix = "" ;
91 .executable-path-variable = PATH ;
92 .executable-suffix = "" ;
93
94
95 # Return a list of the directories in the PATH. Yes, that information is (sort
96 # of) available in the global module, but jam code can change those values, and
97 # it isn't always clear what case/capitalization to use when looking. This rule
98 # is a more reliable way to get there.
99 rule executable-path ( )
100 {
101 return [ string.words [ environ [ constant executable-path-variable ] ]
102 : [ constant path-separator ] ] ;
103 }
104
105
106 # Initialize the list of home directories for the current user depending on the
107 # OS.
108 if $(.name) = NT
109 {
110 local home = [ environ HOMEDRIVE HOMEPATH ] ;
111 .home-directories = $(home[1])$(home[2]) [ environ HOME ] [ environ USERPROFILE ] ;
112 }
113 else
114 {
115 .home-directories = [ environ HOME ] ;
116 }
117
118
119 # Can't use 'constant' mechanism because it only returns 1-element values.
120 rule home-directories ( )
121 {
122 return $(.home-directories) ;
123 }
124
125
126 # Return the string needed to represent the expansion of the named shell
127 # variable.
128 rule expand-variable ( variable )
129 {
130 local prefix = [ constant expand-variable-prefix ] ;
131 local suffix = [ constant expand-variable-suffix ] ;
132 return $(prefix)$(variable)$(suffix) ;
133 }
134
135
136 # Returns true if running on windows, whether in cygwin or not.
137 rule on-windows ( )
138 {
139 local result ;
140 if [ modules.peek : NT ]
141 {
142 result = true ;
143 }
144 else if [ modules.peek : UNIX ]
145 {
146 switch [ modules.peek : JAMUNAME ]
147 {
148 case CYGWIN* :
149 {
150 result = true ;
151 }
152 }
153 }
154 return $(result) ;
155 }
156
157
158 rule on-vms ( )
159 {
160 local result ;
161 if [ modules.peek : VMS ]
162 {
163 result = true ;
164 }
165 return $(result) ;
166 }
167
168
169 if ! [ on-windows ] && ! [ on-vms ]
170 {
171 .on-unix = 1 ;
172 }
173
174
175 rule on-unix
176 {
177 return $(.on-unix) ;
178 }
179
180
181 rule __test__
182 {
183 import assert ;
184 if ! ( --quiet in [ modules.peek : ARGV ] )
185 {
186 ECHO os: name= [ name ] ;
187 ECHO os: version= [ version ] ;
188 }
189 assert.true name ;
190 }