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)
11 # Return the value(s) of the given environment variable(s) at the time bjam was
13 rule environ ( variable-names + )
15 return [ modules.peek .ENVIRON : $(variable-names) ] ;
18 .name = [ modules.peek : OS ] ;
19 .platform = [ modules.peek : OSPLAT ] ;
20 .version = [ modules.peek : OSVER ] ;
23 local rule constant ( c : os ? )
26 # First look for a platform-specific name, then the general value.
27 local variables = .$(c)-$(os) .$(c) ;
28 local result = $($(variables)) ;
32 rule get-constant ( os ? )
34 # Find the name of the constant being accessed, which is equal to the name
36 local bt = [ BACKTRACE 1 ] ;
37 local rulename = [ MATCH ([^.]*)$ : $(bt[4]) ] ;
38 return [ constant $(rulename) : $(os) ] ;
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)
46 IMPORT $(__name__) : get-constant : $(__name__) : $(constant) ;
48 EXPORT $(__name__) : $(.constants) ;
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.
55 for local n in [ VARNAMES .ENVIRON ]
59 .executable-path-variable-NT = $(n) ;
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 ;
72 .shared-library-path-variable-CYGWIN = PATH ;
74 .shared-library-path-variable-MACOSX = DYLD_LIBRARY_PATH ;
76 .shared-library-path-variable-AIX = LIBPATH ;
78 .shared-library-path-variable-HAIKU = LIBRARY_PATH ;
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 ;
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 = "" ;
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 ( )
101 return [ string.words [ environ [ constant executable-path-variable ] ]
102 : [ constant path-separator ] ] ;
106 # Initialize the list of home directories for the current user depending on the
110 local home = [ environ HOMEDRIVE HOMEPATH ] ;
111 .home-directories = $(home[1])$(home[2]) [ environ HOME ] [ environ USERPROFILE ] ;
115 .home-directories = [ environ HOME ] ;
119 # Can't use 'constant' mechanism because it only returns 1-element values.
120 rule home-directories ( )
122 return $(.home-directories) ;
126 # Return the string needed to represent the expansion of the named shell
128 rule expand-variable ( variable )
130 local prefix = [ constant expand-variable-prefix ] ;
131 local suffix = [ constant expand-variable-suffix ] ;
132 return $(prefix)$(variable)$(suffix) ;
136 # Returns true if running on windows, whether in cygwin or not.
140 if [ modules.peek : NT ]
144 else if [ modules.peek : UNIX ]
146 switch [ modules.peek : JAMUNAME ]
161 if [ modules.peek : VMS ]
169 if ! [ on-windows ] && ! [ on-vms ]
184 if ! ( --quiet in [ modules.peek : ARGV ] )
186 ECHO os: name= [ name ] ;
187 ECHO os: version= [ version ] ;