# makefile for Okbridge 1.8
#
# Copyright (C) 1990-1992 by Matthew Clegg.  All Rights Reserved
# 
# OKbridge is made available as a free service to the Internet.
# Accordingly, the following restrictions are placed on its use:
# 
# 1.  OKbridge may not be modified in any way without the explicit 
#     permission of Matthew Clegg.  
# 
# 2.  OKbridge may not be used in any way for commercial advantage.
#     It may not be placed on for-profit networks or on for-profit
#     computer systems.  It may not be bundled as part of a package
#     or service provided by a for-profit organization.
# 
# If you have questions about restrictions on the use of OKbridge,
# write to mclegg@cs.ucsd.edu.
# 
# DISCLAIMER:  The user of OKbridge accepts full responsibility for any
# damage which may be caused by OKbridge.
# 


# In general the okbridge program can be compiled simply by
# typing 'make'.  If you are planning to install okbridge in
# a public directory, then you may want to first change the
# values of the variables OKBRIDGE_DIR and OKBRIDGE_HELPFILE.
# Then, type 'make install'.

OKBRIDGE_DIR = /usr/local/games
OKBRIDGE_BIN_DIR = $(OKBRIDGE_DIR)
OKBRIDGE_HELPFILE = $(OKBRIDGE_DIR)/okbridge.help
OKBRIDGE_NEWSFILE = $(OKBRIDGE_DIR)/okbridge.news
INSTALL = /usr/bin/install
STRIP = strip

# Thanks to George Ferguson of the University of Rochester, we now have
# a set of manual pages for okbridge.  To install these, change the
# following definitions as appropriate and type "make install.man"
MANDIR = /usr/local/man/man6
MANEXT = 6

# MACHINE SPECIFIC INFORMATION:
#
# Okbridge has been compiled and run successfully on the following systems:
#
#   Machine              OS                 Changes to Makefile
#   -------              --                 -------------------
#   Convex               ConvexOS (??)      FLAGS = -DCONVEX
#   Dec Vax or Risc      BSD UNIX 4.3       none
#   Dec Vax or Risc      ULTRIX V4.0 & 4.2  none
#   HP                   HP/UX              FLAGS = -DHPUX
#   IBM mini/mainframe   AIX 3.1            FLAGS = -DAIX
#   IBM PC               BSD/386            FLAGS = -DBSD386
#   IBM PC               SCO Unix           FLAGS = -DSCO
#                                           LDFLAGS = -lsocket
#   IBM PC               Xenix              FLAGS = -DXENIX
#                                           LDFLAGS = -lsocket -lucb -lnsl
#   NeXT                 NextStep 2.1/3.0   none
#   Sequent Symmetry     Dynix 3.2.0        FLAGS = -DDYNIX
#   SGI/Iris             IRIX               LDFLAGS = -lsun
#   Sun                  SunOS 4.1.x        none
#                        Solaris            FLAGS = -DSOLARIS
#                                           LDFLAGS = -lsocket -lnsl \
#                                             -L/usr/ccs/lib \
#                                             -L/usr/ucblib -lucb -lelf
#                                           INSTALL = /usr/ucb/install
#
# If you are compiling this program on a machine which is
# running IBM's AIX operating system, then uncomment the
# next line:
#MACHINE_FLAGS = -DAIX
#
# If you are running on an HP/UX system, you may need to uncomment
# the following line:
#MACHINE_FLAGS = -DHPUX
#
# For SCO Unix, uncomment the following three lines:
#MACHINE_FLAGS = -DSCO
#LDFLAGS = -lsocket
#INSTALL = cp
#
# For Xenix, uncomment the following three lines:
#MACHINE_FLAGS = -DXENIX
#LDFLAGS = -lsocket -lucb -lnsl
#INSTALL = cp
#
#Getting OKbridge to work under Solaris is a real bitch.  You first
#have to modify the LD_LIBRARY_PATH environment variable to include
#the library /usr/libucb.  In addition, you will need to uncomment
#the following lines:
#MACHINE_FLAGS = -DSOLARIS
#LDFLAGS = -lsocket -lnsl -L/usr/ccs/lib -L/usr/ucblib -lucb -lelf
#INSTALL = /usr/ucb/install
#
# If you are compiling this program on a machine which does not
# have strcasecmp and strncasecmp, then you will need to uncomment
# the following line (this is not necessary if you are using
# SunOS or a recent version of Ultrix):
#STRCASECMP = -DNO_STRCASECMP
#
# Some other machines do not store the 'gecos' field in the password file
# file entry.  If the player has not specified his/her name using the
# FULLNAME field in the .okbridgerc file, then we try to extract his
# name from the gecos field.  This is used in listing the current bridge
# players in the GPS.  If your machine cannot compile this code, then
# you will get a compile time error in network.c near line 500.  You
# should then uncomment the following line:
#PWCOMMENT = -DNO_PWCOMMENT
#

FLAGS = $(STRCASECMP) $(MACHINE_FLAGS) $(PWCOMMENT)

# The following flags may be useful if you have modified the okbridge
# program and you need assistance debugging it:
#
# CFLAGS = -g -DDEBUG -DLOGFILE -DMDEBUG
# MFLAGS = /usr/lib/debug/malloc.o
#
# CFLAGS = $(FLAGS) -g -DDEBUG -DLOGFILE
# CFLAGS = $(FLAGS) -g -DDEBUG
# CC = gcc
CFLAGS = $(FLAGS) -DHELPFILE=\"$(OKBRIDGE_HELPFILE)\" \
	-DNEWSFILE=\"$(OKBRIDGE_NEWSFILE)\" -g


