# This makefile created on Wed Mar 17 13:00:47 EST 1993
# using create_makefile version 1.0.4
#  $Header: /navy/homes/zeus/SRC/RCS/Makefile,v 2.42 1994/05/17 13:43:15 bampton Exp bampton $
#
#  $Log: Makefile,v $
# Revision 2.42  1994/05/17  13:43:15  bampton
# *** empty log message ***
#
# Revision 2.41  1994/04/08  03:11:28  bampton
# Revision 2.40  1994/03/09  20:22:55  bampton
# Revision 2.39  1993/10/28  22:31:20  bampton
# Revision 2.38  1993/09/27  17:15:54  bampton
# Revision 2.37  1993/09/07  20:50:32  bampton
# Revision 2.36  1993/08/19  16:36:09  bampton
#

# ++++++++ Game Configure section ++++++++++

#put executable file name here
PROGRAM = Blind
PREPROCP = blind.dbg

# sort of Optional compilation flags
#game DEFINES (all optional features) = 
#          -DNEWGAME -DMINSEP=30.0 -DRANDPLACE -DCARRYOVER -DV3
#Preproc DEFINES =  -DSMART -DPREPROC -DFORECAST (plus above)

# Comment out lines which have undesired game features

# GM helper compile options.
#INTERACTIVE = -DINTERACTIVE # Not supported
BACKUPS = -DBACKUPS
#REPORTDIR = -DREPORTDIR=\"reports\"
#GAMENAME = -DGAMENAME
#FCASTNAMES = -DFCASTNAMES
VERBOSE = -DVERBOSE

# New Game setup compile options
#NEWGAME = -DNEWGAME
#RANDPLACE = -DRANDPLACE
#MINSEP = -DMINSEP=30.0

# Optional features
KCMD      = -DKCMD      # Add in the selective planet defense stuff
CARRYOVER = -DCARRYOVER # tech level info carries over from turn to turn 
V3        = -DV3        # add in more V3 stuff
UPGRADE = -DUPGRADE     # Add in Fleets and other V2.40 features

#Bug hackarounds, see INSTALL for info.
#BOMBBUG   = -DBOMBBUG
SIZEBUG = -DSIZEBUG
NONAMEBUG = -DNONAMEBUG # To fix C command games.

# Preprocessor switches
PREPROC = -DPREPROC
SMART = -DSMART
FORECAST = -DFORECAST

# Experimental switches
#FULL_REPORTS = -DFULL_REPORTS
#PASSWORDS = -DPASSWORDS

# ++++++ OS Dependant stuff ++++++++

#some machines may not like/honor this directive:
.KEEP_STATE::

# Put in debugging compuiler flags here (-g, or -ggdb for GNU's debugger)
# Or use -O if you trust the code that much...
DBGFLAGS = -ggdb

# These are the "Totally paranoid" flags, use them or not
PNOIDFLAGS = -Wconversion -Wstrict-prototypes -Wmissing-prototypes -ansi 
#-pedantic # Not too useful, as sun's header files aren't ansi....

# Put in OS flags (-DULTRIX for example), and other flags here:
# Note: some compilers/OS do not support -pipe
# For ULTRIX add -DULTRIX
# For HPUX/8.07 cc add -Aa
CFLAGS =  ${DBGFLAGS} -Wall  -c ${PNOIDFLAGS} -pipe 

# Put flags for ld here:
LDFLAGS =  ${DBGFLAGS} #-static

LINTFLAGS =  -abchn

RM = rm -f

# Put in your complier choice here. Note: It must be ansi compliant
CC = gcc

# Libraries needed. At least for SUNs and ULTRIX, this is just the math lib.
LIBS = -lm

# Copy flags
CP = cp -p

################################################
# You shouldn't need to edit anything below here
################################################

# Current version #
VER=2.42

#put source files here
# All C source files
SRCS =  Blind.c loadgame.c savegame.c report.c enterturn.c battle.c misc.c \
	edit.c addplayer.c turn.c new-game.c version.c cmds.c
# preprocessor source files
SRCP =  Blind.c loadgame.c report.c enterturn.c misc.c  version.c cmds.c
# FORECASTing preprocessor source files
SRCPP =  Blind.c loadgame.c report.c enterturn.c misc.c  version.c turn.c cmds.c
# New game source files
SRCN =  Blind.c loadgame.c report.c enterturn.c battle.c misc.c addplayer.c \
	new-game.c turn.c version.c cmds.c
