#
#
#
#

BIN = /usr/local/games

CC = /usr/ccs/bin/cc -eft -Xa
#CC = gcc 
CCOPTS = -O
#CCOPTS = -g

DEBUG =
# override with make DEBUG=-DDEBUG


R_OBJS =    colors.o data.o death.o detonate.o defaults.o dmessage.o \
	    enter.o entrywin.o findslot.o getname.o getdefaults.o getship.o helpwin.o \
	    inform.o  input.o interface.o lagmeter.o netstat.o netstatopt.o newwin.o \
	    option.o planetlist.o planets.o playerlist.o ranklist.o \
	    redraw.o reserved.o rotate.o sintab.o  smessage.o  socket.o \
	    stats.o util.o war.o warning.o  udpopt.o ping.o pingstats.o

R_FILES =   colors.c data.c death.c detonate.c defaults.c dmessage.c \
	    enter.c entrywin.c findslot.c getname.c getdefaults.c getship.c helpwin.c \
	    inform.c  input.c interface.c lagmeter.c netstat.c netstatopt.c newwin.c \
	    option.c planetlist.c planets.c playerlist.c ranklist.c \
	    redraw.c reserved.c rotate.c sintab.c  smessage.c  socket.c \
	    stats.c util.c war.c warning.c  udpopt.c ping.c pingstats.c

INCLUDES = struct.h  packets.h  defs.h  copyright.h  copyright2.h bitmaps.h \
	    data.h oldbitmaps.h keys.h prog_version.h


RSA_FLAGS = -DRSA
RSA_FILES = rsa-client.c rsa_utilmp.c
RSA_OBJS  = rsa-client.o rsa_utilmp.o 
# use rsa_util.[co] if you  don't have libmp.a
#RSA_LIBS  = -L/usr/local/gnu/lib -lmp 
RSA_LIBS  = -L../gmp-1.2 -lmp

INPUT = 
MAINOBJ = main.o
MAINSRC = main.c
X10LIB = -lX
X10OBJS = x10window.o
#X11LIB = -L/usr/lib/X11 -lX11-mit
X11LIB = -lX11
X11OBJS = x11window.o
GLLIB = -lgl_s
GLOBJS = glwindow.o

DYN_FLAGS = -DDYNAMIC_BITMAPS
DYN_SRCS = bitmaps.c RotateBitmap.c
DYN_OBJS = bitmaps.o RotateBitmap.o

UTSLIBS = -lsocket -la -lbsd
LIBS = -lm $(UTSLIBS)
#  -static for static linking

# NBT		-- changes by nick trown
# TSH           -- changes by me
# TC            -- changes by Terence Chang
# PING		-- hadley ping code
# NBT		-- nick trown distress and macro code
# SGALAXY       -- changes by Jerry Frain & Joe Young
# ATM           -- changes by Andy McFadden
# RWATCH	-- for robot client only
# TCURSORS      -- cursors for different windows
# GODMESSAGE	-- message to GOD.
# EM		-- changes by ERic Mehlhaff (mehlhaff@soda.Berkeley.EDU)
# RSA		-- New RSA reserved packets stuff
# NETSTAT	-- Keep network statistics
# ROTATERACE	-- Rotate the galactic perspective
# DEBUG		-- Debugging info. 
# FOR_MORONS	-- Netrek For Morons 'info borg' client
# MOO		-- Mess of moo client features
# MOOBITMAPS	-- Strange 'moo' bitmaps, cursors
# VSHEILD_BITMAPS -- USe different shield bitmaps varying with damage
# MOOTCURSORS   -- shiptypes cursors in team windows
# MOOCURSORS	-- lame moo client cursors on tactical and galactic maps
# DYNAMIC_BITMAPS -- Lots of hacks to allow ship bitmaps to be be 
#		     manipulated at run-time.
#
# NO_TRAP	-- don't trap segmentation fault signals
# DEBUG		-- lots of annoying cebugging stuff
# BITMAP_DEBUG  -- show own ship as random other shiptype bitmaps 
#		   controlled from options window.


# to make a plain vanilla client, compile without -DRSA and
# make 'oldnetrek'

INCLUDES = -Ibitmaps -I/tmp/bits

CDEFS = -DPING -DNBT -DTSH -DPCLIENT -DGALAXY -DATM -DGODMESSAGE -DNOWARP \
	-DSYSTEM_DEFAULTFILE='"/usr/local/games/.netrekrc"' \
	-DEM  $(RSA_FLAGS) -DTCURSORS $(DEBUG) \
	-DNETSTAT -DROTATERACE -DPACKET_LOG -DFOR_MORONS \
	-DMOO -DMOOBITMAPS -DNEED_EXIT $(DYN_FLAGS) -DBITMAP_DEBUG \
	-DVSHIELD_BITMAPS -DMOOTCURSORS -DNO_TRAP -DCURSORFIX \
	-DGATEWAY -DTREKHOPD -DSYSV
