# (C) Copyright International Business Machines Corporation 23 January 
# 1990.  All Rights Reserved. 
#  
# See the file USERAGREEMENT distributed with this software for full 
# terms and conditions of use. 
# SCCS Info: @(#)Makefile	1.10 3/14/90

# Source files
PFILES =	root.p pcom.p dcom.p cwd.p findfile.p pathload.p \
		pathreadobj.p loadprog.p libstore.p libwriteobj.p \
		fixdefsint.p fixfull.p fixmin.p shorten.p \
		getfile.p progfixfull.p formaterror.p fixdefs.p checkdefs.p
# and...	progfixfull.p

# process modules generated
BASICOBJS =	root.po pcom.po dcom.po cwd.po findfile.po pathload.po \
		pathreadobj.po loadprog.po libstore.po libwriteobj.po \
		getfile.po formaterror.po
TCOBJS =	fixdefsint.po fixfull.po fixmin.po shorten.po checkdefs.po \
		fixdefs.po
# and...	progfixfull.po
PROCOBJS =	$(BASICOBJS) $(TCOBJS)

# parsed process modules which are needed before we can use the
# integerated front-end to go straight from .p to .po
AOFILES	=	root.ao pcom.ao dcom.ao cwd.ao findfile.ao pathload.ao \
		pathreadobj.ao loadprog.ao libstore.ao libwriteobj.ao \
		getfile.ao formaterror.ao
# and...	fixdefs.ao progfixfull.ao

# Extra flags that we need for the c preprocessor
EXTRACPPFLAGS =	-Uunix $(BOOTFLAG)

# Use preparsed process modules when compiling
PCOMOPTS =	-noparse

include ../make/includefile

# Only take compiled process modules from standard system library
LOADPATH =	$(PROCDIR)
# Definitions come from the compiler support definitions directory and
# the standard system library, but we also include the current
# directory for loading .ao files
DEFPATH =	$(HROOT)/hermes/defs:$(DEFDIR):$(HROOT)/hermes

# We need a couple of extra suffix rules, and we also need to give .ao
# a higher priority than .p when selecting a suffix rule for making a
# .po file
.SUFFIXES:
.SUFFIXES:	.ao .pp .p .po $(SUFFIXES)
.p.ao:	$<
	env $(HERMENV) $(HERMES) $<
.ao.po:	$<
	$*

# compilation of process modules

all:	$(AOFILES) basic compileprocs
install: all
	cp $(PROCOBJS) $(PROCDIR)

# following target builds only what we can build before typechecking
basic:	$(AOFILES)
	@plist=`make -n basicprocs` ; if [ "$$plist" ] ; then \
		echo $(PCOMCMD) -noparse $$plist ; \
		$(PCOMCMD) -noparse $$plist ; fi
basicprocs: $(BASICOBJS)
basicinstall: basic
	cp $(BASICOBJS) $(PROCDIR)

# following target builds the non-typemarked modules, going straight
# from .p to .po file
tc:	$(PFILES)
	@plist=`make -n tcprocs` ; if [ "$$plist" ] ; then \
		echo $(PCOMCMD) $$plist ; $(PCOMCMD) $$plist ; fi
tcprocs: $(TCOBJS)
tcinstall: tc
	cp $(TCOBJS) $(PROCDIR)

tcboot:
	@-rm -f pcom.p pcom.po
	$(MAKE) basic BOOTFLAG=-DTCBOOT HROOT=$(HROOT) MTYPE=$(MTYPE) CACHE=
tsboot:
	@-rm -f pcom.p pcom.ao pcom.po \
		formaterror.p formaterror.ao formaterror.po
	$(MAKE) basic BOOTFLAG=-DTSBOOT HROOT=$(HROOT) MTYPE=$(MTYPE)
final:
	@-rm -f pcom.p pcom.po dcom.p dcom.po \
		formaterror.p formaterror.ao formaterror.po
	$(MAKE) all BOOTFLAG= HROOT=$(HROOT) MTYPE=$(MTYPE)
	
# Dependencies
root.po:	root.ao
root.ao:	root.p
root.p:		root.pp getpaths.pp

pcom.po:	pcom.ao
pcom.ao:	pcom.p
pcom.p:		pcom.pp

dcom.po:	dcom.ao
dcom.ao:	dcom.p
dcom.p:		dcom.pp

formaterror.po:	formaterror.ao
formaterror.ao:	formaterror.p
formaterror.p:	formaterror.pp

cwd.po:		cwd.ao
cwd.ao:		cwd.p

findfile.po:	findfile.ao
findfile.ao:	findfile.p

pathload.po:	pathload.ao
pathload.ao:	pathload.p

pathreadobj.po:	pathreadobj.ao
pathreadobj.ao:	pathreadobj.p

loadprog.po:	loadprog.ao
loadprog.ao:	loadprog.p

libstore.po:	libstore.ao
libstore.ao:	libstore.p

libwriteobj.po:	libwriteobj.ao
libwriteobj.ao:	libwriteobj.p

getfile.po:	getfile.ao
getfile.ao:	getfile.p

fixdefs.po:	fixdefs.p
fixdefsint.po:	fixdefsint.p
fixfull.po:	fixfull.p
fixmin.po:	fixmin.p
shorten.po:	shorten.p
progfixfull.po:	progfixfull.p
checkdefs.po:	checkdefs.p

clean:
	rm -f core *.do *.ao *.po *~ *~*~ *.cd root.p pcom.p dcom.p \
		formaterror.p
