##############################################################################
#
#     Make file for the support library occamutl.lib in occam 2 toolset
#
#                            16-Nov-90 SRH
#
#             This makefile is presently set up for UNIX
#
##############################################################################


# UNIX specific macros
SWITCH=-
DELETE=rm
CONCATENATE=cat
INTO=>


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

# tools and global options
PREPROCESSOR=preocc
PREOPT=$(SWITCH)d OCCAM
LIBRARIAN=ilibr
LIBOPT=
OCCAM=oc
OCCOPT=$(SWITCH)d $(SWITCH)e $(SWITCH)v $(OCCEXTRAS)


# T2 class modules
OCCAMUTLT2=rimul.t2h ridiv.t2h qrimul.t2h qridiv.t2h qnorm.t2h \
	  qshiftl.t2h qshiftr.t2h  \
	  rimul.t2x ridiv.t2x qrimul.t2x qridiv.t2x qnorm.t2x \
	  qshiftl.t2x qshiftr.t2x

# TA class modules
OCCAMUTLTA=rimul.tah ridiv.tah rimul.tax ridiv.tax

# T8 class modules
OCCAMUTLT8=rimul.t8h ridiv.t8h rimul.t8x ridiv.t8x


#
############################## target and rules ##############################
#
all: occamutl.lib

occamutl.lib:	occamutl.t2 occamutl.t8 occamutl.ta
	$(LIBRARIAN) occamutl.t2 occamutl.t8 occamutl.ta $(LIBOPT) $(SWITCH)o occamutl.lib


occamutl.t2: $(OCCAMUTLT2)
	$(CONCATENATE) $(OCCAMUTLT2) $(INTO) occamutl.t2

occamutl.ta: $(OCCAMUTLTA)
	$(CONCATENATE) $(OCCAMUTLTA) $(INTO) occamutl.ta

occamutl.t8: $(OCCAMUTLT8)
	$(CONCATENATE) $(OCCAMUTLT8) $(INTO) occamutl.t8


# Pattern matching rules.
#
# defining HALT and UNISTOP are, in fact, redundant because none of the files
# have the modes defined for the preprocessor ( as at 10-Apr-90 ), however,
# there is no harm defining them on the preprocessor command line for
# possible changes in the future and for consistency across other makefiles.
# $< is a dynamic macro which means the current dependency file
# $* is a dynamic macro which means the base name of the current target
%.t2h: %.occ
	$(PREPROCESSOR) $< $(PREOPT) $(SWITCH)d T2 $(SWITCH)d HALT $(SWITCH)o $*.p2h
	$(OCCAM) $*.p2h $(SWITCH)h $(SWITCH)t2 $(OCCOPT) $(SWITCH)o $*.t2h
	$(DELETE) $*.p2h

%.t2x: %.occ
	$(PREPROCESSOR) $< $(PREOPT) $(SWITCH)d T2 $(SWITCH)d UNISTOP $(SWITCH)o $*.p2x
	$(OCCAM) $*.p2x $(SWITCH)x $(SWITCH)t2 $(OCCOPT) $(SWITCH)o $*.t2x
	$(DELETE) $*.p2x


%.tah: %.occ
	$(PREPROCESSOR) $< $(PREOPT) $(SWITCH)d TA $(SWITCH)d HALT $(SWITCH)o $*.pah
	$(OCCAM) $*.pah $(SWITCH)h $(SWITCH)ta $(OCCOPT) $(SWITCH)o $*.tah
	$(DELETE) $*.pah

%.tax: %.occ
	$(PREPROCESSOR) $< $(PREOPT) $(SWITCH)d TA $(SWITCH)d UNISTOP $(SWITCH)o $*.pax
	$(OCCAM) $*.pax $(SWITCH)x $(SWITCH)ta $(OCCOPT) $(SWITCH)o $*.tax
	$(DELETE) $*.pax


%.t8h: %.occ
	$(PREPROCESSOR) $< $(PREOPT) $(SWITCH)d T8 $(SWITCH)d HALT $(SWITCH)o $*.p8h
	$(OCCAM) $*.p8h $(SWITCH)h $(SWITCH)t8 $(OCCOPT) $(SWITCH)o $*.t8h
	$(DELETE) $*.p8h

%.t8x: %.occ
	$(PREPROCESSOR) $< $(PREOPT) $(SWITCH)d T8 $(SWITCH)d UNISTOP $(SWITCH)o $*.p8x
	$(OCCAM) $*.p8x $(SWITCH)x $(SWITCH)t8 $(OCCOPT) $(SWITCH)o $*.t8x
	$(DELETE) $*.p8x
