SConsopts revision 13737
112817Sgabeblack@google.com# Copyright 2018 Google, Inc.
212817Sgabeblack@google.com#
312817Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without
412817Sgabeblack@google.com# modification, are permitted provided that the following conditions are
512817Sgabeblack@google.com# met: redistributions of source code must retain the above copyright
612817Sgabeblack@google.com# notice, this list of conditions and the following disclaimer;
712817Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright
812817Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the
912817Sgabeblack@google.com# documentation and/or other materials provided with the distribution;
1012817Sgabeblack@google.com# neither the name of the copyright holders nor the names of its
1112817Sgabeblack@google.com# contributors may be used to endorse or promote products derived from
1212817Sgabeblack@google.com# this software without specific prior written permission.
1312817Sgabeblack@google.com#
1412817Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1512817Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1612817Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1712817Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1812817Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1912817Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2012817Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2112817Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2212817Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2312817Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2412817Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2512817Sgabeblack@google.com#
2612817Sgabeblack@google.com# Authors: Gabe Black
2712817Sgabeblack@google.com
2812817Sgabeblack@google.comImport('*')
2912817Sgabeblack@google.com
3013737Sgabeblack@google.comfrom m5.util import compareVersions
3113737Sgabeblack@google.comfrom m5.util.terminal import termcap
3213737Sgabeblack@google.com
3313737Sgabeblack@google.comdef use_systemc_check(env, warn=False):
3413737Sgabeblack@google.com    if ('GCC_VERSION' in env and
3513737Sgabeblack@google.com            compareVersions(env['GCC_VERSION'], '5.0') < 0):
3613737Sgabeblack@google.com        if warn:
3713737Sgabeblack@google.com            print(termcap.Yellow + termcap.Bold +
3813737Sgabeblack@google.com                  'Warning: Systemc may not work on gcc versions less '
3913737Sgabeblack@google.com                  'than 5.0.' + termcap.Normal)
4013737Sgabeblack@google.com        return False
4113737Sgabeblack@google.com    elif env['PLATFORM'] == 'darwin':
4213737Sgabeblack@google.com        if warn:
4313737Sgabeblack@google.com            print(termcap.Yellow + termcap.Bold +
4413737Sgabeblack@google.com                  'Warning: Systemc may not work on Mac OS.' + termcap.Normal)
4513737Sgabeblack@google.com        return False
4613737Sgabeblack@google.com    return True
4713737Sgabeblack@google.com
4813737Sgabeblack@google.commain.AddMethod(use_systemc_check, 'UseSystemcCheck')
4913737Sgabeblack@google.com
5012817Sgabeblack@google.comsticky_vars.AddVariables(
5113737Sgabeblack@google.com    BoolVariable('USE_SYSTEMC', 'Enable SystemC API support',
5213737Sgabeblack@google.com                 main.UseSystemcCheck())
5312817Sgabeblack@google.com    )
5412817Sgabeblack@google.com
5512817Sgabeblack@google.comexport_vars.append('USE_SYSTEMC')
56