#	Makefile for libqt.a (Intel object) and libqtg.a (GNU/960 object)
#
# $Id: Makefile,v 1.5 89/12/10 14:09:11 chrisb Exp $
#
# This library provides routines specific for running on an Intel QT960 board
# (with 80960KB).

LD_FILES= flash.ld flrom.ld qtnindy.ld qtrom.ld

# The following are names of flag 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}

.c.o:
	${CC} ${CFLAGS} -c $<

.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.
#
ARCH	= -AKB

CC	= uhuh
AS	= uhuh
ASFLAGS	= ${ARCH}
AR	= uhuh
ARFLAGS	= rs
IPATH	= ../../../include

OBJS = copyrght.o dma.o eat_time.o flashlib.o qtasms.o time_qt.o ver960.o

all:	libqt.a libqtg.a

libqtg.a:	FORCE
	make ${GFLAG} lib				\
		CC=gcc960				\
		CFLAGS='-O2 -g ${ARCH} -I${IPATH}'	\
		AS=gas960 				\
		AR=gar960				\
		LIB=libqtg.a

libqt.a:	FORCE
	make ${IFLAG} lib 			\
		CC=ic960			\
		CFLAGS='-O2 ${ARCH} -I${IPATH}'	\
		AS=asm960 			\
		AR=arc960			\
		LIB=libqt.a

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


# Header file dependencies
#
dma.c:		${IPATH}/qtcommon.h
flashlib.c:	${IPATH}/qtcommon.h
timer_qt.c:	${IPATH}/qtcommon.h


# Delete all local object files if they're not in the format specified by
# ${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 libqt_ver[]= \"libqt `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:	libqtg.a
	mv -f libqtg.a ${G960BASE}/lib/libqtg.a

install_intel:	libqt.a
	mv -f libqt.a ${G960BASE}/lib/libqt.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}
