# ************************************************************************************************
# * FILE PURPOSE: Build the testsmall code
# ************************************************************************************************
# * FILE NAME: makefile
# *
# * DESCRIPTION: Builds the testsmall images
# *
# *	   invokation: make DEVICE=[hawking] ENDIAN=[little | big] ARM_ENDIAN=[little | big]
# *
# ************************************************************************************************


ifeq ($(DEVICE),hawking)

 NGEMS=   8
 NARMS=   4
 MAXGEMS= 8
 MAXARMS= 4

 LNKFILE_GEM=  hawking_gem.cmd
 LNKFILE_ARM=  hawking_arm.cmd
 RMDFILE=      hawking_arm.rmd

endif

ifdef RESTRICT_DSP_CORES
 NGEMS= $(RESTRICT_DSP_CORES)
endif

export NGEMS
export NARMS
export MAXGEMS
export MAXARMS


.PHONY: genGem genArm


# unfortunately must build the arm code little endian always since CCS will not allow loading
# big endian symbols even when the endian is running in big endian mode
#  The order of genArmLittle and genArm is important!!
all:  gen_cdefdep util genGem genArmLittle genArm testsmall.btbl.ccs

testsmall.btbl.ccs: testsmall_gem.btbl.ccs testsmall_arm.btbl.ccs
	../util/ccsutil/ccsCatBtbl testsmall_gem.btbl.ccs testsmall_arm.btbl.ccs -outfile $@
	cp hold.out testsmall_arm.out

genGem:
	make -f makeGem LNKFILE=$(LNKFILE_GEM) ENDIAN=$(ENDIAN) ARM_ENDIAN=$(ARM_ENDIAN)

genArm:
	make -f makeArm LNKFILE=$(LNKFILE_ARM) RMDFILE=$(RMDFILE) ENDIAN=$(ENDIAN) ARM_ENDIAN=$(ARM_ENDIAN)
	cp testsmall_arm.out hold.out
	sleep 1

genArmLittle:
	make -f makeArm LNKFILE=$(LNKFILE_ARM) RMDFILE=$(RMDFILE) ENDIAN=$(ENDIAN) ARM_ENDIAN=little
	cp testsmall_arm.out testsmall_arm_little.out
	sleep 1


util:
	make -C ../util/ccsutil


gen_cdefdep:
	@echo $(DEVICE) $(ENDIAN) $(ARM_ENDIAN) $(NGEMS) > cdefdep.tmp
	@sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else cp cdefdep.tmp cdefdep ; fi '
	

