3 Tool-specific initialization for C++ on SunOS / Solaris.
5 There normally shouldn't be any need to import this module directly.
6 It will usually be imported through the generic SCons.Tool.Tool()
12 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
14 # Permission is hereby granted, free of charge, to any person obtaining
15 # a copy of this software and associated documentation files (the
16 # "Software"), to deal in the Software without restriction, including
17 # without limitation the rights to use, copy, modify, merge, publish,
18 # distribute, sublicense, and/or sell copies of the Software, and to
19 # permit persons to whom the Software is furnished to do so, subject to
20 # the following conditions:
22 # The above copyright notice and this permission notice shall be included
23 # in all copies or substantial portions of the Software.
25 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
26 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
27 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 __revision__ = "src/engine/SCons/Tool/sunc++.py 5023 2010/06/14 22:05:46 scons"
42 cplusplus = __import__('c++', globals(), locals(), [])
46 def get_package_info(package_name, pkginfo, pkgchk):
48 return package_info[package_name]
53 sadm_contents = open('/var/sadm/install/contents', 'r').read()
54 except EnvironmentError:
57 sadm_re = re.compile('^(\S*/bin/CC)(=\S*)? %s$' % package_name, re.M)
58 sadm_match = sadm_re.search(sadm_contents)
60 pathname = os.path.dirname(sadm_match.group(1))
63 p = subprocess.Popen([pkginfo, '-l', package_name],
64 stdout=subprocess.PIPE,
65 stderr=open('/dev/null', 'w'))
66 except EnvironmentError:
69 pkginfo_contents = p.communicate()[0]
70 version_re = re.compile('^ *VERSION:\s*(.*)$', re.M)
71 version_match = version_re.search(pkginfo_contents)
73 version = version_match.group(1)
77 p = subprocess.Popen([pkgchk, '-l', package_name],
78 stdout=subprocess.PIPE,
79 stderr=open('/dev/null', 'w'))
80 except EnvironmentError:
83 pkgchk_contents = p.communicate()[0]
84 pathname_re = re.compile(r'^Pathname:\s*(.*/bin/CC)$', re.M)
85 pathname_match = pathname_re.search(pkgchk_contents)
87 pathname = os.path.dirname(pathname_match.group(1))
89 package_info[package_name] = (pathname, version)
90 return package_info[package_name]
92 # use the package installer tool lslpp to figure out where cppc and what
93 # version of it is installed
95 cxx = env.subst('$CXX')
97 cppcPath = os.path.dirname(cxx)
103 pkginfo = env.subst('$PKGINFO')
104 pkgchk = env.subst('$PKGCHK')
106 for package in ['SPROcpl']:
107 path, version = get_package_info(package, pkginfo, pkgchk)
109 cppcPath, cppcVersion = path, version
112 return (cppcPath, 'CC', 'CC', cppcVersion)
115 """Add Builders and construction variables for SunPRO C++."""
116 path, cxx, shcxx, version = get_cppc(env)
118 cxx = os.path.join(path, cxx)
119 shcxx = os.path.join(path, shcxx)
121 cplusplus.generate(env)
125 env['CXXVERSION'] = version
126 env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS -KPIC')
127 env['SHOBJPREFIX'] = 'so_'
128 env['SHOBJSUFFIX'] = '.o'
131 path, cxx, shcxx, version = get_cppc(env)
133 cppc = os.path.join(path, cxx)
134 if os.path.exists(cppc):
140 # indent-tabs-mode:nil
142 # vim: set expandtab tabstop=4 shiftwidth=4: