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 ;
79 .shared-library-path-variable = LD_LIBRARY_PATH ;
80 .path-separator = ":" ;
81 .expand-variable-prefix = $ ;
82 .expand-variable-suffix = "" ;
83 .executable-path-variable = PATH ;
84 .executable-suffix = "" ;
87 # Return a list of the directories in the PATH. Yes, that information is (sort
88 # of) available in the global module, but jam code can change those values, and
89 # it isn't always clear what case/capitalization to use when looking. This rule
90 # is a more reliable way to get there.
91 rule executable-path ( )
93 return [ string.words [ environ [ constant executable-path-variable ] ]
94 : [ constant path-separator ] ] ;
98 # Initialize the list of home directories for the current user depending on the
102 local home = [ environ HOMEDRIVE HOMEPATH ] ;
103 .home-directories = $(home[1])$(home[2]) [ environ HOME ] [ environ USERPROFILE ] ;
107 .home-directories = [ environ HOME ] ;
111 # Can't use 'constant' mechanism because it only returns 1-element values.
112 rule home-directories ( )
114 return $(.home-directories) ;
118 # Return the string needed to represent the expansion of the named shell
120 rule expand-variable ( variable )
122 local prefix = [ constant expand-variable-prefix ] ;
123 local suffix = [ constant expand-variable-suffix ] ;
124 return $(prefix)$(variable)$(suffix) ;
128 # Returns true if running on windows, whether in cygwin or not.
132 if [ modules.peek : NT ]
136 else if [ modules.peek : UNIX ]
138 switch [ modules.peek : JAMUNAME ]
165 if ! ( --quiet in [ modules.peek : ARGV ] )
167 ECHO os: name= [ name ] ;
168 ECHO os: version= [ version ] ;