#*****************************************************************
#**                                                             **
#**             (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.6 10/26/92 09:41:54 LLNL "

#
#	Constructs ISODE client and server for thebigsender service
#

# The following macros should be appropriately defined.
#
#   ISODE_INCDIR - directory path to ISODE header files
#   ISODE_BINDIR - directory path to ISODE bin files (rosy, posy, pepy)
#   ISODE_LIBDIR - directory path to ISODE library files
#   RO_RUNTIME_DIR - directory path to ELROS runtime
#   RO_SWITCHES - C compilation options

include ../../Make.Defaults

#
# Paths and files
#
DISTFILES=	README Makefile UNIV.ph \
		build.h build.c \
		big.c bigone.ro ryinitiator.h ryinitiator.c \
		bigd.c ryresponder.h ryresponder.c \
		TheBigOne-ops.h TheBigOne-ops.c \
		TheBigOne-asn.py TheBigOne-types.py \
		TheBigOne-types.h TheBigOne-types.c 

INSTALLFILES=	bigd big

#
# Local macros
#
CFLAGS=	-I$(ISODE_INCDIR) -I. -I$(RO_RUNTIME_DIR)/include $(RO_SWITCHES)

#
# Targets
#
all:	showenv bigd big
	@$(ECHOTEXT)
	@$(ECHOTEXT) "Big sender ISODE test is up to date"

showenv:
	@$(ECHOTEXT)
	@$(ECHOTEXT) $(BORDER)
	@$(ECHOTEXT) "Building new version of ISODE16.4"
	@$(ECHOTEXT)
	@$(ECHOTEXT) "ISODE_INCDIR=$(ISODE_INCDIR)"
	@$(ECHOTEXT) "ISODE_LIBDIR=$(ISODE_LIBDIR)"
	@$(ECHOTEXT) "ISODE_BINDIR=$(ISODE_BINDIR)"
	@$(ECHOTEXT) "RO_RUNTIME_DIR=$(RO_RUNTIME_DIR)"
	@$(ECHOTEXT) "RO_SWITCHES=$(RO_SWITCHES)"
	@$(ECHOTEXT) $(BORDER)

big:	big.o ryinitiator.o TheBigOne-Iops.o TheBigOne-types.o build.o
	$(LD) -o big big.o build.o \
		TheBigOne-Iops.o TheBigOne-types.o ryinitiator.o \
		-L$(ISODE_LIBDIR) -lisode -lm

bigd:	bigd.o ryresponder.o TheBigOne-Rops.o TheBigOne-types.o build.o
	$(LD) -o bigd bigd.o build.o \
		TheBigOne-Rops.o TheBigOne-types.o ryresponder.o \
		-L$(ISODE_LIBDIR) -lisode -lm

big.o:	ryinitiator.h TheBigOne-ops.h TheBigOne-types.h build.h

bigd.o:	ryresponder.h TheBigOne-ops.h TheBigOne-types.h build.h

TheBigOne-Iops.o:	TheBigOne-ops.c TheBigOne-ops.h
	$(CC) $(CFLAGS) -DINVOKER $(COPTS) TheBigOne-ops.c
	$(MV) TheBigOne-ops.o $@

TheBigOne-Rops.o:	TheBigOne-ops.c TheBigOne-ops.h
	$(CC) $(CFLAGS) -DPERFORMER $(COPTS) TheBigOne-ops.c
	$(MV) TheBigOne-ops.o $@

TheBigOne-types.o: TheBigOne-types.h


TheBigOne-types.c:       TheBigOne-types.py
	$(ISODE_BINDIR)/pepy -a ryr_advise -m -A $(PYFLAGS) TheBigOne-types.py

TheBigOne-types.py + TheBigOne-types.h:	TheBigOne-asn.py
	$(ISODE_BINDIR)/posy -f -h2 -m -o TheBigOne-types.py $(POFLAGS) \
			TheBigOne-asn.py

TheBigOne-asn.py + TheBigOne-ops.h:	bigone.ro
	$(ISODE_BINDIR)/rosy $(RYFLAGS) -m -o TheBigOne-asn.py bigone.ro

ryinitiator.o:	ryinitiator.h
	$(CC) $(CFLAGS) $(COPTS) ryinitiator.c

build.o:	build.h

#
# Housekeeping targets
#
new:	clean

clean:
	$(RM) *.o $(INSTALLFILES)

#
# For the "package" target, the following macro must be defined on the 
# command line:
#
#    RO_DIST_DIR - directory where distribution files are to be copied

package:	$(DISTFILES)
	$(CP) -p $(DISTFILES) $(RO_DIST_DIR)

#
# For the "install" target, the following macro must be appropriately
# defined.
#
#   RO_INSTALL_DIR - directory where installed files should be copied
#
MY_INSTALL_DIR=	$(RO_INSTALL_DIR)/tests/isode16.4

install: $(DISTFILES) $(INSTALLFILES) $(MY_INSTALL_DIR)
	$(RM) $(MY_INSTALL_DIR)/*
	$(FOR) i in $(DISTFILES); $(DO) ( \
		$(CP) -p $$i $(MY_INSTALL_DIR); \
		$(CHMOD) 444 $(MY_INSTALL_DIR)/$$i; \
	); $(DONE)
	$(CP) -p $(INSTALLFILES) $(MY_INSTALL_DIR)
