Makefile.ALL 2.84 KB
#!gmake 

ifndef SIMTOOLS
SIMTOOLS = ../../..
endif

CPUSIM = mxs
include $(SIMTOOLS)/makedefs

TARGET = mxslib.a

VPATH = ..

#################################################################
# INCLUDES
#################################################################
INCS    = -I$(SIMTOOLS)/simos -I$(SIMTOOLS)/cpus/mipsy 
INCS   += -I$(SIMTOOLS)/cpus/mxs -I$(SIMTOOLS)/caches/2Level 
INCS   += -I$(SIMTOOLS)/caches 
INCS   += -I$(SIMTOOLS)/cpus/shared
INCS   += -I$(SIMTOOLS)/memsystems
INCS   += -I$(SIMTOOLS)/cpus/simos
INCS   += $(GLOBAL_INCS)


#################################################################
# DEFINES
#################################################################
#DEF1 = -DSIMOS -DMEMSTAT -DUSEREXIT -DDATA_HANDLING -DMIPSY_MXS 
DEF1 = -DSIMOS -DMEMSTAT -DUSEREXIT -DMIPSY_MXS 
DEF2 = -DNEED_OPTAB -DBREAKPOINT -DDEBUG_CHECKS -DTRACE
DEFS = $(DEF1) $(DEF2) $(GLOBAL_DEFS)

################################################################
# C and ASM FLAGS
################################################################
ASFLAGS	= $(GLOBAL_ASFLAGS) 
CFLAGS  = $(GLOBAL_CFLAGS)

CC_OPTS      = $(CFLAGS) $(INCS) $(DEFS)
AS_OPTS      = $(ASFLAGS) $(INCS) $(DEFS)

MXS_CSRCS    = ms.c ms_fetch.c ms_compile.c \
		ms_grad.c mc_opc.c ms_ldst.c ms_branch.c \
		ms_wrklst.c ms_divmul.c \
		ms_st_init.c ms_iprint.c ms_stats.c \
		ms_simos.c

MXS_M4SRCS   = ms_inst.m4

SIMOSCSRCS   = simos_interface.c r4k_cp0.c cpu.c debug.c fpu.c stats.c \
		cpu_interface.c print_insts.c smash_insts.c \
		dash_prefetch.c

MIPSY_C_TARGETS   = $(SIMOSCSRCS:.c=.o)
C_TARGETS         = $(MXS_CSRCS:.c=.o)
M4_TARGETS        = $(MXS_M4SRCS:.m4=.o)
TARGETS           = $(sort $(ASM_TARGETS) $(MIPSY_ASM_TARGETS) $(C_TARGETS) \
                        $(MIPSY_C_TARGETS) $(M4_TARGETS))

.PHONY: warn deps

default: warn
	@$(MAKE) -f ../Makefile.ALL SIMOS=1 deps
	@$(MAKE) -f ../Makefile.ALL SIMOS=1 INCLUDE_DEPS=1  $(TARGET)

$(TARGET): $(TARGETS)
	@echo "-> Updating $(TARGET)"
	$(AR) cru $(TARGET) $(TARGETS)

warn:
	@echo ""
	@echo "Making MXS"
	@echo "**********"
	@echo "  DEFS :   `$(FORMAT) $(DEFS)`"
	@echo "  CFLAGS : `$(FORMAT) $(CFLAGS)`"
	@echo ""

ms_stats.h: ../stats.awk ../ms.h
	nawk -f ../stats.awk ../ms.h > ../ms_stats.h	

$(C_TARGETS): %.o: %.c
	@echo "Compiling  $(<F)"
	$(CC) $(CC_OPTS) -c $< 

$(MIPSY_C_TARGETS): %.o: $(SIMTOOLS)/cpus/mipsy/%.c
	@echo "Compiling  $(<F)"
	$(CC) $(CC_OPTS) -c $< 

$(ASM_TARGETS): %.o: %.s
	@echo "Assembling $(<F)"
	$(AS) $(AS_OPTS) -c $< -o $@

$(MIPSY_ASM_TARGETS): %.o: $(SIMTOOLS)/cpus/mipsy/%.s
	@echo "Assembling $(<F)"
	$(AS) $(AS_OPTS) -c $< -o $@

$(M4_TARGETS): %.o: %.m4
	@echo "Macro-izing $(<F)"
	m4 $< > $*.c
	$(CC) $(CC_OPTS) -c $*.c

ms_stats.o: ms_stats.h

deps: ms_stats.h ${C_TARGETS:.o=.d}

%.d: %.c
	@echo "Finding dependencies of $(<F)"
	@$(CC) -M $(CC_OPTS) $< > $@

ifdef INCLUDE_DEPS
include ${C_TARGETS:.o=.d}
endif