#     Makefile for the occam compiler T8 routines for the FORTRAN 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.
#
#                         5-Feb-91 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 T8 globally via PREOPT - see examples below, e.g. r32remer.occ
PREPROCESSOR=preocc
PREOPT=$(SWITCH)d FORTRAN $(SWITCH)d UNISTOP
LIBRARIAN=ilibr
LIBOPT=
OCCAM=oc
OCCOPT=$(SWITCH)d $(SWITCH)v $(SWITCH)x $(SWITCH)u $(SWITCH)t8 $(SWITCH)zlcp %f $(SWITCH)zlcs % $(OCCEXTRAS)

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


# Pattern matching rules - used if there is no explicit rule.
#
# $< is a dynamic macro meaning the name of the dependency file;
# $* is a dynamic macro meaning the base name of the current target
%.t8x: %.occ
	$(PREPROCESSOR) $< $(PREOPT) $(SWITCH)d T8 $(SWITCH)o $*.p8x
	$(OCCAM) $*.p8x $(OCCOPT) $(SWITCH)o $*.t8x
	$(DELETE) $*.p8x


REALT8X=r32remer.t8x r64remer.t8x ridiv.t8x rimul.t8x \
	r32op.t8x r64op.t8x ie32comp.t8x ie64comp.t8x \
	rscaleb.t8x dscaleb.t8x rfunpack.t8x dfunpack.t8x \
	unpacksn.t8x roundsn.t8x \
	dargred.t8x

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

# force build of OUTNAME
all:	 $(OUTNAME)

$(OUTNAME):	$(REALT8X)
	$(CONCATENATE) $(REALT8X)  $(INTO)  $(OUTNAME)
	$(COPY) $(OUTNAME) occam8.lib
	$(DELETE) occamutl.lib

occamutl.lib: ridiv.t8x
	$(LIBRARIAN) ridiv.t8x $(SWITCH)o occamutl.lib


# use TA source code
r32remer.t8x: r32remer.occ
	$(PREPROCESSOR) r32remer.occ $(PREOPT) $(SWITCH)d TA $(SWITCH)o r32remer.p8x
	$(OCCAM) r32remer.p8x $(OCCOPT) $(SWITCH)o r32remer.t8x
	$(DELETE) r32remer.p8x

# use TA source code with FPU part for DMODP; needs RealIDiv from occamutl.lib
r64remer.t8x: r64remer.occ occamutl.lib
	$(PREPROCESSOR) r64remer.occ $(PREOPT) $(SWITCH)d TA $(SWITCH)d FPU $(SWITCH)o r64remer.p8x
	$(OCCAM) r64remer.p8x $(OCCOPT) $(SWITCH)o r64remer.t8x
	$(DELETE) r64remer.p8x
