# $Header: /soma/users/miyata/planet/RCS/Makefile,v 5.6.0.4 91/02/13 15:51:00 miyata Exp $ 
VERSION = 	5.6.0

# To install PlaNet programs, see README.
# To print the User's Guide and the Reference Manual, see doc/README

# Comment out options (put '#' before them) you don't want.
Shell=-Dshellinput #	# for receiving commands from shell
Optimize=-O #		# optimize
#Debug=-g #		# for debugging

# # floating point options - choose one or make a new one.
# for HPs and DecStations, comment out F=-fsingle.
#F=-fsingle
#F=-f68881
#F=-ffpa
#F=-fsky
#	# if you choose -fsky above, uncomment the following line.
#SKY=sky #		# use skyboard library

#Prof=-p #		# for prof program
#Prof=-gp #		# for gprof program

## X11 library -> change it to the apprropriate one on your system. 
XLibs= 		-lX11
## uncomment and set to X include directory if it is not in /usr/include.
# Xinclude=	-I/usr/local/X11/include

## uncomment for HPs.
# HP = -Dhp

TYPE=$(Shell)
CFLAGS=$(Optimize) $(Debug) $F $(HP) $(Xinclude)

mainDir   =	..
sourceDir =	../src
sunnetDir =	sunnet # set this to "sun4" etc. as needed
planetDir =	planet
xnetDir =	xnet
mgrDir =	mgr
MAKE=		make $(MFLAGS) "CFLAGS = $(CFLAGS)" "VPATH = $(sourceDir)" \
		"PFLAGS = $(Prof)" -f $(mainDir)/Makefile.temp
MAKEX=		make $(MFLAGS) "CFLAGS = $(CFLAGS)" "XLibs = $(XLibs)"\
		"PFLAGS = $(Prof)" -f $(mainDir)/Makefile.temp

XNet:	
	cd $(xnetDir); $(MAKEX) "PROG = -Dxnet $(TYPE)" XNet
StarNet:	
	cd $(sunnetDir); $(MAKE) "PROG = $(TYPE)" StarNet
netcommand: src/netcommand.c
	cd $(sunnetDir); make -f $(mainDir)/Makefile.temp netcommand

## SunNet/PlaNet/MgrNet/AllieNet/Solar are not officially supported any more.
SunNet:		
	cd $(sunnetDir); $(MAKE) "PROG = -Dsunnet $(TYPE)" "SKY = $(SKY)" SunNet
PlaNet:		
	cd $(planetDir); $(MAKE) "PROG = -Dplanet $(TYPE)" PlaNet
MgrNet:		
	cd $(mgrDir); $(MAKE) "PROG = -Dmgr $(TYPE)" MgrNet

AllieNet:	
	cd $(allieDir); $(MAKE) "PROG = -Dallie -Dplanet $(TYPE)" AllieNet
Solar:		
	cd $(sunnetDir); $(MAKE) "PROG = -Dsunnet $(TYPE)" Solar
cluster:	
	cd $(sunnetDir); $(MAKE) cluster

directory:	
	mkdir $(sunnetDir) $(planetDir) $(xnetDir) $(allieDir)

S=$(sourceDir)

