17732SAli.Saidi@ARM.com# Copyright (c) 2010 ARM Limited
27732SAli.Saidi@ARM.com# All rights reserved.
37732SAli.Saidi@ARM.com#
47732SAli.Saidi@ARM.com# The license below extends only to copyright in the software and shall
57732SAli.Saidi@ARM.com# not be construed as granting a license to any other intellectual
67732SAli.Saidi@ARM.com# property including but not limited to intellectual property relating
77732SAli.Saidi@ARM.com# to a hardware implementation of the functionality of the software
87732SAli.Saidi@ARM.com# licensed hereunder.  You may use the software subject to the license
97732SAli.Saidi@ARM.com# terms below provided that you ensure that this notice is replicated
107732SAli.Saidi@ARM.com# unmodified and in its entirety in all distributions of the software,
117732SAli.Saidi@ARM.com# modified or unmodified, in source code or in binary form.
127732SAli.Saidi@ARM.com#
137732SAli.Saidi@ARM.com# Copyright (c) 2005-2006 The Regents of The University of Michigan
147732SAli.Saidi@ARM.com# All rights reserved.
157732SAli.Saidi@ARM.com#
167732SAli.Saidi@ARM.com# Redistribution and use in source and binary forms, with or without
177732SAli.Saidi@ARM.com# modification, are permitted provided that the following conditions are
187732SAli.Saidi@ARM.com# met: redistributions of source code must retain the above copyright
197732SAli.Saidi@ARM.com# notice, this list of conditions and the following disclaimer;
207732SAli.Saidi@ARM.com# redistributions in binary form must reproduce the above copyright
217732SAli.Saidi@ARM.com# notice, this list of conditions and the following disclaimer in the
227732SAli.Saidi@ARM.com# documentation and/or other materials provided with the distribution;
237732SAli.Saidi@ARM.com# neither the name of the copyright holders nor the names of its
247732SAli.Saidi@ARM.com# contributors may be used to endorse or promote products derived from
257732SAli.Saidi@ARM.com# this software without specific prior written permission.
267732SAli.Saidi@ARM.com#
277732SAli.Saidi@ARM.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
287732SAli.Saidi@ARM.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
297732SAli.Saidi@ARM.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
307732SAli.Saidi@ARM.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
317732SAli.Saidi@ARM.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
327732SAli.Saidi@ARM.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
337732SAli.Saidi@ARM.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
347732SAli.Saidi@ARM.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
357732SAli.Saidi@ARM.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
367732SAli.Saidi@ARM.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
377732SAli.Saidi@ARM.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
387732SAli.Saidi@ARM.com#
397732SAli.Saidi@ARM.com# Authors: Nathan Binkert
407732SAli.Saidi@ARM.com#          Ali Saidi
417732SAli.Saidi@ARM.com
429821Satgutier@umich.edu### If we are not compiling on an arm, we must use cross tools ###
439192SAli.Saidi@ARM.comifneq ($(shell uname -m), armv7l)
449192SAli.Saidi@ARM.comCROSS_COMPILE?=arm-linux-gnueabi-
457732SAli.Saidi@ARM.comendif
467732SAli.Saidi@ARM.comCC=$(CROSS_COMPILE)gcc
477732SAli.Saidi@ARM.comAS=$(CROSS_COMPILE)as
487732SAli.Saidi@ARM.comLD=$(CROSS_COMPILE)ld
499333Sjames.clarkson@arm.comAR=$(CROSS_COMPILE)ar
507732SAli.Saidi@ARM.com
518547Sprakash.ramrakhyani@arm.comJC=javac
528547Sprakash.ramrakhyani@arm.comJH=javah
538547Sprakash.ramrakhyani@arm.comJR=jar
548547Sprakash.ramrakhyani@arm.com### JDK_PATH must be set to build gem5OpJni
558547Sprakash.ramrakhyani@arm.com#JDK_PATH=/path/to/jdk/version_number
568547Sprakash.ramrakhyani@arm.com
5712157Sandreas.sandberg@arm.comCFLAGS=-O2 -I $(JDK_PATH)/include/ -I $(JDK_PATH)/include/linux \
5813103Skevin.brodsky@arm.com       -I../../include -march=armv7-a
5910151Satgutier@umich.eduLDFLAGS=-L. -lm5 -static
608547Sprakash.ramrakhyani@arm.com
6112464Sjang.hanhwi@gmail.comLIB_OBJS=m5op_arm.o m5_mmap.o
629333Sjames.clarkson@arm.comOBJS=m5.o
638547Sprakash.ramrakhyani@arm.comJNI_OBJS=m5op_arm.o jni_gem5Op.o
6412464Sjang.hanhwi@gmail.comLUA_OBJS=lua_gem5Op.o m5op_arm.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) \
6812464Sjang.hanhwi@gmail.com	-I/usr/include/x86_64-linux-gnu
697732SAli.Saidi@ARM.com
709333Sjames.clarkson@arm.comall: libm5.a m5
717732SAli.Saidi@ARM.com
727732SAli.Saidi@ARM.com%.o: %.S
737732SAli.Saidi@ARM.com	$(CC) $(CFLAGS) -o $@ -c $<
747732SAli.Saidi@ARM.com
757732SAli.Saidi@ARM.com%.o: %.c
767732SAli.Saidi@ARM.com	$(CC)  $(CFLAGS) -o $@ -c $<
777732SAli.Saidi@ARM.com
789685Sandreas@sandberg.pp.sem5: $(OBJS) libm5.a
7912464Sjang.hanhwi@gmail.com	$(CC) -o $@ $^ $(LDFLAGS)
809333Sjames.clarkson@arm.com
819333Sjames.clarkson@arm.comlibm5.a: $(LIB_OBJS)
8212464Sjang.hanhwi@gmail.com	$(AR) rcs $@ $^
837732SAli.Saidi@ARM.com
848547Sprakash.ramrakhyani@arm.comgem5OpJni: gem5OpJni.jar $(JNI_OBJS)
858547Sprakash.ramrakhyani@arm.com	$(CC) --shared -o lib$@.so $(JNI_OBJS)
868547Sprakash.ramrakhyani@arm.com
878547Sprakash.ramrakhyani@arm.comgem5OpJni.jar:
888547Sprakash.ramrakhyani@arm.com	$(JC) jni/gem5Op.java; \
898547Sprakash.ramrakhyani@arm.com	$(JH) jni.gem5Op; \
908547Sprakash.ramrakhyani@arm.com	$(JR) cvf $@ jni/*.class
918547Sprakash.ramrakhyani@arm.com
9212464Sjang.hanhwi@gmail.comlua_gem5Op.o: lua_gem5Op.c
9312464Sjang.hanhwi@gmail.com	$(CC) $(CFLAGS) $(LUA_HEADER_INCLUDE) -o $@ -c $< -fPIC
9412464Sjang.hanhwi@gmail.com
9512464Sjang.hanhwi@gmail.comgem5OpLua.so: $(LUA_OBJS)
9612464Sjang.hanhwi@gmail.com	$(CC) $(CFLAGS) $^ -o $@ -shared
9712464Sjang.hanhwi@gmail.com
987732SAli.Saidi@ARM.comclean:
9910151Satgutier@umich.edu	rm -f *.o m5 libgem5OpJni.so gem5OpJni.jar jni/*.class libm5.a \
10012464Sjang.hanhwi@gmail.com	jni_gem5Op.h gem5OpLua.so
101