112027Sjungma@eit.uni-kl.de# Copyright (c) 2017, TU Dresden
212027Sjungma@eit.uni-kl.de# Copyright (c) 2017, University of Kaiserslautern
312027Sjungma@eit.uni-kl.de# All rights reserved.
412027Sjungma@eit.uni-kl.de
512027Sjungma@eit.uni-kl.de# Permission is hereby granted, free of charge, to any person obtaining a copy
612027Sjungma@eit.uni-kl.de# of this software and associated documentation files (the "Software"), to deal
712027Sjungma@eit.uni-kl.de# in the Software without restriction, including without limitation the rights
812027Sjungma@eit.uni-kl.de# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
912027Sjungma@eit.uni-kl.de# copies of the Software, and to permit persons to whom the Software is
1012027Sjungma@eit.uni-kl.de# furnished to do so, subject to the following conditions:
1112027Sjungma@eit.uni-kl.de#
1212027Sjungma@eit.uni-kl.de# The above copyright notice and this permission notice shall be included in
1312027Sjungma@eit.uni-kl.de# all copies or substantial portions of the Software.
1412027Sjungma@eit.uni-kl.de#
1512027Sjungma@eit.uni-kl.de# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1612027Sjungma@eit.uni-kl.de# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1712027Sjungma@eit.uni-kl.de# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1812027Sjungma@eit.uni-kl.de# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1912027Sjungma@eit.uni-kl.de# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2012027Sjungma@eit.uni-kl.de# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2112027Sjungma@eit.uni-kl.de# SOFTWARE.
2212027Sjungma@eit.uni-kl.de#
2312027Sjungma@eit.uni-kl.de# Authors: Christian Menard
2412027Sjungma@eit.uni-kl.de#          Matthias Jung
2512027Sjungma@eit.uni-kl.de
2612563Sgabeblack@google.comfrom __future__ import print_function
2712563Sgabeblack@google.com
2812027Sjungma@eit.uni-kl.deimport os
2912046Sgabeblack@google.comfrom m5.util.terminal import get_termcap
3012027Sjungma@eit.uni-kl.de
3112027Sjungma@eit.uni-kl.deImport('main')
3212046Sgabeblack@google.comsystemc = main.Clone()
3312027Sjungma@eit.uni-kl.de
3412046Sgabeblack@google.combuild_root = Dir('.').abspath
3512046Sgabeblack@google.comsrc_root = Dir('.').srcdir.abspath
3612027Sjungma@eit.uni-kl.de
3712046Sgabeblack@google.comsystemc.Prepend(CPPPATH=Dir('./src'))
3812046Sgabeblack@google.comsystemc.Prepend(CPATH=Dir('./src'))
3912027Sjungma@eit.uni-kl.de
4012046Sgabeblack@google.comsystemc.Prepend(CXXFLAGS=['-DSC_INCLUDE_FX'])
4112046Sgabeblack@google.comsystemc.Prepend(CFLAGS=['-DSC_INCLUDE_FX'])
4212027Sjungma@eit.uni-kl.de
4312046Sgabeblack@google.comconf = Configure(systemc,
4412046Sgabeblack@google.com                 conf_dir = os.path.join(build_root, '.scons_config'),
4512046Sgabeblack@google.com                 log_file = os.path.join(build_root, 'scons_config.log'))
4612027Sjungma@eit.uni-kl.de
4712046Sgabeblack@google.comif systemc['PLATFORM'] == 'darwin':
4812046Sgabeblack@google.com    systemc.Append(LINKFLAGS=['-undefined', 'dynamic_lookup'])
4912046Sgabeblack@google.com
5012046Sgabeblack@google.comarch = None
5112046Sgabeblack@google.comsystemc['COROUTINE_LIB'] = ''
5212046Sgabeblack@google.comif conf.CheckDeclaration('__i386__'):
5312046Sgabeblack@google.com    systemc['COROUTINE_LIB'] = 'qt'
5412046Sgabeblack@google.com    systemc['QT_ARCH'] = 'i386'
5512046Sgabeblack@google.com    arch = 'i386'
5612046Sgabeblack@google.comelif conf.CheckDeclaration('__x86_64__'):
5712046Sgabeblack@google.com    systemc['COROUTINE_LIB'] = 'qt'
5812046Sgabeblack@google.com    systemc['QT_ARCH'] = 'iX86_64'
5912046Sgabeblack@google.com    arch = 'x86_64'
6012046Sgabeblack@google.comelse:
6112046Sgabeblack@google.com    termcap = get_termcap(GetOption('use_colors'))
6212563Sgabeblack@google.com    print(termcap.Yellow + termcap.Bold +
6312563Sgabeblack@google.com          "Warning: Unrecognized architecture for systemc." + termcap.Normal)
6412046Sgabeblack@google.com
6512027Sjungma@eit.uni-kl.deconf.Finish()
6612027Sjungma@eit.uni-kl.de
6712046Sgabeblack@google.comif systemc['COROUTINE_LIB'] == 'pthreads':
6812046Sgabeblack@google.com    systemc.Prepend(CXXFLAGS=['-DSC_USE_PTHREADS'])
6912027Sjungma@eit.uni-kl.de
7012046Sgabeblack@google.comsystemc_files = []
7112046Sgabeblack@google.comdef SystemCSource(*args):
7212046Sgabeblack@google.com    for arg in args:
7312046Sgabeblack@google.com        systemc_files.append(systemc.File(arg))
7412027Sjungma@eit.uni-kl.de
7512046Sgabeblack@google.comif arch:
7612046Sgabeblack@google.com    for root, dirs, files in os.walk(src_root):
7712046Sgabeblack@google.com        if 'SConscript.sc' in files:
7812046Sgabeblack@google.com            build_dir = os.path.relpath(root, src_root)
7912046Sgabeblack@google.com            systemc.SConscript(os.path.join(root, 'SConscript.sc'),
8012046Sgabeblack@google.com                               exports=['systemc', 'SystemCSource'],
8112046Sgabeblack@google.com                               variant_dir=os.path.join(build_root, build_dir))
8212027Sjungma@eit.uni-kl.de
8312046Sgabeblack@google.com    systemc.Library('libsystemc', systemc_files)
8412046Sgabeblack@google.com    systemc.SharedLibrary('libsystemc', systemc_files)
8512046Sgabeblack@google.com
86