#-----------------------------------------------------------------------------
#	Makefile for libasv.a (Intel object) and libasvg.a (GNU/960 object).
#
# $Id: Makefile,v 1.11 89/12/10 14:06:52 chrisb Exp $
#
# This library provides routines specific for running on an Intel ASV960 board
# (with 80960CA).
#-----------------------------------------------------------------------------

LD_FILES= asvnindy.ld asvrom.ld

# The following are names of sentinel files.  The presence of a file indicates
# what format object file was last built in the current directory.  Only one
# format can be present at a time:  when a change of format is required, all
# objects are first deleted, so as to avoid mixing formats within a library.
#
GFLAG = .gnu_objs
IFLAG = .intel_objs

ALL_FLAGS= ${GFLAG} ${IFLAG}

# "-S" and separate assembly step
# can go away when ic960 supports -ACA switch.
#
.c.o:
	${CC} ${CFLAGS} -S $<
	${AS} ${ASFLAGS} -o $*.o $*.s; rm $*.s

.s.o:
	${AS} ${ASFLAGS} -o $*.o $*.s

# Unpleasant consequence of this makefile organization (supporting 2 object
# formats) is that you can only say "make x.a".  An attempt to say "make x.o"
# will come in at too low a level -- before all of the variables have been
# defined -- and get you the host assembler or archiver.  The "uhuh" entries
# here will at least cause you to bomb instead of building the wrong stuff.
#
CC	= uhuh
AS	= uhuh
AR	= uhuh
ARFLAGS	= rs

OBJS	= asvasms.o copyrght.o eat_time.o time_asv.o noint_time.o ver960.o

all:	libasv.a libasvg.a

libasvg.a:	FORCE
	make ${GFLAG} lib		\
		CC=gcc960		\
		CFLAGS='-O2 -g -ACA -c'	\
		AS=gas960 		\
		ASFLAGS=-ACA		\
		AR=gar960		\
		LIB=libasvg.a

libasv.a:	FORCE
	make ${IFLAG} lib		\
		CC=ic960		\
		CFLAGS='-O2 -ACA -c'	\
		AS=asm960 		\
		ASFLAGS=-ACA_A		\
		AR=arc960		\
		LIB=libasv.a

lib:	${OBJS}
	${AR} ${ARFLAGS} ${LIB} ${OBJS}


# Delete all local object files if they're not in the specified format,
# as indicated by the presence of the flag file ${GFLAG} or ${IFLAG}.
#
${GFLAG}:
	rm -f *.o ${ALL_FLAGS}
	touch ${GFLAG}

${IFLAG}:
	rm -f *.o ${ALL_FLAGS}
	touch ${IFLAG}

#-----------------------------------------------------------------------------
#		'STANDARD' GNU/960 TARGETS BELOW THIS POINT
#
# 'VERSION' file must be present and contain a string of the form "x.y"
#-----------------------------------------------------------------------------

ver960.c: FORCE
	rm -f ver960.c
	echo "char libasv_ver[]= \"libasv `cat VERSION`, `date`\";" > ver960.c


# This target should be invoked before building a new release.
# 'VERSION' file must be present and contain a string of the form "x.y"
#
roll:
	@V=`cat VERSION`		; \
	MAJ=`sed 's/\..*//' VERSION`	; \
	MIN=`sed 's/.*\.//' VERSION`	; \
	V=$$MAJ.`expr $$MIN + 1`	; \
	rm -f VERSION			; \
	echo $$V >VERSION		; \
	echo Version $$V

# Dummy target to force execution of dependent targets.
#
FORCE:

# 'G960BASE' should be defined at invocation

install_gnu:	libasvg.a
	mv -f libasvg.a ${G960BASE}/lib/libasvg.a 

install_intel:	libasv.a
	mv -f libasv.a ${G960BASE}/lib/libasv.a 
	cd ${G960BASE}/lib && rm -f ${LD_FILES}
	cp ${LD_FILES} ${G960BASE}/lib

install: install_gnu install_intel

clean:
	rm -f *.o *.a ${ALL_FLAGS}