# Game in progress source files
SRCG =  Blind.c loadgame.c savegame.c report.c enterturn.c battle.c misc.c  \
	turn.c new-game.c version.c cmds.c
# Game editor source files
SRCE =  edit.c loadgame.c savegame.c report.c enterturn.c misc.c version.c


#put object files here
OBJS =  Blind.o loadgame.o savegame.o report.o enterturn.o battle.o misc.o \
	edit.o addplayer.o turn.o new-game.o version.o cmds.o
OBJP =  Blind.o loadgame.o report.o enterturn.o misc.o battle.o version.o cmds.o
OBJPP =  Blind.o loadgame.o report.o enterturn.o misc.o battle.o version.o \
	turn.o cmds.o
OBJN =  Blind.o loadgame.o savegame.o report.o enterturn.o battle.o misc.o \
	addplayer.o new-game.o turn.o version.o cmds.o
OBJG =  Blind.o loadgame.o savegame.o report.o enterturn.o battle.o misc.o  turn.o new-game.o version.o cmds.o
OBJE =  edit.o loadgame.o savegame.o report.o enterturn.o misc.o version.o


# Put Header files here
HEADERS = common.h global.h prot.h 
PHEADERS = protos/new-game.h protos/report.h protos/battle.h  protos/version.h \
	protos/g-report.h protos/enterturn.h protos/misc.h protos/i-o.h protos/cmds.h

# Misc files to include
MISC = Makefile Readme To-Do Changes 
MISC2 = manifest
# Documentation stuff
DOCS = doc/Add-ons doc/FAQ doc/INSTALL doc/Notes doc/Ported doc/QuickRef doc/Rules doc/fleet.txt doc/intro

# Scripts that might be of use
SCRIPTS = support/README support/mailer 
S=scripts
SERVER = ${S}/ADDNEW ${S}/README ${S}/multi-forw ${S}/turn-over ${S}/MONITER  \
	${S}/body.awk ${S}/return.awk ${S}/turn-run ${S}/Pre-proc \
	${S}/game-forw ${S}/run ${S}/good-subject ${S}/p-Can-Fwd \
	${S}/blind-preproc.awk ${S}/v3-blind-preproc.awk

# The whole thing
ALLSRC = ${SRCS} ${HEADERS} ${PHEADERS} ${SERVER} ${SCRIPTS} ${MISC} ${DOCS} ${MISC2}