alliant:
	cd $(allieDir); \
	ln -s $S/*.c $S/*.h $S/expr.* $S/help.h $S/psc.h $S/lib.h .; \
	for file in help.h psc.h expr.c; do if test -f $$file; \
	then ln -s $S/$$file .; fi; done
link:
	cd $(xnetDir);\
	ln -s $S/*.c $S/*.h $S/expr.y $S/expr.lex $S/i.xbm .;\
	make -f ../Makefile link2

link2:  help.h starhelp.h psc.h lib.h expr.c
		 
help.h: ; ln -s $S/help.h .
starhelp.h: ; ln -s $S/starhelp.h .
psc.h: ; ln -s $S/psc.h .
lib.h: ; ln -s $S/lib.h .
expr.c: ; ln -s $S/expr.c .

# The following is used for distribution & revision control purposes.

#       All the source type files - in directory "src".

Files.a=	alloc.c arith.c cluster.c help.c list.c net.c \
		y.tab.c lex.yy.c expr.y expr.lex 
Files.b=	netfind.c parameter.c print.c procedure.c rand.c setup.c vector.c
Files.c=	sunnet.c sunnetcomm.c sunnetio.c sunnetparam.c top.c netcommand.c
Files.d=	display.c graph.c graphinit.c xcore.c 
Files.e=	graphcomm.c Solar.c screen.c
Files.f=        alloc.h arith.h color.h vector.h version.h userdefs.h files.h \
                command.h error.h farith.f fmain.f fnet.f fnet.param xnetcore.h\
                graph.h xgraph.h list.h movie.h net.h parameter.h planetcore.h\
                setup.h stack.h suncorefunc.h sunnet.h time.h port.h msg.h \
		dprint.h mgrcore.h history.h  i.xbm 
#
# 	Files.g are in the main directory.

Files.g- =      sed.gethelp sed.helpfile \
		example psc.defs netcsh planet.el\
		Makefile Makefile.temp Tutorial Install RunNet README

Files.ksh=	RunNet.ksh netkorn

Files.g=        $(Files.g-) $(Files.ksh)

#
#	Files.ref are in the "doc" directory.

Files.ref=	Makefile README PlaNet.ref csl.macros \
		sed.graphref sed.parameter sed.ref \
		ref.macros ref.terminology ref.parameter \
		Copyright

Files.source =	$(Files.a) $(Files.b) $(Files.c) $(Files.d) $(Files.e) $(Files.f)
Files.rest = $(Files.g)

# to make a new release do:
#	make "VNAME = <version name>" "VLOG = <log message>" release
release: 	ci.all tarfile

# to make a tar file, do:
# 'make "TarFile = ..." tarfile'

TarFile =	PlaNet5.6.tar
Files.exclude = help.h starhelp.h psc.h lib.h

tarfile:
	cd src; mv $(Files.exclude) ..
	tar cf $(TarFile) src doc ref lib $(Files.rest)
	if test -f $(TarFile).Z ; then rm $(TarFile).Z; fi
	compress $(TarFile)
	mv $(Files.exclude) src

# to make a tar tape, do:
# 	make "TapeDrive = /dev/..." tartape
#
TapeDrive =	/dev/rst0

tartape:
	cd src; mv $(Files.exclude) ..
	tar cf $(TapeDrive) src doc lib $(Files.rest)
	mv $(Files.exclude) src

backup:;	tar cf $(TapeDrive) src doc RCS $(Files.rest)

# to make a tar file for the latex file for the User's Guide do:
# 	make tarfile.tex
#
TarFile.tex = PlaNet_doc.tar

tarfile.tex:
	cd doc.w/TeX;\
	tar cf ../../$(TarFile.tex) PlaNet_doc.tex PlaNet_doc.ind figs
	if test -f $(TarFile.tex).Z ; then rm $(TarFile.tex).Z; fi
	compress $(TarFile.tex)

# to check in source files to the RCS files, do:
#   make "VERSION = ..." "VLOG = <log message>" "VNAME = <version name>" ci
#
VLOG =		
VNAME =		
Files.rcs= Install Tutorial RunNet RunNet.ksh Makefile Makefile.temp

# 	to check in only the modified files
#
ci:	
	cd src; ci -q -u$(VERSION) "-m$(VLOG)" "-N$(VNAME)" $(Files.source)
	ci -q -u$(VERSION) "-m$(VLOG)" "-N$(VNAME)" $(Files.rcs)

#	to check in all files
#
ci.all:	
	cd src; ci -f -u$(VERSION) "-m$(VLOG)" "-N$(VNAME)" $(Files.source)
	ci  -f -u$(VERSION) "-m$(VLOG)" "-N$(VNAME)" $(Files.rcs)

#	to check in a new file(s), and unset lock.
#		make "VNAME=.." "VLOG=.." "FILE=file1 file2.." ci.new

ci.new: ; cd src; ci -u$(VERSION) "-m$(VLOG)" "-N$(VNAME)" $(FILE);rcs -U $(FILE)

FILE = $(Files.source)
TestDir = test

# to check out source files for a version from the RCS files for testing:
#   make "VERSION = ..." "DIR = <directory>" "FILE = <files>" co
#   	defaults: VERSION = the latest; DIR = test; FILE = all sources.

co:	;	cd $(TestDir); co -q -r$(VERSION) $(FILE)

# to copy all files to a remote host, do:
# 	make "TO = <remote host>" "DIR = <remote dir>" rcpto
# to copy all files from a remote host, do:
# 	make "FROM = <remote host>" "DIR = <remote dir>" rcpfrom
#
TO = fred
FROM = soma
DIR = planet

rcpto:	;	tar cf - $(FILE) | rsh $(TO) 'cd $(DIR); tar xf -'
	
rcpfrom: ;	rsh $(FROM) 'cd $(DIR); tar cf - $(FILE)' | tar xf -

# to mail uuencoded compressed tar files, do:
# 	make "To = recipient" tarmail
#
To =	
MAIL=	mail

ENCODE =	compress|uuencode

tarmail:	mail.a mail.b mail.c mail.d mail.e mail.f mail.g mail.ref \
		mail.readme
mail.a:;	cd src; tar cf - $(Files.a)| $(ENCODE) tar.a.Z \
					| $(MAIL) -s "files a" $(To)
mail.b:;	cd src; tar cf - $(Files.b)| $(ENCODE) tar.b.Z \
					| $(MAIL) -s "files b" $(To)
mail.c:;	cd src; tar cf - $(Files.c)| $(ENCODE) tar.c.Z \
					| $(MAIL) -s "files c" $(To)
mail.d:;	cd src; tar cf - $(Files.d)| $(ENCODE) tar.d.Z \
					| $(MAIL) -s "files d" $(To)
mail.e:;	cd src; tar cf - $(Files.e)| $(ENCODE) tar.e.Z \
					| $(MAIL) -s "files e" $(To)
mail.f:;	cd src; tar cf - $(Files.f)| $(ENCODE) tar.f.Z \
					| $(MAIL) -s "files f" $(To)
mail.g:;	tar cf - $(Files.g-) lib | $(ENCODE) tar.g.Z \
					| $(MAIL) -s "files g" $(To)
mail.ref:;	tar cf - ref | $(ENCODE) tar.ref.Z \
					| $(MAIL) -s "files ref" $(To)
mail.readme:;	cat MAIL.README | $(MAIL) $(To) miyata

# to mail uuencoded compressed tar files for the user's guide, do:
# 	make "To = recipient" tarmail.doc
#

tarmail.doc:	mail.doc1 mail.doc2 mail.doc3 mail.doc4 mail.doc5 mail.doc6\
		mail.doc.readme

mail.doc1:;	tar cf - doc/PlaNet_doc1.ps|$(ENCODE) tar.doc1.Z \
					| $(MAIL) -s "tar.doc1" $(To)
mail.doc2:;	tar cf - doc/PlaNet_doc2.ps|$(ENCODE) tar.doc2.Z \
					| $(MAIL) -s "tar.doc2" $(To)
mail.doc3:;	tar cf - doc/PlaNet_doc3.ps|$(ENCODE) tar.doc3.Z \
					| $(MAIL) -s "tar.doc3" $(To)
mail.doc4:;	tar cf - doc/PlaNet_doc4.ps|$(ENCODE) tar.doc4.Z \
					| $(MAIL) -s "tar.doc4" $(To)
mail.doc5:;	tar cf - doc/PlaNet_doc5.ps|$(ENCODE) tar.doc5.Z \
					| $(MAIL) -s "tar.doc5" $(To)
mail.doc6:;	tar cf - doc/PlaNet_doc6.ps|$(ENCODE) tar.doc6.Z \
					| $(MAIL) -s "tar.doc6" $(To)
mail.doc.readme:;cat DOC.README | $(MAIL) $(To) miyata

# To mail the latex file for the User's Guide do:
#	make "To = <recipient>" tarmail.tex
#

tarmail.tex:    mail.tex mail.figs tex.readme

mail.tex:;	cd doc.w/TeX; tar cf - PlaNet_doc.tex PlaNet_doc.ind | $(ENCODE) tex.tar.Z \
					| $(MAIL) -s "files tex" $(To)

tex.readme:;	cat TEX.README | $(MAIL) $(To) miyata
		
mail.figs:;	cd doc.w/TeX; tar cf - figs | $(ENCODE) figs.tar.Z \
					| $(MAIL) -s "files figs" $(To)

# To mail some files in uuencoded tar format do:
#	make "Files = <file1> <file2> .." "Label = <name of package>" "To = <recipient>" mail.file
#
mail.file:	
		tar cf - $(Files)| $(ENCODE) $(Label).tar.Z |$(MAIL) $(To)

# to create a patch file for making an old version up to date, do:
#	make "VERSION = <version name>" patch
#
patch:		$(Files.source)
	rcsdiff -c -r$(VERSION) $(Files.source) > patch.$(VERSION)

# this will make the patch file in compressed uuencoded form.
#	make "VERSION = <version name>" patch.encode
#
patch.encode:	$(Files.source)
	rcsdiff -c -r$(VERSION) $(Files.source) | \
		$(ENCODE) patch.$(VERSION).Z > patch.$(VERSION).Z.U

# to mail a patch file for an old version in compressed uuencoded form, do:
#	make "VERSION = <version name>" "To = recipient" patch.mail
#
patch.mail:	$(Files.source)
	cd src.w; rcsdiff -c -r$(VERSION) $(Files.source) \
	| compress |uuencode patch.$(VERSION).Z | $(MAIL) $(To)
	cat MAIL.PATCH | sed -e 's/VERSION/$(VERSION)/' \
	| $(MAIL) $(To) miyata

# if the patch is too large to send in one mail, use this:
#	make "VERSION = <version name>" "To = recipient" patch.mail.2

patch.mail.2:	$(Files.source)
	cd src.w; rcsdiff -c -r$(VERSION) $(Files.a) $(Files.b) $(Files.c) \
	| compress |uuencode patch.$(VERSION).1.Z | $(MAIL) $(To)
	cd src.w; rcsdiff -c -r$(VERSION) $(Files.d) $(Files.e)  $(Files.f) \
	| compress |uuencode patch.$(VERSION).2.Z | $(MAIL) $(To)
	cat MAIL.PATCH2| sed -e 's/VERSION/$(VERSION)/' \
	| $(MAIL) $(To) miyata

# to find out the size of the patch do :
#	make "VERSION = <version name>" patch.size

patch.size:	$(Files.a) $(Files.b) $(Files.c)
	cd src.w; rcsdiff -c -r$(VERSION) $(Files.source) | \
	$(ENCODE) patch.$(VERSION).Z | wc

diff:		$(Files.source)
	cd src.w; rcsdiff -r$(VERSION) $(Files.source) 

# to delete a version in the RCS files.
#	make "VERSION = <version name>" rcsdelete

rcsdelete:	; rcs -o$(VERSION) $(Files.source)

COM =
ARG =
FILES =
allfile:	; $(COM) $(Files.source) $(ARG)

eachsource:; for file in $(Files.source); do $(COM) $$file $(ARG); done

allset:		; $(COM) $(Files.a); $(COM) $(Files.b); $(COM) $(Files.c) \
		; $(COM) $(Files.d); $(COM) $(Files.e); $(COM) $(Files.f) \
		; $(COM) $(Files.g); $(COM) $(Files.ref)

updates:
	cd src; sed -n -f ../sed.update $(Files.source) |sed -e '/\*\*\*/d' > ../UPDATES
