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 + )
16 for local var-name in $(variable-names)
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.
23 value ?= [ modules.peek .ENVIRON : $(var-name) ] ;
24 value ?= [ modules.peek .ENVIRON : $(var-name:U) ] ;
25 value ?= [ modules.peek .ENVIRON : $(var-name:L) ] ;
31 .name = [ modules.peek : OS ] ;
32 .platform = [ modules.peek : OSPLAT ] ;
33 .version = [ modules.peek : OSVER ] ;
36 local rule constant ( c : os ? )
39 # First look for a platform-specific name, then the general value.
40 local variables = .$(c)-$(os) .$(c) ;
41 local result = $($(variables)) ;
45 rule get-constant ( os ? )
47 # Find the name of the constant being accessed, which is equal to the name
49 local bt = [ BACKTRACE 1 ] ;
50 local rulename = [ MATCH ([^.]*)$ : $(bt[4]) ] ;
51 return [ constant $(rulename) : $(os) ] ;
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)
59 IMPORT $(__name__) : get-constant : $(__name__) : $(constant) ;
61 EXPORT $(__name__) : $(.constants) ;
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.
68 for local n in [ VARNAMES .ENVIRON ]
72 .executable-path-variable-NT = $(n) ;
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 ;
86 .shared-library-path-variable-CYGWIN = PATH ;
88 .shared-library-path-variable-MACOSX = DYLD_LIBRARY_PATH ;
90 .shared-library-path-variable-AIX = LIBPATH ;
92 .shared-library-path-variable-HAIKU = LIBRARY_PATH ;
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 ;
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 ;
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 = "" ;
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 ( )
119 return [ string.words [ environ [ constant executable-path-variable ] ]
120 : [ constant path-separator ] ] ;
124 # Initialize the list of home directories for the current user depending on the
128 local home = [ environ HOMEDRIVE HOMEPATH ] ;
129 .home-directories = $(home[1])$(home[2]) [ environ HOME ] [ environ USERPROFILE ] ;
133 .home-directories = [ environ HOME ] ;
137 # Can't use 'constant' mechanism because it only returns 1-element values.
138 rule home-directories ( )
140 return $(.home-directories) ;
144 # Return the string needed to represent the expansion of the named shell
146 rule expand-variable ( variable )
148 local prefix = [ constant expand-variable-prefix ] ;
149 local suffix = [ constant expand-variable-suffix ] ;
150 return $(prefix)$(variable)$(suffix) ;
154 # Returns true if running on windows, whether in cygwin or not.
158 if [ modules.peek : NT ]
162 else if [ modules.peek : UNIX ]
164 switch [ modules.peek : JAMUNAME ]
179 if [ modules.peek : VMS ]
187 if ! [ on-windows ] && ! [ on-vms ]
202 if ! ( --quiet in [ modules.peek : ARGV ] )
204 ECHO os: name= [ name ] ;
205 ECHO os: version= [ version ] ;