1 # Copyright 2020 Google, Inc.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met: redistributions of source code must retain the above copyright
6 # notice, this list of conditions and the following disclaimer;
7 # redistributions in binary form must reproduce the above copyright
8 # notice, this list of conditions and the following disclaimer in the
9 # documentation and/or other materials provided with the distribution;
10 # neither the name of the copyright holders nor the names of its
11 # contributors may be used to endorse or promote products derived from
12 # this software without specific prior written permission.
14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 m5op = '${VARIANT}/m5op.S'
38 # The m5 library for use in other C/C++ programs.
40 libm5 = env.StaticLibrary('out/m5', [ m5op, m5_mmap ])
44 # The m5 stand alone command line utility.
46 m5_bin_env = env.Clone()
47 m5_bin_env.Append(LINKFLAGS=[ '-static' ])
48 m5_bin = m5_bin_env.Program('out/m5', [ m5, m5_mmap, libm5 ])
51 # The shared version of the m5 op call sights, used by mutliple targets below.
52 m5op_shared = env.SharedObject(m5op)
56 # A wrapper to make the m5 ops available in Java through the JNI.
58 java_env = env.Clone()
59 # SCons provides Java and JavaH builders, but the JavaH builder assumes
60 # that the javah tool exists. Java has dropped that tool in favor of a -h
61 # option on javac which the Java builder doesn't know how to use. To get
62 # around this, we set up our own builder which does the "right thing" here.
63 java_env.Command([ 'jni_gem5Op.h', 'out/gem5OpJni.jar' ],
65 [ '${JAVAC} ${JAVACFLAGS} -d ${OUT} ${SOURCES} -h ${CWD}',
66 '${JAR} cvf ${TARGETS[1]} ${JNI_DIR}/*.class' ],
67 JNI_DIR=Dir('out').Dir('jni'),
68 OUT=Dir('out'), CWD=Dir('.'))
69 # Set include paths to the C headers from the JDK which scons found for us.
70 java_env.Append(CPPPATH='${JAVAINCLUDES}')
71 java_env.SharedLibrary('out/gem5OpJni', [ jni, m5op_shared ])
76 # A wrapper to make the m5 ops available in lua version 5.1.
79 # Extract the include paths needed for lua51 using pkg-config.
80 lua_env.ParseConfig('pkg-config --cflags lua51')
81 lib = lua_env.SharedLibrary('out/gem5OpLua', [ lua, m5op_shared, m5_mmap ])