#
#	This is the global Makefile to make and install the entire
#	Modula-2 release.
#

#
#	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 ###############################


# Names of VMS directories (not yet supported)
REMOTEDIR = '[.m2]'
SUBJECT    = "Here are the results of the remote make (MMS on VMS)."
REMOTENODE = ophion::

all :
	(cd doc     ; make all)
	(cd mod	    ; make all)
	(cd prep    ; make all)
	(cd lib	    ; make all)
	(cd mod2    ; make mod2.0)
#	(cd mod2    ; make mod2.0 mod2.0t)
	(cd imc	    ; make all)
	(cd pascal  ; make pas2.0)
#	(cd pascal  ; make pas2.0 pas2.0t)
	(cd xlate   ; make all)
	(cd p2m2    ; make all)
	(cd modprof ; make all)
	(cd bench   ; make -i all)
#	(cd test    ; make all)

Makefile: Metafile Metafile.defines
	$(CP) Makefile Makefile.bak
	(cd mod     ; make mod)
	(cd prep    ; make prep)
	prep/prep -Dvax=$(VAX) -Dmips=$(MIPS) <Metafile > Makefile

Makefiles:
	              make Makefile
	(cd doc     ; make Makefile)
	(cd mod     ; make Makefile)
	(cd prep    ; make Makefile)
	(cd lib     ; make Makefile)
	(cd mod2    ; make Makefile)
	(cd imc     ; make Makefile)
	(cd pascal  ; make Makefile)
	(cd xlate   ; make Makefile)
	(cd p2m2    ; make Makefile)
	(cd modprof ; make Makefile)
	(cd bench   ; make Makefile)
#	(cd test    ; make Makefile)

quickinstall:
	(cd doc	    ; make quickinstall)
	(cd mod	    ; make quickinstall)
	(cd prep    ; make quickinstall)
	(cd lib	    ; make quickinstall)
	(cd mod2    ; make quickinstallmod2.0)
#	(cd mod2    ; make quickinstallmod2.0 quickinstallmod2.0t)
	(cd imc	    ; make quickinstall)
	(cd pascal  ; make quickinstallpas2.0)
#	(cd pascal  ; make quickinstallpas2.0 quickinstallpas2.0t)
	(cd xlate   ; make quickinstall)
	(cd p2m2    ; make quickinstall)
	(cd modprof ; make quickinstall)

install :
	(cd doc	    ; make install)
	(cd mod	    ; make install)
	(cd prep    ; make install)
	(cd lib	    ; make install)
	(cd mod2    ; make installmod2.0)
#	(cd mod2    ; make installmod2.0 installmod2.0t)
	(cd imc	    ; make install)
	(cd pascal  ; make installpas2.0)
#	(cd pascal  ; make installpas2.0 install pas2.0t)
	(cd xlate   ; make install)
	(cd p2m2    ; make install)
	(cd modprof ; make install)

release:
	maketar m2.tar
	-$(RM) m2.tar.Z
	compress m2.tar

clean :
	(cd doc	    ; make clean)
	(cd mod	    ; make clean)
	(cd prep    ; make clean)
	(cd lib	    ; make clean)
	(cd mod2    ; make clean)
	(cd imc	    ; make clean)
	(cd pascal  ; make clean)
	(cd xlate   ; make clean)
	(cd p2m2    ; make clean)
	(cd modprof ; make clean)
	(cd bench   ; make clean)

checkin :
	(cd doc     ; make checkin)
	(cd mod	    ; make checkin)
	(cd prep    ; make checkin)
	(cd lib	    ; make checkin)
	(cd mod2    ; make checkin)
	(cd imc	    ; make checkin)
# don't checkin pascal, uses same files as mod2
	(cd xlate   ; make checkin)
	(cd p2m2    ; make checkin)
	(cd modprof ; make checkin)

makemod.com : Makefile
	@echo "Re-creating the submit file: $@"
	@echo \$$ SET VERIFY > $@
	@echo \$$ SET DEFAULT $(REMOTENODE)$(REMOTEDIR) >> $@
	@echo \$$ "@NEWMOD" >> $@
	@echo \$$ MMS/OUTPUT=MAKE.LOG >> $@
	@echo \$$ MAIL MAKE.LOG $${HOST}::$${USER} /SUBJECT='$(SUBJECT)' >>$@
	@echo \$$ SET NOVERIFY >> $@

descrip.mms : Makefile
	@echo "Please update $@ and copy it to $(REMOTENODE)$(REMOTEDIR)."
