# -- Top Makefile for all ot the standalone diagnostics --
#

# ------------   MACROS --------------
#
# -- WHERE TO INSTALL DIAGNOSTICS 
IDIR=	/n/test

#MACHINES=	V20 V25 V30 VQX
MACHINES=	V20 V25 V30
# -- MACHINES 
#	the order must match the "ON_" order in sadie.c, and the 
#   *mach[] in (makeimage.c, maketape.c), for tape drives (for autoboot).
#	Dont change the order!!!, just add to the end...
#	NMACHTYPES in sadhi.h must be changed. 
#
#	V20- VMEbus 68020 cpu card
#	V25- VMEbus 68020 cpu card with modified address map and increased speed
#	VQX- Torch Board
#	V30- VMEbus 68030 cpu card

SADIEFILES= 	V20 V25 Q10 V10 V30
# VQX
#SADIEFILES= 	V20 V25 V30 
# -- SADIEFILES These are the machines for which there must be a "sadie"
# file on the tape.  They must be written in the order shown to maintain
# boot prom compatibility.  Each machine's boot prom expects a bootable
# sadie file in the position shown.  For those architectures not currently
# supported, a "dummy" sadie file is written to the tape simply to 
# maintain positioning.  

MINI_ROOT=	/@mark/usr/tmp/MINI_ROOT
TAPE=		/dev/nrmt0

# -- Make targets ----------

all:
	(cd tools ; make)
	(cd V20 ; make)
	(cd V25 ; make)
	(cd V30 ; make)
#	(cd VQX ; make)
depend:
	(cd tools ; make depend)
	(cd V20 ; make depend)
	(cd V25 ; make depend)
	(cd V30 ; make depend)
	(cd VQX ; make depend)
clean:
	(cd tools ; make clean)
	(cd V20 ; make clean)
	(cd V25 ; make clean)
	(cd V30 ; make clean)
	(cd VQX ; make clean)
	-rm -f rslts rslts.depend a.out core

tools:	FRC
	(cd tools ; make)
V20:	FRC
	(cd V20 ; make)
V25:	FRC
	(cd V25 ; make)
V30:	FRC
	(cd V30 ; make)
VQX:	FRC
	(cd VQX ; make)

FRC:

# Extract diagnostics used from sadie.c, and make tape. 
# KLUDGE: Some of the diagnostics are not 'made' in this directory, they are 
# copied down into their machine directory.
#	-for i in ${MACHINES}; do (cp GIP.$$i $$i/gip); done
DIAG_IMAGE:	sadie.c all
	./tools/makeimage > DIAG_IMAGE \
		`sed <sadie.c -n -e '/BEGIN:/,/END:/ s/.*"\\(.*\\)".*/\\1/p'`

boot_tape:	all
	Maketape ${TAPE} "${MACHINES}" install ${MINI_ROOT} 9 

diag_tape: 	DIAG_IMAGE dt_list1
	Maketape ${TAPE} "${SADIEFILES}" sadie DIAG_IMAGE 8
	tar cf ${TAPE} `cat dt_list1`
	sleep 10
	mt -f ${TAPE} rew

dt_list:	sadie.c
	awk '/BEGIN:/,/END:/ {if (length($$2) > 0) print $$2}' sadie.c | \
		sed -e 's/\"//g' -e 's/,//' -e 's/BEGIN://' -e 's/END://' | \
		awk '{printf "%s\n", $$1}' > dt_list

dt_list1:	Makefile dt_list V20/Makefile V25/Makefile V30/Makefile VQX/Makefile
	cat /dev/null > dt_list1
	-for i in ${MACHINES}; do \
		for j in `cat dt_list` ; do \
			(ls -l $$i/$$j | awk '{if (length($$8) > 0) \
				printf "%s\n", $$8}' >> dt_list1); done \
	done

dup_diag_tape:
	make diag_tape 

install:
	-for i in ${MACHINES}; do (cp -r $$i ${IDIR}; \
								rm -f ${IDIR}/*.o ${IDIR}/*.HEX); done
	-for i in ${MACHINES}; do (cp -r tools/xfer ${IDIR}/$$i); done
	@echo Done install.