#	-DSYSV

CFLAGS = $(CCOPTS) $(INCLUDES) $(CDEFS)

#	-DNEED_EXIT   
# some systems need exit() defined in socket.c, some don't
#
# -DSHORT_PACKETS   may or may not bee usable at calvin port 2594
#	But it _will_ end up being made better in NBR, so it's soon to be
#	dropped and/or obsoleted
#
#	-DMAXPLAYER=36
#       -DDEBUG    Various useful debugging stuff.  No signal trapping
#	-DPACKET_LOG	logging of packets -- see just how much net
#	    traffic your client is generating
# 

all : netrek

x10netrek: $(R_OBJS) $(MAINOBJ) $(INPUT) $(X10OBJS)
	$(CC) -o x10netrek $(R_OBJS) $(INPUT) $(MAINOBJ) $(X10OBJS) $(X10LIB) $(LIBS)

glnetrek: $(R_OBJS) $(MAINOBJ) $(INPUT) $(GLOBJS)
	$(CC) -o glnetrek $(R_OBJS) $(MAINOBJ) $(INPUT) $(GLOBJS) $(GLLIB) $(LIBS)

netrek: $(R_OBJS) $(MAINOBJ) $(INPUT) $(X11OBJS) $(RSA_OBJS) $(DYN_OBJS)
	$(CC) -O -o netrek $(R_OBJS) $(INPUT) $(MAINOBJ) $(X11OBJS) \
			$(RSA_OBJS) $(DYN_OBJS) $(X11LIB) $(RSA_LIBS) $(LIBS) 



netreko: $(R_OBJS) $(MAINOBJ) $(INPUT) $(X11OBJS) $(RSA_OBJS)
	$(CC) -O -o netrek $(R_OBJS) $(INPUT) $(MAINOBJ) $(X11OBJS) \
			$(RSA_OBJS) $(X11LIB) $(RSA_LIBS) $(LIBS) 

rsa_sockdet.o: key.h socket.c
	$(CC) $(CFLAGS) $(RSA_FLAGS) -c socket.c -o socket.o

clean:
	rm -f $(R_OBJS) $(MAINOBJ) $(INPUT) $(X10OBJS) $(X11OBJS) $(GLOBJS) make.out $(RSA_OBJS) $(DYN_OBJS)

reallyclean:   clean
	rm -f netrek glnetrek netrek.old x10netrek

tags: $(R_FILES)
	ctags $(R_FILES) $(INCLUDES)

archive: reallyclean
	cd ..; tar cf - client | compress - > client.tar.Z

expirationdate: expirationdate.c
	$(CC) $(CFLAGS)  expirationdate.c

RotateBitmap.o: RotateBitmap.c
	$(CC) $(CFLAGS) -DNETREK -DNO_READ_BITMAPFILE -DNO_X_HEADERS -c RotateBitmap.c

install: netrek
	mv netrek $(BIN)

#####

depend:
	makedepend $(CDEFS) -f Makefile $(MAINSRC) $(R_FILES) $(RSA_FILES) $(EXTRA_FILES)

# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.


# DO NOT DELETE THIS LINE -- make depend depends on it.

