#*****************************************************************
#**                                                             **
#**             (C) Copyright 1992 the Regents of the           **
#**        University of California.  All Rights Reserved.      **
#**                                                             **
#**        This work was produced under the sponsorship of      **
#**         the U.S. Department of Energy.  The Government      **
#**                retains certain rights therein.              **
#**                                                             **
#**                         Written by                          **
#**         Distributed Programming Environments Project        **
#**           Computer Software and Networking Division,        **
#**                   Livermore Computer Center,                **
#**            Lawrence Livermore National Laboratory           **
#**                                                             **
#*****************************************************************

#	sccsid:		"@(#)Makefile	1.33 12/4/92 09:14:36 LLNL "

#
#	Make ELROS system
#

#
# The following macros must be defined for making various parts of the
# ELROS system, and configuring the runtime library.  The values for these
# are read from the file "Make.Defaults".  If you need to change the
# values for these macros for the entire ELROS system, you must edit that 
# file.  See the installation guide for details on how to select the right
# definitions for your system.
#
#   RO_DIR - root directory ELROS system
#
#   RO_PARAMS - parameters.dat file to use
#
#   RO_OPT_REAL - 0 or 1
#   RO_HAS_LONGLONG - 0 or 1
#   RO_HAS_LONGDOUBLE - 0 or 1
#   RO_SWITCHES - C and C++ compilation options, e.g., "-g"
#   RO_PLATFORMS - ISODE or PURESOCKETS or ISODE_and_PURESOCKETS
#   RO_TASKING_FLAG - __RO_TASKING or NO__RO_TASKING
#
# If RO_PLATFORMS includes ISODE, the following macro must also be defined.
#
#   ISODE_INCDIR - directory where ISODE header files are installed
#   ISODE_LIBDIR - directory where ISODE library files are installed
#
# For the "package" target, the following macro must be defined.
#
#   RO_DIST_DIR - directory where distribution directory and tar file
#                 should be built
#
# For the "install" target, the following macro must be defined. 
#
#   RO_INSTALL_DIR - directory where installed files should be copied
#


#############################################################################
#############################################################################
# Review and edit the macro assignments in the "Make.Defaults" file as needed 
# for your particular installation before running this Makefile.
#############################################################################
#############################################################################

include Make.Defaults

#
# Paths and files
#
DISTFILES=	Makefile README COPYRIGHT \
		any.h 

INSTALLFILES=	parameters.dat

#
# Targets
#
all:	showenv Preprocessor Runtime Driver Util Tests

showenv: show$(RO_PLATFORMS)

showPURESOCKETS:
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "               Current ELROS Make environment"
	@$(ECHOTEXT)
	@$(ECHOTEXT) "RO_DIR=$(RO_DIR)"
	@$(ECHOTEXT) "RO_PARAMS=$(RO_PARAMS)"
	@$(ECHOTEXT)
	@$(ECHOTEXT) "RO_OPT_REAL=$(RO_OPT_REAL)"
	@$(ECHOTEXT) "RO_HAS_LONGLONG=$(RO_HAS_LONGLONG)"
	@$(ECHOTEXT) "RO_HAS_LONGDOUBLE=$(RO_HAS_LONGDOUBLE)"
	@$(ECHOTEXT) "RO_SWITCHES=$(RO_SWITCHES)"
	@$(ECHOTEXT) "RO_PLATFORMS=$(RO_PLATFORMS)"
	@$(ECHOTEXT) "RO_TASKING_FLAG=$(RO_TASKING_FLAG)"
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) $(BORDER)

showISODE showISODE_and_PURESOCKETS:
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "               Current ELROS Make environment"
	@$(ECHOTEXT)
	@$(ECHOTEXT) "RO_DIR=$(RO_DIR)"
	@$(ECHOTEXT) "RO_PARAMS=$(RO_PARAMS)"
	@$(ECHOTEXT)
	@$(ECHOTEXT) "RO_OPT_REAL=$(RO_OPT_REAL)"
	@$(ECHOTEXT) "RO_HAS_LONGLONG=$(RO_HAS_LONGLONG)"
	@$(ECHOTEXT) "RO_HAS_LONGDOUBLE=$(RO_HAS_LONGDOUBLE)"
	@$(ECHOTEXT) "RO_SWITCHES=$(RO_SWITCHES)"
	@$(ECHOTEXT) "RO_PLATFORMS=$(RO_PLATFORMS)"
	@$(ECHOTEXT) "RO_TASKING_FLAG=$(RO_TASKING_FLAG)"
	@$(ECHOTEXT)
	@$(ECHOTEXT) "ISODE_INCDIR=$(ISODE_INCDIR)";
	@$(ECHOTEXT) "ISODE_LIBDIR=$(ISODE_LIBDIR)";
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) $(BORDER)

New: newhdr new all 

newhdr:
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "Making everything from scratch"
	@$(ECHOTEXT)
	@$(DATE)
	@$(ECHOTEXT) $(BORDER)

#
# ELROS products
#
Driver:
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "Making driver"
	@$(ECHOTEXT) $(BORDER)
	$(CD) driver; $(MAKE)

Preprocessor:
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "Making preprocessor"
	@$(ECHOTEXT) $(BORDER)
	$(CD) preprocessor; $(MAKE)

Runtime:
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "Making runtime system"
	@$(ECHOTEXT) $(BORDER)
	$(CD) runtime; $(MAKE)

Util:
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "Making utilities"
	@$(ECHOTEXT) $(BORDER)
	$(CD) util; $(CD) asn; $(MAKE)
	$(CD) util; $(CD) logging; $(MAKE)

Tests: 
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "Making test suite"
	@$(ECHOTEXT) $(BORDER)
	$(CD) tests; $(MAKE) clean
	$(CD) tests; $(MAKE)


#
# Make distribution
#
# For the Distribution target, the following macros must be defined.
#
#   RO_DIST_DIR - directory where distribution directory and tar file
#                 should be built
#   DIRS - names of ELROS subdirectories
#
Distribution:
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "Making distribution"
	@$(ECHOTEXT)
	@$(ECHOTEXT) "RO_DIST_DIR=$(RO_DIST_DIR)"
	@$(ECHOTEXT) $(BORDER)
	-$(RM) -r distribution
	$(MKDIR) distribution

	@$(ECHOTEXT)
	@$(ECHOTEXT) "Loading 'distribution'"
	$(CP) -p $(DISTFILES) distribution

	@$(FOR) i in $(DIRS); $(DO) ( \
		$(ECHOTEXT) ; \
		$(ECHOTEXT) "Loading 'distribution/$$i'"; \
		$(MKDIR) distribution/$$i; \
		$(CD) $(RO_DIST_DIR)/$$i; \
		$(MAKE) $(D)RO_DIST_DIR=$(RO_DIST_DIR)/distribution/$$i package \
	); $(DONE)

	@$(ECHOTEXT) 
	@$(ECHOTEXT) "Make distribution tar tape:  new-elros.tar"
	$(CD) distribution; $(TAR) -cf ../new-elros.tar *

#
# Housekeeping targets
#
new:
	$(RM) parameters.dat
	$(CP) params/$(RO_PARAMS) parameters.dat
	$(CD) runtime; $(MAKE) new
	$(CD) preprocessor; $(MAKE) new
	$(CD) driver; $(MAKE) new
	$(CD) util; $(MAKE) new
	$(CD) tests; $(MAKE) new

clean:

#
# For the "install" target, the following macro must be defined. 
#
#   RO_INSTALL_DIR - directory where installed files should be copied
#

install: $(DISTFILES) $(INSTALLFILES) $(RO_INSTALL_DIR)
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "Making installation"
	@$(ECHOTEXT)
	@$(ECHOTEXT) "RO_INSTALL_DIR=$(RO_INSTALL_DIR)"
	@$(ECHOTEXT) $(BORDER)

	$(CD) $(RO_INSTALL_DIR); $(RM) $(DISTFILES) $(INSTALLFILES)
	$(FOR) i in $(DISTFILES); $(DO) ( \
		$(CP) -p $$i $(RO_INSTALL_DIR); \
		$(CHMOD) 444 $(RO_INSTALL_DIR)/$$i; \
	); $(DONE)

	$(CP) -p $(INSTALLFILES) $(RO_INSTALL_DIR)


#
# Check if all files have been checked into SCCS.  For the "delta-check" 
# target to work, you must have an underlying SCCS tree structure that 
# mirrors the ELROS tree structure.
#
# The following macros must be defined appropriately:
#
#   DIRS - names of all ELROS subdirectories
# 

delta-check:
	@$(ECHOTEXT) "sccs info in '.'"; sccs info
	$(FOR) i in $(DIRS); $(DO) ( \
		$(ECHOTEXT) "sccs info in '$$i'"; \
		$(CD) $$i; sccs info; \
	); $(DONE)


