# ####################################################
# This is the Makefile for building the nios32 ArchC model
# This file is automatically generated by ArchC
# WITHOUT WARRANTY OF ANY KIND, either express
# or implied.
# For more information on ArchC, please visit:   
# http://www.archc.org                           
#                                                
# The ArchC Team                                 
# Computer Systems Laboratory (LSC)              
# IC-UNICAMP                                     
# http://www.lsc.ic.unicamp.br                   
# ####################################################

# Variable that points to SystemC installation path.
SYSTEMC := /home/renarech/disciplinas/arqII/systemc-2.1.v1

# Variable that points to ArchC installation path
ARCHC :=/home/renarech/disciplinas/arqII/archc-2.0//bin
# Target Arch used by SystemC
TARGET_ARCH := linux

INC_DIR := -I. -I/home/renarech/disciplinas/arqII/archc-2.0//include/archc -I$(SYSTEMC)/include
LIB_DIR := -L. -L$(SYSTEMC)/lib-$(TARGET_ARCH) -L/home/renarech/disciplinas/arqII/archc-2.0//lib

LIB_SYSTEMC := -lsystemc
LIBS := $(LIB_SYSTEMC) -lm $(EXTRA_LIBS) -larchc
CC :=  g++

OPT :=  

DEBUG :=  -g

OTHER :=  -Wno-deprecated

CFLAGS := $(DEBUG) $(OPT) $(OTHER) 

MODULE := nios32

# These are the source files automatically generated by ArchC, that must appear in the SRCS variable
ACSRCS := $(MODULE)_arch_ref.cpp $(MODULE)_pipe_IF.cpp $(MODULE)_pipe_ID.cpp $(MODULE)_pipe_EX.cpp $(MODULE)_pipe_MEM.cpp $(MODULE)_pipe_WB.cpp $(MODULE).cpp

# These are the source files automatically generated by ArchC that are included by other files in ACSRCS.
ACINCS := $(MODULE)_isa_init.cpp

# These are the header files automatically generated by ArchC
ACHEAD := $(MODULE)_parms.H $(MODULE)_arch.H $(MODULE)_arch_ref.H $(MODULE)_isa.H $(MODULE)_bhv_macros.H $(MODULE)_fmt_regs.H $(MODULE)_pipe_IF.H $(MODULE)_pipe_ID.H $(MODULE)_pipe_EX.H $(MODULE)_pipe_MEM.H $(MODULE)_pipe_WB.H $(MODULE)_syscall.H $(MODULE).H $(MODULE)_stages_ref.H

# These are the source files provided by ArchC that must be compiled together with the ACSRCS.
# They are stored in the archc/src/aclib directory.
ACFILES := 

# These are the library files provided by ArchC.
# They are stored in the archc/lib directory.
ACLIBFILES := ac_decoder_rt.o ac_module.o ac_storage.o ac_utils.o ac_syscall.o

# These are the headers files provided by ArchC.
# They are stored in the archc/include directory.
ACFILESHEAD := $(ACFILES:.cpp=.H) $(ACLIBFILES:.o=.H) ac_sync_reg.H ac_regbank.H ac_debug_model.H ac_sighandlers.H ac_ptr.H ac_memport.H ac_arch.H ac_arch_dec_if.H ac_arch_ref.H ac_stage.H ac_syscall.H

# These are the source files provided by the user + ArchC sources.
SRCS := main.cpp $(ACSRCS) $(ACFILES) $(MODULE)_isa.cpp $(MODULE)_syscall.cpp

OBJS := $(SRCS:.cpp=.o)

EXE := $(MODULE).x

.SUFFIXES: .cc .cpp .o .x

all: $(addprefix /home/renarech/disciplinas/arqII/archc-2.0//include/archc/, $(ACFILESHEAD)) $(ACHEAD) $(ACFILES) $(EXE)

$(EXE): $(OBJS) $(SYSTEMC)/lib-$(TARGET_ARCH)/libsystemc.a
	$(CC) $(CFLAGS) $(INC_DIR) $(LIB_DIR) -o $@ $(OBJS) $(LIBS) 2>&1 | c++filt

# Copy from template if main.cpp not exist.
main.cpp:
	cp main.cpp.tmpl main.cpp

.cpp.o:
	$(CC) $(CFLAGS) $(INC_DIR) -c $<

.cc.o:
	$(CC) $(CFLAGS) $(INC_DIR) -c $<

clean:
	rm -f $(OBJS) *~ $(EXE) core *.o

model_clean:
	rm -f $(ACSRCS) $(ACHEAD) $(ACINCS) $(ACFILESHEAD) $(ACFILES) *.tmpl loader.ac

sim_clean: clean model_clean

distclean: sim_clean
	rm -f main.cpp Makefile.archc

