#!smake -k
#
# Makefile for RSP verification application test suite.
#

PRDEPTH = ../..

include $(PRDEPTH)/PRdefs

APP =		rspverif

OPTIMIZER =	-g

TARGETS =	rom

EMULATE	= 	$(ROOT)/usr/sbin/emulate

TEXHFILES =

HFILES =	rspverif.h

CODEFILES =	rspverif.c main.c
CODEOBJECTS =	$(CODEFILES:.c=.o)

DATAFILES =	dynamic.c zbuffer.c init.c static.c cfb.c
DATAOBJECTS =	 $(GENHFILES) $(DATAFILES:.c=.o)

CODESEGMENT =	codesegment.o

OBJECTS =	$(CODESEGMENT) $(DATAOBJECTS)

LCINCS =	-I. -I$(ROOT)/usr/include/PR 
LCOPTS =	-fullwarn -non_shared -G 0

LDIRT  =	$(APP) rspverif $(GENHFILES) InData/test*Z $(TEXHFILES)

LDFLAGS =	$(MKDEPOPT) -nostdlib -L$(ROOT)/usr/lib -L$(ROOT)/usr/lib/PR \
			-lem -lultra_em

default:	$(TARGETS)

include $(COMMONRULES)

#
# what does it mean to 'install' this thing?
#
install:	default
		$(INSTALL) -m 444 -F /usr/src/PR/$(APP) rspverif \
			$(HFILES) $(CODEFILES) $(DATAFILES) Makefile spec

$(CODESEGMENT):	$(CODEOBJECTS)
		$(LD) -o $(CODESEGMENT) -r $(CODEOBJECTS) $(LDFLAGS)

$(OBJECTS): $(HFILES)

#
# This must depend on the generated h-files, which in turn depend
# on the cases utility. If we don't do this, smake fails.
#
static.o: $(GENHFILES)

rom $(APP):	spec $(OBJECTS) $(MAKEROM)
		$(MAKEROM) -e -r rom spec

#
# ADD TEST CASE:
#
# Note: due to fopen() restrictions in the rsp simulator, the
# directory you send the output to must exist before running...
#

NIGHTLY_REGRESSION_TEST_ARCHIVE =

OTHER_TESTS_ARCHIVE =

NIGHTLY_REGRESSION_TESTS        = ${NIGHTLY_REGRESSION_TEST_ARCHIVE:R:R:R:R:T}
NIGHTLY_REGRESSION_TEST_TARGETS = ${NIGHTLY_REGRESSION_TEST_ARCHIVE:R}
OTHER_TESTS                     = ${OTHER_TESTS_ARCHIVE:R:R:R:R:T}
OTHER_TESTS_TARGETS             = ${OTHER_TESTS_ARCHIVE:R}
TESTS                           = ${OTHER_TESTS} ${NIGHTLY_REGRESSION_TESTS}

#
# Header file build rules
#

RGBA16grid.h: Texture/grid.rgb
	$(RGB2C) -m RGBA16grid Texture/grid.rgb > RGBA16grid.h

IA8phong.h: Texture/phong.rgba
	$(RGB2C) -m IA8phong -s 8 -f IA Texture/phong.rgba > IA8phong.h


#
# Anti-aliased
#
test000:                        InData/test000.0.rdp.Z

InData/test000.0.rdp.Z:        $(APP)
	$(EMULATE) -n -s -a "-m -a -o 0 -n InData/test000" $(APP) rom
	compress -f InData/test000*.rdp

test001:			InData/test001.1.rdp

InData/test001.1.rdp:        $(APP)
	emulate -e -s -a "-a -o 1 -f 1 -n InData/test01 -m" rdpverif rom 
	uncompress InData/test01.1.mem.Z
	rdp_c -i test01.1 -m test01.1 -z -v -e

test002:			InData/test002.2.rdp

InData/test002.2.rdp:        $(APP)
	emulate -e -s -a "-a -o 2 -f 2 -n InData/test02 -m" rdpverif rom 
	uncompress InData/test02.2.mem.Z
	rdp_c -i test02.2 -m test02.2 -z -v -e

test003:			InData/test003.3.rdp

