110185Seric.vanhensbergen@arm.com# Copyright (c) 2010 ARM Limited
210185Seric.vanhensbergen@arm.com# All rights reserved.
310185Seric.vanhensbergen@arm.com#
410185Seric.vanhensbergen@arm.com# The license below extends only to copyright in the software and shall
510185Seric.vanhensbergen@arm.com# not be construed as granting a license to any other intellectual
610185Seric.vanhensbergen@arm.com# property including but not limited to intellectual property relating
710185Seric.vanhensbergen@arm.com# to a hardware implementation of the functionality of the software
810185Seric.vanhensbergen@arm.com# licensed hereunder.  You may use the software subject to the license
910185Seric.vanhensbergen@arm.com# terms below provided that you ensure that this notice is replicated
1010185Seric.vanhensbergen@arm.com# unmodified and in its entirety in all distributions of the software,
1110185Seric.vanhensbergen@arm.com# modified or unmodified, in source code or in binary form.
1210185Seric.vanhensbergen@arm.com#
1310185Seric.vanhensbergen@arm.com# Copyright (c) 2005-2006 The Regents of The University of Michigan
1410185Seric.vanhensbergen@arm.com# All rights reserved.
1510185Seric.vanhensbergen@arm.com#
1610185Seric.vanhensbergen@arm.com# Redistribution and use in source and binary forms, with or without
1710185Seric.vanhensbergen@arm.com# modification, are permitted provided that the following conditions are
1810185Seric.vanhensbergen@arm.com# met: redistributions of source code must retain the above copyright
1910185Seric.vanhensbergen@arm.com# notice, this list of conditions and the following disclaimer;
2010185Seric.vanhensbergen@arm.com# redistributions in binary form must reproduce the above copyright
2110185Seric.vanhensbergen@arm.com# notice, this list of conditions and the following disclaimer in the
2210185Seric.vanhensbergen@arm.com# documentation and/or other materials provided with the distribution;
2310185Seric.vanhensbergen@arm.com# neither the name of the copyright holders nor the names of its
2410185Seric.vanhensbergen@arm.com# contributors may be used to endorse or promote products derived from
2510185Seric.vanhensbergen@arm.com# this software without specific prior written permission.
2610185Seric.vanhensbergen@arm.com#
2710185Seric.vanhensbergen@arm.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2810185Seric.vanhensbergen@arm.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2910185Seric.vanhensbergen@arm.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3010185Seric.vanhensbergen@arm.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3110185Seric.vanhensbergen@arm.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3210185Seric.vanhensbergen@arm.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3310185Seric.vanhensbergen@arm.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3410185Seric.vanhensbergen@arm.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3510185Seric.vanhensbergen@arm.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3610185Seric.vanhensbergen@arm.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3710185Seric.vanhensbergen@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3810185Seric.vanhensbergen@arm.com#
3910185Seric.vanhensbergen@arm.com# Authors: Nathan Binkert
4010185Seric.vanhensbergen@arm.com#          Ali Saidi
4110185Seric.vanhensbergen@arm.com
4210185Seric.vanhensbergen@arm.com### If we are not compiling on an arm v8, we must use cross tools ###
4310185Seric.vanhensbergen@arm.comifneq ($(shell uname -m), aarch64)
4410185Seric.vanhensbergen@arm.comCROSS_COMPILE?=aarch64-linux-gnu-
4510185Seric.vanhensbergen@arm.comendif
4610185Seric.vanhensbergen@arm.comCC=$(CROSS_COMPILE)gcc
4710185Seric.vanhensbergen@arm.comAS=$(CROSS_COMPILE)as
4810185Seric.vanhensbergen@arm.comLD=$(CROSS_COMPILE)ld
4910185Seric.vanhensbergen@arm.comAR=$(CROSS_COMPILE)ar
5010185Seric.vanhensbergen@arm.com
5110185Seric.vanhensbergen@arm.comJC=javac
5210185Seric.vanhensbergen@arm.comJH=javah
5310185Seric.vanhensbergen@arm.comJR=jar
5410185Seric.vanhensbergen@arm.com### JDK_PATH must be set to build gem5OpJni
5510185Seric.vanhensbergen@arm.com#JDK_PATH=/path/to/jdk/version_number
5610185Seric.vanhensbergen@arm.com
5712157Sandreas.sandberg@arm.comCFLAGS=-O2 -I $(JDK_PATH)/include/ -I $(JDK_PATH)/include/linux \
5813103Skevin.brodsky@arm.com       -I../../include -march=armv8-a
5910185Seric.vanhensbergen@arm.comLDFLAGS=-static -L. -lm5
6010185Seric.vanhensbergen@arm.com
6112464Sjang.hanhwi@gmail.comLIB_OBJS=m5op_arm_A64.o m5_mmap.o
6210185Seric.vanhensbergen@arm.comOBJS=m5.o
6310185Seric.vanhensbergen@arm.comJNI_OBJS=m5op_arm_A64.o jni_gem5Op.o
6412464Sjang.hanhwi@gmail.comLUA_OBJS=lua_gem5Op.o m5op_arm_A64.o m5_mmap.o
6512464Sjang.hanhwi@gmail.com
6612464Sjang.hanhwi@gmail.com### Need to install lua5.1 library to compile gem5OpLua.so
6712464Sjang.hanhwi@gmail.comLUA_HEADER_INCLUDE=$(shell pkg-config --cflags lua51) -I/usr/include/x86_64-linux-gnu
6810185Seric.vanhensbergen@arm.com
6910185Seric.vanhensbergen@arm.comall: libm5.a m5
7010185Seric.vanhensbergen@arm.com
7110185Seric.vanhensbergen@arm.com%.o: %.S
7210185Seric.vanhensbergen@arm.com	$(CC) $(CFLAGS) -o $@ -c $<
7310185Seric.vanhensbergen@arm.com
7410185Seric.vanhensbergen@arm.com%.o: %.c
7510185Seric.vanhensbergen@arm.com	$(CC)  $(CFLAGS) -o $@ -c $<
7610185Seric.vanhensbergen@arm.com
7710185Seric.vanhensbergen@arm.comm5: $(OBJS) libm5.a
7812464Sjang.hanhwi@gmail.com	$(CC) -o $@ $^ $(LDFLAGS)
7910185Seric.vanhensbergen@arm.com
8010185Seric.vanhensbergen@arm.comlibm5.a: $(LIB_OBJS)
8112464Sjang.hanhwi@gmail.com	$(AR) rcs $@ $^
8210185Seric.vanhensbergen@arm.com
8310185Seric.vanhensbergen@arm.comgem5OpJni: gem5OpJni.jar $(JNI_OBJS)
8410185Seric.vanhensbergen@arm.com	$(CC) --shared -o lib$@.so $(JNI_OBJS)
8510185Seric.vanhensbergen@arm.com
8610185Seric.vanhensbergen@arm.comgem5OpJni.jar:
8710185Seric.vanhensbergen@arm.com	$(JC) jni/gem5Op.java; \
8810185Seric.vanhensbergen@arm.com	$(JH) jni.gem5Op; \
8910185Seric.vanhensbergen@arm.com	$(JR) cvf $@ jni/*.class
9010185Seric.vanhensbergen@arm.com
9112464Sjang.hanhwi@gmail.comlua_gem5Op.o: lua_gem5Op.c
9212464Sjang.hanhwi@gmail.com	$(CC) $(CFLAGS) $(LUA_HEADER_INCLUDE) -o $@ -c $<
9312464Sjang.hanhwi@gmail.com
9412464Sjang.hanhwi@gmail.comgem5OpLua.so: $(LUA_OBJS)
9512464Sjang.hanhwi@gmail.com	$(CC) $(CFLAGS) $^ -o $@ -shared
9612464Sjang.hanhwi@gmail.com
9710185Seric.vanhensbergen@arm.comclean:
9812464Sjang.hanhwi@gmail.com	rm -f *.o m5 libgem5OpJni.so gem5OpJni.jar jni/*.class libm5.a gem5OpLua.so
99