#Default action for make:
Blind:   ${OBJG}
	@if [ x${NEWGAME} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error ..."; \
	echo "NEWGAME defined. "; \
	echo "undefine, or 'make New-game'"; \
	echo ""; \
	exit 1; \
	fi
	@if [ x${PREPROC} = x  -a x${FORECAST} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error .."; \
	echo "PREPROC not defined, FORECAST defined "; \
	echo "undefine'"; \
	echo ""; \
	exit 1; \
	fi
	@if [ x${PREPROC} = x  -a x${SMART} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error .."; \
	echo "PREPROC not defined, SMART defined "; \
	echo "undefine'"; \
	echo ""; \
	exit 1; \
	fi
	${CC} $(LDFLAGS) ${OPTS} -o ${PROGRAM} ${OBJG} ${LIBS}

New-game: ${OBJN}
	@if [ x${NEWGAME} = x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error ..."; \
	echo "NEWGAME not defined. "; \
	echo "define, or 'make Blind'"; \
	echo ""; \
	exit 1; \
	fi
	@if [ x${PREPROC} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error .."; \
	echo "PREPROC defined. "; \
	echo "undefine'"; \
	echo ""; \
	exit 1; \
	fi
	@if [ x${PREPROC} = x  -a x${FORECAST} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error .."; \
	echo "PREPROC not defined, FORECAST defined "; \
	echo "undefine'"; \
	echo ""; \
	exit 1; \
	fi
	@if [ x${PREPROC} = x  -a x${SMART} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error .."; \
	echo "PREPROC not defined, SMART defined "; \
	echo "undefine'"; \
	echo ""; \
	exit 1; \
	fi
	${CC} $(LDFLAGS) ${OPTS} -o ${PROGRAM} ${OBJN} ${LIBS} 

blind.dbg:   $(OBJP)
	@if [ x${FORECAST} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error ..."; \
	echo "FORECAST defined, undefine, or build dbg-plus"; \
	echo ""; \
	exit 1; \
	fi
	@if [ x${NEWGAME} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error ..."; \
	echo "NEWGAME defined, undefine"; \
	echo ""; \
	exit 1; \
	fi
	@if [ x${PREPROC} = x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error .."; \
	echo "PREPROC not defined"; \
	echo ""; \
	exit 1; \
	fi
	${CC} $(LDFLAGS) ${OPTS} -o ${PREPROCP} ${OBJP} ${LIBS}

dbg-plus:   $(OBJPP)
	@if [ x${FORECAST} = x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error ..."; \
	echo "FORECAST not defined, define, or build blind.dbg"; \
	echo ""; \
	exit 1; \
	fi
	@if [ x${NEWGAME} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error ..."; \
	echo "NEWGAME defined, undefine"; \
	echo ""; \
	exit 1; \
	fi
	@if [ x${PREPROC} = x ] ; then \
	echo ""; \
	echo ""; \
	echo "Blind configure error .."; \
	echo "PREPROC not defined"; \
	echo ""; \
	exit 1; \
	fi
	${CC} $(LDFLAGS) ${OPTS} -o ${PREPROCP} ${OBJPP} ${LIBS}

edit: $(OBJE)
	${CC} $(LDFLAGS) ${DEFINES} ${OPTS} -o Edit $(OBJE) ${LIBS}

upgrade: ${OBJG} Fix
	@if [ x${PREPROC} != x ] ; then \
	echo ""; \
	echo ""; \
	echo "Upgrade configure error .."; \
	echo "PREPROC defined. "; \
	echo "undefine"; \
	echo ""; \
	exit 1; \
	fi
	${CC} loadgame.c ${CFLAGS} ${PREPOC} ${NEW} ${CARRYOVER} ${V3} ${KCMD} \
	-DBOMBBUG
	${CC} savegame.c ${CFLAGS} ${PREPOC} ${NEW} ${CARRYOVER} ${V3} ${KCMD} \
	-DFIX ${NONAMEBUG} ${GAMENAME}
	${CC} Blind.c ${CFLAGS} ${BACKUPS} ${NEWGAME} ${PREPROC} -DVER=${VER} \
	${UPGRADE} ${REPORTDIR} ${V3} ${CARRYOVER}  ${GAMENAME} -DFIX


	${CC} $(LDFLAGS) ${OPTS} -o Fix ${OBJG} ${LIBS}
	@echo ""; echo "";
	@echo "Making backup copy of blindrc: blindrc.orig"
	@${CP} blindrc blindrc.orig
	@if [ x${GAMENAME} != x ] ; then \
	echo "GAMENAME defined, see INSTALL for manual upgrade instrctions";\
	exit 1; \
	fi
	@echo "q" | Fix
	@echo "Conversion complete"

Blind.o: Blind.c
	${CC} $*.c ${CFLAGS} ${BACKUPS} ${NEWGAME} ${PREPROC} -DVER=${VER} \
	${UPGRADE} ${REPORTDIR} ${V3} ${CARRYOVER}  ${GAMENAME}

addplayer.o: addplayer.c
	${CC} $*.c ${CFLAGS} ${NEWGAME} ${RANDPLACE} ${MINSEP} ${V3} \
	${CARRYOVER} ${UPGRADE}

battle.o: battle.c
	${CC} $*.c ${CFLAGS} ${PREPROC} ${V3} ${VERBOSE} ${UPGRADE} ${CARRYOVER}

cmds.o: cmds.c
	${CC} $*.c ${CFLAGS} ${KCMD} ${PREPROC} ${V3} ${UPGRADE} ${SIZEBUG} \
	${CARRYOVER}

enterturn.o: enterturn.c
	${CC} $*.c ${CFLAGS} ${INTERACTIVE} ${KCMD} ${PREPROC} ${SMART} \
	${V3} ${FORECAST} ${UPGRADE} ${CARRYOVER} ${PASSWORDS}

loadgame.o: loadgame.c
	${CC} $*.c ${CFLAGS} ${PREPOC} ${CARRYOVER} ${V3} ${KCMD} \
	${BOMBBUG} ${UPGRADE} ${SIZEBUG} ${NONAMEBUG} ${GAMENAME}

misc.o: misc.c
	${CC} $*.c ${CFLAGS} ${CARRYOVER} ${PREPROC} ${V3} ${KCMD} \
	${UPGRADE} ${CARRYOVER}

new-game.o: new-game.c
	${CC} $*.c ${CFLAGS} ${NEWGAME} ${PREPROC} ${UPGRADE} ${GAMENAME} \
	${UPGRADE} ${V3} ${CARRYOVER}

report.o: report.c
	${CC} $*.c ${CFLAGS} ${CARRYOVER} ${FULL_REPORTS} ${PREPROC} ${V3} \
	${KCMD} -DVER=${VER} ${FORECAST} ${FCASTNAMES} ${UPGRADE}

savegame.o: savegame.c
	${CC} $*.c ${CFLAGS} ${PREPOC} ${CARRYOVER} ${V3} ${KCMD} ${UPGRADE} \
	${BOMBBUG} ${SIZEBUG} ${NONAMEBUG} ${GAMENAME}

turn.o: turn.c
	${CC} $*.c ${CFLAGS} ${PREPROC} ${FORECAST} ${VERBOSE} ${UPGRADE} \
	${V3} ${CARRYOVER}

version.o: version.c
	${CC} $*.c ${CFLAGS} ${BACKUPS} ${INTERACTIVE} ${FULL_REPORTS} \
	${CARRYOVER} ${V3} ${KCMD} ${RANDPLACE} ${MINSEP} ${NEWGAME} \
	${PREPROC} ${SMART} ${FORECAST} -DVER=${VER} ${BOMBBUG} ${UPGRADE} \
	${SIZEBUG}

#rule to follow for making object files form source files
#.c.o:; ${CC} ${CFLAGS} $*.c ${DEFINES}


build-dirs:;
	@if [ -d Blind-${VER} ] ; then \
	echo "Warning, directory exists" ; \
	else \
	mkdir Blind-${VER} Blind-${VER}/doc \
	Blind-${VER}/protos Blind-${VER}/scripts Blind-${VER}/support ; \
	fi
	${CP} ${SRCS} ${HEADERS} ${MISC} Blind-${VER}
	${CP} ${DOCS} Blind-${VER}/doc
	${CP} ${PHEADERS} Blind-${VER}/protos
	${CP} ${SERVER} Blind-${VER}/scripts
	${CP} ${SCRIPTS} Blind-${VER}/support

tar: ${ALLSRC} build-dirs manifest
	tar cvf blind-src-V${VER}.tar Blind-${VER}
	compress blind-src-V${VER}.tar

zip: ${ALLSRC} build-dirs manifest
	zip -r blind-src-V${VER}.zip Blind-${VER}

rcs-ver::
	ci -l${VER} ${SRCS} ${HEADERS} ${PHEADERS} Makefile ${SCRIPTS} ${SERVER}

clean::
	- ${RM} *.o *.ln *~ core


very-clean::
	${RM} *.o ${PROGRAM} ${PREPROCP} Edit *.ln blindrc forecast.F

print::
	enscript -2 -r -h ${SRCS} ${HEADERS} ${MISC} ${DOCS}


lint:           l${PROGRAM}.ln


manifest: build-dirs
	@echo "Files included in this release:" > Blind-${VER}/manifest
	@echo "" >> Blind-${VER}/manifest
	@ls -lR Blind-${VER} >> Blind-${VER}/manifest
	@echo "Made Blind-${VER}/manifest"

l${PROGRAM}.ln: ${SRCS}
	lint -C${PROGRAM} ${LINTFLAGS} ${SRCS}


Blind.o: common.h global.h prot.h protos/new-game.h
addplayer.c: common.h global.h 
battle.o: common.h global.h prot.h protos/battle.h
cmds.o: common.h prot.h protos/enterturn.h protos/cmds.h global.h
enterturn.o: common.h global.h prot.h protos/enterturn.h protos/cmds.h
loadgame.o: common.h global.h prot.h protos/i-o.h protos/misc.h
misc.o: common.h prot.h protos/misc.h global.h
new-game.o: common.h global.h prot.h protos/new-game.h
report.o: common.h global.h prot.h protos/report.h protos/g-report.h
savegame.o: common.h global.h prot.h protos/i-o.h protos/misc.h
turn.o: common.h global.h prot.h 
version.o: common.h global.h prot.h protos/version.h
edit.o: common.h prot.h protos/g-report.h global.h
Fix: loadgame.o savegame.o Blind.o

# If .KEEP_STATE is ignored, try uncommenting these out
#Blind.o: Makefile
#loadgame.o: Makefile
#savegame.o: Makefile
#report.o: Makefile
#enterturn.o: Makefile
#new-game.o: Makefile
#battle.o: Makefile
#turn.o: Makefile
#edit.o: Makefile
#misc.o: Makefile
#version.o: Makefile