InData/test003.3.rdp:        $(APP)
	emulate -e -s -a "-t -a -o 3 -f 3 -n InData/test03 -m" rdpverif rom 
	uncompress InData/test03.3.mem.Z
	rdp_c -i test03.3 -m test03.3 -z -v -e

test004:			InData/test004.4.rdp

InData/test004.4.rdp:        $(APP)
	emulate -e -s -a "-t -a -o 4 -f 4 -n InData/test04 -m" rdpverif rom 
	uncompress InData/test04.4.mem.Z
	rdp_c -i test04.4 -m test04.4 -z -v -e

test005:			InData/test005.5.rdp

InData/test005.5.rdp:        $(APP) I4bump.h
	emulate -e -s -a "-t -a -o 5 -f 5 -n InData/test05 -m" rdpverif rom 
	uncompress InData/test05.5.mem.Z
	rdp_c -i test05.5 -m test05.5 -z -v -e

test006:			InData/test006.6.rdp

InData/test006.6.rdp:        $(APP) I4bump.h
	emulate -e -s -a "-t -a -o 6 -f 6 -n InData/test06 -m" rdpverif rom 
	uncompress InData/test06.6.mem.Z
	rdp_c -i test06.6 -m test06.6 -z -v -e

test007:			InData/test007.7.rdp

InData/test007.7.rdp:        $(APP) I4bump.h
	emulate -e -s -a "-t -a -o 7 -f 7 -n InData/test07 -m" rdpverif rom 
	uncompress InData/test07.7.mem.Z
	rdp_c -i test07.7 -m test07.7 -z -v -e

test008:			InData/test008.8.rdp

InData/test008.8.rdp:        $(APP) I4bump.h
	emulate -e -s -a "-t -a -o 8 -f 8 -n InData/test08 -m" rdpverif rom 
	uncompress InData/test08.8.mem.Z
	rdp_c -i test08.8 -m test08.8 -z -v -e

test009:			InData/test009.9.rdp

InData/test009.9.rdp:        $(APP) I4bump.h
	emulate -e -s -a "-t -a -o 9 -f 9 -n InData/test09 -m" rdpverif rom 
	uncompress InData/test09.9.mem.Z
	rdp_c -i test09.9 -m test09.9 -z -v -e

test010:			InData/test010.10.rdp

InData/test010.10.rdp:        $(APP) I4bump.h
	emulate -e -s -a "-t -a -o 10 -f 10 -n InData/test10 -m" rdpverif rom 
	uncompress InData/test10.10.mem.Z
	rdp_c -i test10.10 -m test10.10 -z -v -e

test011:			InData/test011.11.rdp

InData/test011.11.rdp:        $(APP) I4bump.h
	emulate -e -s -a "-t -a -o 11 -f 11 -n InData/test11 -m" rdpverif rom 
	uncompress InData/test11.11.mem.Z
	rdp_c -i test11.11 -m test11.11 -z -v -e

test012:			InData/test012.12.rdp

InData/test012.12.rdp:        $(APP) I4bump.h
	emulate -e -s -a "-t -a -o 12 -f 12 -n InData/test12 -m" rdpverif rom 
	uncompress InData/test12.12.mem.Z
	rdp_c -i test12.12 -m test12.12 -z -v -e

test013:			InData/test013.13.rdp

InData/test013.13.rdp:        $(APP) I4bump.h
	emulate -e -s -a "-t -a -o 13 -f 13 -n InData/test13 -m" rdpverif rom 
	uncompress InData/test13.13.mem.Z
	rdp_c -i test13.13 -m test13.13 -z -v -e


tests:	$(TESTS)

#
# Run a smaller subset of the total test coverage on a nightly basis.
#
nightly_regression: $(NIGHTLY_REGRESSION_TESTS)

#
# Only checkin archived versions of the .rdp files on a periodic, 
# on-demand basis (e.g. whenever an RSP simulator/ucode change affects the 
# output files mumble.rdp).
#
# Otherwise we'll pollute the source tree with unnecessary copies
# of these data files.  The intent is to provide a way to resurrect data
# files for downstream simulation purposes whenever the output files generated
# by the rsp sim environment causes a hiccup downstream.
#
periodic_checkin: $(NIGHTLY_REGRESSION_TESTS)
	$(ROOT)/PR/tools/scripts/copyToArchive $(NIGHTLY_REGRESSION_TEST_TARGETS)