main.o: copyright.h /usr/include/stdio.h
main.o: /usr/include/string.h /usr/include/sys/types.h /usr/include/signal.h
main.o: /usr/include/setjmp.h /usr/include/pwd.h /usr/include/sys/time.h
main.o: /usr/include/sys/wait.h Wlib.h copyright2.h defs.h struct.h data.h
main.o: bitmapstuff.h packets.h prog_version.h
colors.o: copyright2.h /usr/include/stdio.h
colors.o: /usr/include/string.h Wlib.h defs.h copyright.h struct.h data.h
colors.o: bitmapstuff.h
data.o: copyright.h /usr/include/stdio.h Wlib.h
data.o: copyright2.h defs.h struct.h data.h bitmapstuff.h
death.o: copyright.h /usr/include/stdio.h
death.o: /usr/include/signal.h /usr/include/setjmp.h /usr/include/sys/types.h
death.o: /usr/include/sys/time.h Wlib.h copyright2.h defs.h struct.h data.h
death.o: bitmapstuff.h
detonate.o: copyright.h /usr/include/stdio.h
detonate.o: /usr/include/sys/types.h Wlib.h copyright2.h defs.h struct.h
detonate.o: data.h bitmapstuff.h
defaults.o: copyright2.h /usr/include/stdio.h
defaults.o: /usr/include/string.h /usr/include/ctype.h Wlib.h defs.h
defaults.o: copyright.h struct.h data.h bitmapstuff.h /usr/include/sys/file.h
dmessage.o: copyright.h /usr/include/stdio.h
dmessage.o: /usr/include/math.h Wlib.h copyright2.h defs.h struct.h data.h
dmessage.o: bitmapstuff.h
enter.o: copyright.h /usr/include/stdio.h
enter.o: /usr/include/sys/types.h /usr/include/errno.h /usr/include/pwd.h
enter.o: /usr/include/string.h /usr/include/ctype.h Wlib.h copyright2.h
enter.o: defs.h struct.h data.h bitmapstuff.h
entrywin.o: copyright.h /usr/include/stdio.h
entrywin.o: /usr/include/math.h /usr/include/signal.h
entrywin.o: /usr/include/sys/types.h /usr/include/sys/time.h Wlib.h
entrywin.o: copyright2.h defs.h struct.h data.h bitmapstuff.h packets.h
entrywin.o: bitmaps/clockbitmap.h
findslot.o: copyright2.h /usr/include/stdio.h
findslot.o: /usr/include/sys/types.h /usr/include/errno.h /usr/include/pwd.h
findslot.o: /usr/include/string.h /usr/include/ctype.h Wlib.h defs.h
findslot.o: copyright.h struct.h data.h bitmapstuff.h
getname.o: copyright2.h /usr/include/stdio.h
getname.o: /usr/include/sys/types.h /usr/include/sys/stat.h
getname.o: /usr/include/sys/file.h /usr/include/errno.h /usr/include/pwd.h
getname.o: /usr/include/string.h /usr/include/ctype.h Wlib.h defs.h
getname.o: copyright.h struct.h data.h bitmapstuff.h
getdefaults.o: copyright2.h /usr/include/stdio.h
getdefaults.o: Wlib.h defs.h copyright.h data.h bitmapstuff.h
getship.o: copyright.h /usr/include/stdio.h
getship.o: /usr/include/sys/types.h Wlib.h copyright2.h defs.h struct.h
getship.o: data.h bitmapstuff.h
helpwin.o: /usr/include/stdio.h
helpwin.o: /usr/include/math.h /usr/include/signal.h /usr/include/sys/types.h
helpwin.o: /usr/include/sys/time.h Wlib.h copyright2.h defs.h copyright.h
helpwin.o: struct.h data.h bitmapstuff.h /usr/include/string.h
inform.o: copyright.h /usr/include/stdio.h
inform.o: /usr/include/math.h /usr/include/signal.h Wlib.h copyright2.h
inform.o: defs.h struct.h data.h bitmapstuff.h
input.o: copyright.h /usr/include/stdio.h
input.o: /usr/include/math.h /usr/include/sys/types.h /usr/include/sys/time.h
input.o: /usr/include/signal.h /usr/include/errno.h Wlib.h copyright2.h
input.o: defs.h struct.h data.h bitmapstuff.h packets.h
interface.o: copyright.h /usr/include/stdio.h
interface.o: /usr/include/math.h /usr/include/sys/types.h
interface.o: /usr/include/sys/time.h /usr/include/sys/timeb.h
interface.o: /usr/include/signal.h Wlib.h copyright2.h defs.h struct.h data.h
interface.o: bitmapstuff.h packets.h
lagmeter.o: copyright.h /usr/include/stdio.h
lagmeter.o: /usr/include/ctype.h Wlib.h copyright2.h defs.h struct.h data.h
lagmeter.o: bitmapstuff.h packets.h
netstat.o: copyright2.h /usr/include/stdio.h
netstat.o: /usr/include/sys/types.h /usr/include/sys/socket.h
netstat.o: /usr/include/sys/time.h /usr/include/netinet/in.h
netstat.o: /usr/include/netinet/tcp.h /usr/include/netdb.h
netstat.o: /usr/include/math.h /usr/include/errno.h Wlib.h defs.h copyright.h
netstat.o: struct.h data.h bitmapstuff.h packets.h
netstatopt.o: copyright.h /usr/include/stdio.h
netstatopt.o: /usr/include/ctype.h Wlib.h copyright2.h defs.h struct.h data.h
netstatopt.o: bitmapstuff.h packets.h
newwin.o: copyright.h /usr/include/stdio.h
newwin.o: /usr/include/math.h /usr/include/signal.h /usr/include/sys/types.h
newwin.o: /usr/include/sys/time.h Wlib.h copyright2.h defs.h struct.h data.h
newwin.o: bitmapstuff.h bitmaps/bitmaps.h
newwin.o: bitmaps/miscbitmaps.h bitmaps/oldbitmaps.h
newwin.o: packets.h bitmaps/moobitmaps.h bitmaps/clockbitmap.h
option.o: copyright.h /usr/include/stdio.h
option.o: /usr/include/ctype.h Wlib.h copyright2.h defs.h struct.h data.h
option.o: bitmapstuff.h packets.h
planetlist.o: copyright.h /usr/include/stdio.h
planetlist.o: Wlib.h copyright2.h defs.h struct.h data.h bitmapstuff.h
planets.o: copyright2.h /usr/include/stdio.h
planets.o: /usr/include/math.h Wlib.h defs.h copyright.h struct.h data.h
planets.o: bitmapstuff.h
playerlist.o: copyright.h /usr/include/stdio.h
playerlist.o: Wlib.h copyright2.h defs.h struct.h data.h bitmapstuff.h
ranklist.o: copyright2.h /usr/include/stdio.h
ranklist.o: Wlib.h defs.h copyright.h struct.h data.h bitmapstuff.h
redraw.o: copyright.h /usr/include/stdio.h
redraw.o: /usr/include/signal.h /usr/include/math.h /usr/include/time.h
redraw.o: Wlib.h copyright2.h defs.h struct.h data.h bitmapstuff.h packets.h
reserved.o: copyright2.h /usr/include/stdio.h
reserved.o: /usr/include/sys/types.h /usr/include/sys/socket.h
reserved.o: /usr/include/netinet/in.h /usr/include/netdb.h defs.h copyright.h
reserved.o: packets.h
rotate.o: copyright2.h /usr/include/stdio.h
rotate.o: /usr/include/sys/types.h /usr/include/sys/socket.h
rotate.o: /usr/include/sys/time.h /usr/include/netinet/in.h
rotate.o: /usr/include/netinet/tcp.h /usr/include/netdb.h /usr/include/math.h
rotate.o: /usr/include/errno.h Wlib.h defs.h copyright.h struct.h data.h
rotate.o: bitmapstuff.h packets.h
sintab.o: copyright.h
smessage.o: copyright.h /usr/include/stdio.h
smessage.o: /usr/include/math.h /usr/include/signal.h /usr/include/ctype.h
smessage.o: Wlib.h copyright2.h defs.h struct.h data.h bitmapstuff.h
socket.o: copyright2.h /usr/include/stdio.h
socket.o: /usr/include/sys/types.h /usr/include/sys/socket.h
socket.o: /usr/include/sys/time.h /usr/include/netinet/in.h
socket.o: /usr/include/netinet/tcp.h /usr/include/netdb.h /usr/include/math.h
socket.o: /usr/include/errno.h Wlib.h defs.h copyright.h struct.h data.h
socket.o: bitmapstuff.h packets.h
stats.o: copyright.h /usr/include/stdio.h
stats.o: copyright2.h defs.h struct.h data.h bitmapstuff.h
util.o: copyright.h /usr/include/stdio.h
util.o: /usr/include/math.h /usr/include/signal.h Wlib.h copyright2.h defs.h
util.o: struct.h data.h bitmapstuff.h
war.o: copyright.h /usr/include/stdio.h
war.o: /usr/include/math.h /usr/include/signal.h Wlib.h copyright2.h defs.h
war.o: struct.h data.h bitmapstuff.h packets.h
warning.o: copyright.h /usr/include/stdio.h
warning.o: /usr/include/math.h /usr/include/signal.h Wlib.h copyright2.h
warning.o: defs.h struct.h data.h bitmapstuff.h
udpopt.o: copyright.h /usr/include/stdio.h
udpopt.o: /usr/include/ctype.h Wlib.h copyright2.h defs.h struct.h data.h
udpopt.o: bitmapstuff.h
ping.o: copyright2.h /usr/include/stdio.h
ping.o: /usr/include/sys/types.h /usr/include/sys/time.h /usr/include/math.h
ping.o: /usr/include/errno.h Wlib.h defs.h copyright.h struct.h data.h
ping.o: bitmapstuff.h packets.h
pingstats.o: copyright.h /usr/include/stdio.h
pingstats.o: /usr/include/math.h Wlib.h copyright2.h defs.h struct.h data.h
pingstats.o: bitmapstuff.h
rsa-client.o: copyright2.h /usr/include/stdio.h
rsa-client.o: /usr/include/sys/types.h /usr/include/sys/socket.h
rsa-client.o: /usr/include/netinet/in.h /usr/include/netdb.h defs.h
rsa-client.o: copyright.h packets.h Wlib.h data.h bitmapstuff.h keys.h
rsa_utilmp.o:
