#-----------------------------------------------------------------------------
#	Makefile for libnin.a (Intel object) and libning.a (GNU/960 object)
#
# $Id: Makefile,v 1.12 89/12/10 14:08:03 chrisb Exp $
#
# This library provides routines for interfacing with the NINDY monitor.
#-----------------------------------------------------------------------------


# 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	# GNU/960 format
IFLAG = .intel_objs	# Intel format

ALL_FLAGS = ${GFLAG} ${IFLAG}

IPATH	= ../../../include

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

.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	= -AKA

CC	= uhuh
AS	= uhuh
ASFLAGS	= ${ARCH}
AR	= uhuh
ARFLAGS	= rs

OBJS	= copyrght.o dto_stub.o errno.o gcc_stub.o heapsize.o lib.o libasm.o \
		ver960.o

all:	libnin.a libning.a

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


# The following target can only be compiled with V2 or higher of the
# Intel ic960 compiler and header files (dto_stub.o will fail otherwise).
libnin.a: FORCE
	make ${IFLAG} lib			\
		CC=ic960			\
		CFLAGS='-O2 ${ARCH} -c ${INCL}'	\
		AS=asm960 			\
		AR=arc960			\
		LIB=libnin.a			\
		IOBJ=newlib.o

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


lib.o:	${IPATH}/block_io.h


# 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 libnin_ver[]= \"libnin `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:	libning.a 
	mv -f libning.a ${G960BASE}/lib

install_intel:	libnin.a
	mv -f libnin.a ${G960BASE}/lib

install: install_gnu install_intel

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