#-----------------------------------------------------------------------------
# Makefile for libfp, in two flavors:
#	libfpgka.a:	GNU/960 object, for 80960KA
#	libfpgca.a:	GNU/960 object, for 80960CA
#
# $Id: Makefile,v 1.1 89/12/05 11:22:26 chrisb Exp $
#
# This library provides floating point emulation for members of the 80960
# family that do not have floating point capability.
#-----------------------------------------------------------------------------

# The following are names of flag files.  The presence of a flag file indicates
# what flavor (architecture) object files were last built in the current
# directory.  Only one flavor can be present at a time:  when a change of
# flavor is required, all objects are first deleted, so as to avoid mixing
# architectures within a library.
#
KA_FLAG = .ka_objs
CA_FLAG = .ca_objs
ALL_FLAGS = ${KA_FLAG} ${CA_FLAG}


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

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

CC	= gcc960
CFLAGS	= -g -O3 ${ARCH}
AS	= gas960
ASFLAGS	= ${ARCH}
AR	= gar960
ARFLAGS	= rs


OBJS = ver960.o

GNU_LIBS= libfpgka.a libfpgca.a

all:	${GNU_LIBS}

libfpgka.a: FORCE
	make ${KA_FLAG} lib LIB=libfpgka.a ARCH=-AKA

libfpgca.a: FORCE
	make ${CA_FLAG} lib LIB=libfpgca.a ARCH=-ACA

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

# Delete all local object files if they're not for the specified architecture,
# as indicated by the presence of the flag files.
#
${KA_FLAG}:
	rm -f *.o ${ALL_FLAGS}
	touch ${KA_FLAG}

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


#-----------------------------------------------------------------------------
#		'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 libfp_ver[]= \"libfp `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: install_gnu

install_gnu:	${GNU_LIBS}
	mv -f ${GNU_LIBS} ${G960BASE}/lib

install_intel:
	@echo "Use floating point library supplied with Intel tools"

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