#       Makefile for the occam compiler TB routines for the C library
#
#
# This file assumes that it is being run within the directory of the sources
# and output files.
#
# The macro OUTNAME must be supplied from the command line.
#
#                          4-Dec-90 SRH
#
#                 This file is set up for UNIX.


SWITCH=-

# this name must be supplied from the command line
OUTNAME=

# for the flexibility to pass something in from the command line 
OCCEXTRAS=

# do not define TB in PREOPT - see SQRT example below
PREPROCESSOR=preocc
PREOPT=$(SWITCH)d C $(SWITCH)d UNISTOP
LIBRARIAN=ilibr
LIBOPT=
OCCAM=oc
OCCOPT=$(SWITCH)d $(SWITCH)v $(SWITCH)x $(SWITCH)u $(SWITCH)tb $(SWITCH)zlcp %c $(SWITCH)zlcs % $(OCCEXTRAS)

INTO=>
COPY=cp
RENAME=mv
DELETE=rm
CONCATENATE=cat

# files which must be in TB mode since they are more efficient in this
# mode, rsqrt because it uses ROUNDSN and UNPACKSN, the others because
# the source code is different for TB than for TA ( ASM is used )
TBXMODE=	r32op.tbx r32operr.tbx r32gterr.tbx r32eqerr.tbx \
		rsqrt.tbx

#-------------------------------- Main rule ---------------------------------

# Force the whole library to be made
all:		$(OUTNAME)

$(OUTNAME):	$(TBXMODE)
	$(CONCATENATE) $(TBXMODE)  $(INTO)  $(OUTNAME)


# now for the TB stuff

r32op.tbx:	r32op.occ
	$(PREPROCESSOR) $(@:.tbx=.occ) $(PREOPT) $(SWITCH)d TB $(SWITCH)o $(@:.tbx=.pbx)
	$(OCCAM) $(@:.tbx=.pbx) $(OCCOPT) $(SWITCH)o $@
	$(DELETE) $(@:.tbx=.pbx)

r32operr.tbx:	r32operr.occ
	$(PREPROCESSOR) $(@:.tbx=.occ) $(PREOPT) $(SWITCH)d TB $(SWITCH)o $(@:.tbx=.pbx)
	$(OCCAM) $(@:.tbx=.pbx) $(OCCOPT) $(SWITCH)o $@
	$(DELETE) $(@:.tbx=.pbx)

r32gterr.tbx:	r32gterr.occ
	$(PREPROCESSOR) $(@:.tbx=.occ) $(PREOPT) $(SWITCH)d TB $(SWITCH)o $(@:.tbx=.pbx)
	$(OCCAM) $(@:.tbx=.pbx) $(OCCOPT) $(SWITCH)o $@
	$(DELETE) $(@:.tbx=.pbx)

r32eqerr.tbx:	r32eqerr.occ
	$(PREPROCESSOR) $(@:.tbx=.occ) $(PREOPT) $(SWITCH)d TB $(SWITCH)o $(@:.tbx=.pbx)
	$(OCCAM) $(@:.tbx=.pbx) $(OCCOPT) $(SWITCH)o $@
	$(DELETE) $(@:.tbx=.pbx)

# note how we use the TA source code for SQRT
rsqrt.tbx:	rsqrt.occ
	$(PREPROCESSOR) $(@:.tbx=.occ) $(PREOPT) $(SWITCH)d TA $(SWITCH)o $(@:.tbx=.pbx)
	$(OCCAM) $(@:.tbx=.pbx) $(OCCOPT) $(SWITCH)o $@
	$(DELETE) $(@:.tbx=.pbx)
