########################################################################
##
## Galaxy v3.41   Copyright (C) 1993 by Russel Wallace,
##		  and the Galaxy PBeM Development Group 
##
## Makefile for Galaxy v3.41 by Mayan Moudgill and Robert Stone
##
## Current GPDG contributors to the development of the main Galaxy
## engine include:
##
## Mayan Moudgill	- Source Reorganization
## Robert Stone		- Bug Fixes, Mail System, Misc Mods
## Graeme Griffith	- Command options
##
## 
## Check the settings in this file to make sure they are correct for your
## system.
##
########################################################################
VERSION=3.41# arbitrarily assigned version number :)
########################################################################

## Pick your compiler!
#CC= gcc			#the one we all know and love
CC= cc			#the one we all know, but have mixed feelings about
#CC= acc		#sun ANSI C compiler


## C Compiler Options.  
#CCOPTS= -Wall -O2 -s 	#optimize and strip for gcc
CCOPTS= -g		#debug
#CCOPTS= -O		#for those boring compilers with no -O2


## Executable name and
## install path
BINNAME= galaxy		#name of the binary/executable 
UPDNAME= upgrade
#install path.
BINPATH= /kazak1/beast/bin


## Includes, libs, etc
INCLUDE= 
LIBPATH=
LIBS=	 -lm		#needs math library on most systems

## install options
INSTALL=install
#INSTALL=cp		# don't have install?  Use this.
IFLAGS= -s -m 750	#strip, chmod 750


## shar options
SHARFILE= galaxy_v$(VERSION).shar
SHAR= shar
SHAROPTS= -c -pX

## tar options
DIRNAME= galaxy-$(VERSION)
TARFILE= galaxy_v$(VERSION).tar
TAR=tar
TAROPTS= -cvf

## mailing (the code) options
#MAILTO=
MAIL= elm -s 
UUENCODE= uuencode
COMPRESS= compress

########################################################################
####### You probably won't need to edit anything under this line #######
############ If you are only going to install the program ##############
########################################################################


CFLAGS = $(INCLUDE) $(CCOPTS)
LDFLAGS= $(LIBPATH) $(LIBS)


CFILES= main.c loadgame.c savegame.c creategame.c phase.c print.c \
	process.c report.c util.c mail.c
UPDCFLS= upgrade.c upgloadgame.c savegame.c util.c
SHFILES=mail_report.sh
HEADERS=proto.h galaxy.h process.h copyright.h
#script for mailing reports with sendmail
MAILREPORT=mail_report
OBJ =	$(CFILES:.c=.o)
UPDOBJ =$(UPDCFLS:.c=.o)
MAN = 
DOCS = doc/Galaxy_3.4
INFO = COPYRIGHT CHANGES MANIFEST README INSTALL $(MAN) $(DOCS)
FILES= $(INFO) $(CFILES) $(HEADERS) $(SHFILES) Makefile

### Skip .SCCS_GET for mailing!
# skip this rule altogether in fact.... aargh!
#.SCCS_GET:
#	test $(MAILTO) &&\
#	sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@ -G$@;

all: $(BINNAME) $(UPDNAME) $(MAILREPORT)

install: $(BINNAME) $(UPDNAME) $(MAILREPORT)
	$(INSTALL) $(IFLAGS) $(BINNAME) $(UPDNAME) $(BINPATH)/$(BINNAME)
	$(INSTALL) $(IFLAGS:-s=) $(MAILREPORT) $(BINPATH)/$(MAILREPORT)

lint: $(CFILES) $(HEADERS)
	$(LINT) $(LIBS) $(CFILES)

$(BINNAME): $(OBJ)
	$(CC)  $(CFLAGS) -o $(BINNAME) $(OBJ) $(LDFLAGS)

$(UPDNAME): $(UPDOBJ)
	$(CC)  $(CFLAGS) -o $(UPDNAME) $(UPDOBJ) $(LDFLAGS)

.c.o: galaxy.h
	$(CC) -c $(CFLAGS) $(INCLUDE) $*.c

galaxy.h: proto.h
process.c: process.h galaxy.h

clean: FORCE
	-rm -f galaxy upgrade *.o
	-rm mail_report

FORCE: #doesn't do anything

shar:	$(SHARFILE)

tar:	$(TARFILE)

$(SHARFILE): $(FILES)	
	$(SHAR) $(SHAROPTS) $(FILES) > $(SHARFILE)

$(TARFILE): $(FILES)
	(cd ..; $(TAR) $(TAROPTS) $(TARFILE) $(DIRNAME);)

archive: $(SHARFILE)
	mv $(SHARFILE) $(ARCPATH)
	rm -f $(ARCPATH)/$(ARCNAME).Z
	compress $(ARCPATH)/$(SHARFILE)
	ln -s $(ARCPATH)/$(SHARFILE).Z $(ARCPATH)/$(ARCNAME).Z
	
mailtar: $(FILES) clean
	#sccs clean
	(cd ..; $(TAR) $(TAROPTS) - $(DIRNAME) | $(COMPRESS) |\
	$(UUENCODE) $(TARFILE).Z | $(MAIL) $(TARFILE).Z.uu $(MAILTO); )

mailshar: $(FILES) clean
	#sccs clean
	$(SHAR) $(SHAROPTS) $(FILES) | $(MAIL) $(SHARFILE) $(MAILTO)

