#
#	This is the Makefile for the p-code to VAX assembly translator
#

#
#	WARNING: This Makefile is derived from the corresponding Metafile.
#	Don't even try to edit this file.  Instead, edit the Metafile, then
#	do a ``make Makefile''.
#
#	If you alter Metafile.defines in the top-level Modula-2 directory,
#	then you should do a ``make Makefiles'' to rederive all Makefiles
#	in all directories.


########################## Common Definitions ###############################

# Defines for conditional processing

VAX         = TRUE
MIPS        = FALSE
ARCH        = vax


# Top-level directory for installation.  Define as /tmp/ to test installation.
# Note that if you define DESTDIR, it must have a trailing /.
DESTDIR     = 
# Directory for installing libmod.a
LIBDIR      = /usr/local/lib
# Directory for installing the passes of the compiler
PASSESDIR   = /usr/local/lib/mod
# Directory for installing the .def files we provide
DEFSDIR     = /usr/local/defs
# Directory for installing the man pages for mod and p2m2
MANDIR      = /usr/man/manl
# Directory for installing the binaries mod and p2m2
BINDIR      = /usr/local/bin

# Name of Modula-2 driver program
MODBINNAME  = mod
# Name of Pascal driver program
PCBINNAME   = wrlpc
# Name of Pascal to Modula-2 converter program
P2M2BINNAME = p2m2
# Name of Modula-2 statement-level profiler
MODPROFBINNAME = modprof
# Name of Modula-2 preprocessor
PREPBINNAME = prep

# Name of directory in which Modula-2 library, compiler passes reside
TESTLIBDIR  = /pandora_a1/m2/m2-$(ARCH)/lib

# Defines for VMS
REMOTENODE = ophion::


# Defines for various utilities.  You may not have all these flags if you
# aren't running a recent release.  So set them according to your system's
# capabilities before trying to install anything.


# rm -f forces removal without asking question or reporting file not found
RM          = rm -f

CP          = cp

MKDIR       = mkdir

RDIST       = rdist -c -h
LOCALHOST        = localhost:

########################## End of Definitions ###############################


.SUFFIXES:
.SUFFIXES: .o .mod .def .c

vms = FALSE

CFLAGS = -O
MODFLAGS = -a -g -O -Dvms=$(vms) -B../lib
MOD = ../mod/mod

.def.mod:
	touch $*.mod
.mod.o:
	$(MOD) -c $(MODFLAGS) $*.mod

all: mod2.1 descrip.mms

OBJS =	CodeSubs.o Consts.o EES.o Error.o Input.o Machine.o \
	MemRef.o OpSubs.o Types.o Output.o Util.o Vars.o Xlate.o \
	PCodeOps.o Hash.o machinec.o

xlate:	$(OBJS)
	$(MOD) -o xlate $(MODFLAGS) -m"$(MODFLAGS)" $(OBJS)

mod2.1:	$(OBJS)
	$(MOD) -o mod2.1 $(MODFLAGS) -m"$(MODFLAGS)" $(OBJS)

testr:	$(OBJS)
	$(MOD) -c $(MODFLAGS) -m"$(MODFLAGS)" $(OBJS)

# hash table function generation
makehash:makehash.o PCodeOps.def PCodeOps.mod PCodeOps.o
	$(MOD) -o makehash $(MODFLAGS) -m"$(MODFLAGS)" PCodeOps.o makehash.o
Input.mod:	Hash.def
Hash.def:	PCodeOps.def PCodeOps.mod makehash
	./makehash
Hash.mod:	PCodeOps.def PCodeOps.mod

# inline dependencies
CodeSubs.o:	Output.o Util.o
EES.o:		Output.o
MemRef.o:	Output.o Util.o
OpSubs.o:	Output.o Util.o


Makefile: Metafile ../Metafile.defines
	mv Makefile Makefile.bak
	../prep/prep -Dvax=$(VAX) -Dmips=$(MIPS) <Metafile > Makefile

quickinstall: ${DESTDIR}$(PASSESDIR)
	install -c -s mod2.1 ${DESTDIR}$(PASSESDIR)/mod2.1

install: ${DESTDIR}$(PASSESDIR) ${DESTDIR}$(PASSESDIR)/mod2.1

${DESTDIR}$(PASSESDIR):
	-test -d $@ || $(MKDIR) $@

${DESTDIR}$(PASSESDIR)/mod2.1:	mod2.1
	install -c -s mod2.1 ${DESTDIR}$(PASSESDIR)/mod2.1

clean:
	-$(RM) *.o xlate makehash

descrip.mms: Metafile
	@echo Update descrip.mms to match Metafile

vmscopy:
	dcp -v [A-Z]*.def [A-Z]*.mod makehash.mod machinec.c descrip.mms \
	$(REMOTEDIR)

checkin:
	ci -l -f -m"Checkin before VMS changes" \
	-s"Experimental" \
	[A-Z]*.def [A-Z]*.mod makehash.mod machinec.c Makefile descrip.mms