# Sun people might like to define this to get pure executables.
#  pure = all code is in the binary
#  non-pure = code may use shared libs, and be demand-paged
# The advatages about pure code, is that you needn't worry about having the
# right version of the shared libs (important if run different versions 
# of the os), and if you store the binary on NFS, you aren't swapping
# code over the network.  Disadvantages is that the size of pure code is
# bigger, and might use more virtual mem (not using shared libs).
#
# For gcc on SunOS
# LDFLAGS= -static -n
# For cc on SunOS
# LDFLAGS= -Bstatic -n

OBJ = 	bridge.o input.o display.o terminal.o network.o help.o scoring.o\
 	boards.o cipher.o rc.o protocol.o parser.o nonstd.o socket.o\
	gps.o ccdef.o commands.o conversation.o cs.o log.o

SHUFFLEOBJ = okshuffle.o nonstd.o boards.o cipher.o scoring.o

TALLYOBJ = oktally.o nonstd.o boards.o cipher.o scoring.o log.o

HANDOBJ = okhand.o nonstd.o boards.o cipher.o scoring.o

COLLATEOBJ = collate.o boards.o cipher.o scoring.o skiplist.o log.o

all:	okbridge okshuffle oktally

okbridge:	$(OBJ)
	$(CC) -o okbridge $(OBJ) -lcurses -ltermcap $(LDFLAGS)

okshuffle:	$(SHUFFLEOBJ) types.h boards.h
	$(CC) -o okshuffle $(SHUFFLEOBJ) $(LDFLAGS)

oktally:	$(TALLYOBJ) types.h
	$(CC) -o oktally $(TALLYOBJ) $(LDFLAGS)

okhand:		$(HANDOBJ) types.h boards.h okhand.h
	$(CC) $(LDFLAGS) -o okhand $(HANDOBJ) -lcurses -ltermcap

collate:	$(COLLATEOBJ)
	$(CC) $(LDFLAGS) -o collate $(COLLATEOBJ)

install: install.bin install.help

install.bin:	okbridge okshuffle oktally
	$(STRIP) okbridge
	$(STRIP) okshuffle
	$(STRIP) oktally
	$(INSTALL) okbridge $(OKBRIDGE_BIN_DIR)
	$(INSTALL) okshuffle $(OKBRIDGE_BIN_DIR)
	$(INSTALL) oktally $(OKBRIDGE_BIN_DIR)

install.help:
#	$(INSTALL) -c -m 0644 okbridge.help $(OKBRIDGE_HELPFILE)
#	$(INSTALL) -c -m 0644 okbridge.news $(OKBRIDGE_NEWSFILE)
	$(INSTALL) okbridge.help $(OKBRIDGE_HELPFILE)
	$(INSTALL) okbridge.news $(OKBRIDGE_NEWSFILE)
	$(INSTALL) okbridgerc $(OKBRIDGE_DIR)
	

install.man:
	$(INSTALL) -c -m 0644 okbridge.man $(MANDIR)/okbridge.$(MANEXT)
	$(INSTALL) -c -m 0644 okshuffle.man $(MANDIR)/okshuffle.$(MANEXT)
	$(INSTALL) -c -m 0644 oktally.man $(MANDIR)/oktally.$(MANEXT)

clean:
	rm -f *.o 
	rm -f *~
	rm -f tmp*
	rm -f *.log
	rm -f *.zlog
	rm -f *.orig
	rm -f okbridge.hands okbridge.lib

veryclean:	clean
	rm -f okbridge okshuffle oktally gps_server core tags TAGS

distrib:	veryclean
		csh -f < MkDistrib

zip:		veryclean
		csh -fsb gzip < MkDistrib

bridge.o:	bridge.c state.h types.h network.h protocol.h\
                display.h input.h terminal.h help.h scoring.h parser.h\
		conversation.h ccdef.h

boards.o:	boards.c boards.h types.h cipher.h boards.h socket.h\
		parser.h protocol.h network.h scoring.h

ccdef.o:	ccdef.c

cipher.o:	cipher.h cipher.c

commands.o:	commands.h commands.c types.h parser.h state.h terminal.h \
		display.h input.h gps.h network.h

conversation.o:	conversation.h conversation.c types.h protocol.h network.h

cs.o:		cs.h cs.c socket.h state.h types.h network.h protocol.h gps.h

display.o:	display.h display.c terminal.h types.h state.h

gps.o:		gps.h gps_info.h parser.h gps.c conversation.h

gps_server.o:   $(GPSSRC) types.h boards.h gps_info.h socket.h
	        cp $(GPSSRC) gps_server.c
	        $(CC) -c $(CFLAGS) gps_server.c
	        rm gps_server.c

help.o:		help.h help.c types.h input.h terminal.h helpfile.h

input.o:	input.h input.c network.h terminal.h display.h\
		help.h input.h protocol.h state.h types.h conversation.h

log.o:		log.h log.c boards.h

network.o:	network.h network.c state.h types.h protocol.h socket.h

nonstd.o:	nonstd.c

parser.o:	parser.h parser.c

protocol.o:     protocol.h parser.h protocol.c types.h

rc.o:		rc.h rc.c types.h parser.h state.h network.h

scoring.o:	scoring.h scoring.c state.h types.h

socket.o:	socket.h socket.c

startup.o:	state.h types.h parser.h

terminal.o:	terminal.h terminal.c
