#  PARADISE 2.2 CLIENT MAKEFILE
#

SHELL=/bin/sh

BIN = ../bin.udp

#comment out if you aren't compiling an authorizing client.

# if you DO have the MP library:
#MPLIBS= -lmp
#AUTH_OBJS = expire.o reserved.o rsa-client.o rsa_utilmp.o

# if you don't have the MP library:
#AUTH_OBJS = expire.o reserved.o rsa-client.o rsa_util.o

# if you're using the new BRMish key making facilities:
#MPLIBS= -lmp
#AUTH_OBJS = expire.o reserved.o rsa-client.o rsa_clientutil.o

# for any authorizing client
#AUTH_DEFS = -DAUTHORIZE

# slightly better hiding of the RSA key when the object files are linked in a
# random order.
#SCRAMBLER=perl scrambleargs.perl
SCRAMBLER=echo

# system paths.  
#X11HOME = -L${OPENWINHOME}/lib
#INCLUDEDIRS = -I${OPENWINHOME}/include

# Compiling this client with any flags other than the ones supplied can
# cause problems. Sorry.
#
# TSH           -- changes by T. Hadley
# TC            -- changes by Terence Chang
# SGALAXY       -- changes by Jerry Frain & Joe Young
# ATM           -- changes by Andy McFadden
# TCURSORS	-- special cursors
# RFCURSORS     -- so that it would compile on recumbents system, turn 
#                  this off if you don't have X11/Xmu/CurUtil.h
#                  this will disable the ability to define cursors in
#                  the .xtrekrc file.  If this is not defined, then
#                  you may remove -lXmu from the X11LIB variable above.
# ROTATERACE	-- galaxy rotation
# NOWARP	-- enable alternates to mouse pointer message warp
# EDEN		-- turn on partial eden 1.996c compatibility.
#		   Breaks everything else (plasma_info, MAXTORPS, MAXPLASMA)
# AUTHORIZE     -- turn on reserved.c and RSA authorization.  If you don't 
#		   define this, comment out AUTH_OBJS.
# SHORT_PACKETS -- Heiko Wengler's short packets.  Not prettily transplanted
#		   from Berkricksmoo2.0pl14.
# METASERVER    -- turns on -m metaserver support
# RS6K		-- must be defined for the IBM RS6000
# SVR4		-- must be defined for SVR4 (eg Solaris 2) machines (Bill Dyess)
# VARY_HULL     -- must be defined for vary hull feature (Bill Dyess)
# MACROS	-- must be defined for macros (Bill Dyess)
# TIMER		-- enables the dashboard timer (Bill Dyess)
# CONTINUOUS_MOUSE -- enable the continuous mouse code (Bill Dyess)
# XTREKRC_HELP  -- must be defined for .xtrekrc help window (Bill Dyess)
# PACKET_LIGHTS -- turns on packetLights (Bill Dyess)
# WIDE_PLIST    -- enables wide (fully configurable) playerlist (Bill Dyess)
#
# Must have -DATM, 
CDEFS = -DATM -DGODMESSAGE -DTCURSORS -DRFCURSORS -DROTATERACE -DNOWARP -DSHORT_PACKETS -DMETASERVER -DVARY_HULL -DMACROS -DTIMER -DCONTINUOUS_MOUSE -DXTREKRC_HELP -DPACKET_LIGHTS -DWIDE_PLIST $(AUTH_DEFS) $(SYSDEFS)
     

R_OBJS =    ${AUTH_OBJS} \
	colors.o \
	dashboard.o \
	data.o \
	death.o \
	detonate.o \
	defaults.o \
	defwin.o \
	distress.o \
	dmessage.o \
	enter.o \
	findslot.o \
	gameconf.o \
	getname.o \
	getship.o \
	helpwin.o \
	inform.o \
	interface.o \
	keymap.o \
	macros.o \
	macrowin.o \
	motdwin.o \
	newwin.o \
	option.o \
	parsemeta.o \
	planetlist.o \
	planets.o \
	playerlist.o \
	ranklist.o \
	ratings.o \
	rotate.o \
	shipbitmaps.o \
	sintab.o \
	smessage.o \
	socket.o \
	stats.o \
	util.o \
	varydamage.o \
	war.o \
	warning.o \
	udpopt.o \
	blk_parsemotd.o \
	shortcomm.o spopt.o \
	ping.o pingstats.o \
	wide_plist.o 
#	/usr/lib/debug/malloc.o


R_FILES =   colors.c \
	    dashboard.c \
	    data.c \
	    death.c \
	    detonate.c \
	    defaults.c \
	    defwin.c \
	    distress.c \
	    dmessage.c \
	    enter.c \
	    findslot.c \
	    getname.c \
	    getship.c \
	    helpwin.c \
	    inform.c \
	    input.c \
	    interface.c \
	    keymap.c \
	    macros.c \
	    macrowin.c \
	    motdwin.c \
	    newwin.c \
	    option.c \
	    parsemeta.c \
	    planetlist.c \
	    planets.c \
	    playerlist.c \
	    ranklist.c \
	    ratings.c \
	    redraw.c \
	    reserved.c \
	    rotate.c \
	    rsa-client.c \
	    rsa_util.c \
	    sintab.c \
	    smessage.c \
	    socket.c \
	    stats.c \
	    util.c \
	    varydamage.c \
	    war.c \
	    warning.c \
	    udpopt.c \
	    blk_parsemotd.c \
	    wide_plist.c 

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

INPUT = input.o redraw.o
MAINOBJ = main.o
MAINSRC = main.c

X10LIB = -lX
X10OBJS = x10window.o

X11LIB = $(X11HOME) -lX11 -lXmu
X11SRC = x11window.c
X11OBJS = x11window.o

GLLIB = -lgl_s
GLOBJS = glwindow.o

LIBS = $(SYSLIBS) $(MPLIBS) -lm

#CC = cc
#CC = cc -pipe
#CC = gcc-2.3.3
LINKSTATIC=-Bstatic

# for gcc, it has a different static linking convention
#CC = gcc ${GCCOPT} -W -Wreturn-type -Wunused -Wswitch -Wtrigraphs -Wformat \
#            -Wchar-subscripts -Wuninitialized -Wparentheses
#LINKSTATIC=-static

CDEBUGFLAGS=-O
#CDEBUGFLAGS=-g
GCCOPT=-O   #gcc can optimize and emit debug symbols at the same time

CFLAGS =  $(CDEFS) $(SYSCFLAGS) $(CDEBUGFLAGS) -I/local/include $(INCLUDEDIRS)

all: help

help:
	@echo 'Use make <parameter> where <parameter> is one of the following:'
	@echo '	generic		generic system.'
	@echo '	sun4		SunOS 4.1.x type machines.'
	@echo '	sun4d		SunOS 4.1.x type machines (dynamic linking).'
	@echo '	sun4strict	SunOS 4.1.x type machines (strict compiling).'
	@echo '	sol		Solaris 2.x machines.'
	@echo '	solstatic	Solaris 2.x (static linking).'
	@echo '	solstrict	Solaris 2.x (strict compiling).'
	@echo '	rs6k		RS6000 based machines.'
	@echo '	X10		X10-based client.'
	@echo '	clean		clean up this directory.'
	@echo '	depend		update dependency information.'
	@echo '	soldep		update dependency information for Solaris.'

generic: netrek.paradise

sun4 : udp_client.sun4_static

sun4strict: 
	make udp_client.sun4_static "LINKSTATIC=-static" "CC=gcc ${GCCOPT} -W -Wreturn-type -Wunused -Wswitch -Wtrigraphs -Wformat -Wchar-subscripts -Wparentheses"

sun4d : udp_client.sun4

sol: 
	make paradise.solaris SYSCFLAGS=-Xc SYSDEFS=-DSVR4 "SYSLIBS=-lnsl -lsocket"

solstatic: 
	make paradise.solaris.static SYSDEFS=-DSVR4 "SYSLIBS=-lnsl -lsocket"

solstrict: 
	make paradise.solaris SYSDEFS=-DSVR4 "SYSLIBS=-lnsl -lsocket" "LINKSTATIC=-static" "CC=gcc ${GCCOPT} -W -Wreturn-type -Wunused -Wswitch -Wtrigraphs -Wformat -Wchar-subscripts -Wparentheses"

soldep: 
	make depend SYSDEFS=-DSVR4

dep: depend

rs6k:
	make generic SYSDEFS=-DRS6K SYSLIBS=-lbsd

X10: x10netrek

# does this think work anymore?
x10netrek: $(R_OBJS) $(MAINOBJ) $(INPUT) $(X10OBJS)
	rm -f $@
	$(CC) -o x10netrek $(R_OBJS) $(INPUT) $(MAINOBJ) $(X10OBJS) $(X10LIB) $(LIBS)

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

netrek.paradise : $(R_OBJS) $(MAINOBJ) $(INPUT) $(X11OBJS)
	rm -f $@
	$(CC) $(CFLAGS) -o $@ `$(SCRAMBLER) $(R_OBJS) $(INPUT) $(MAINOBJ) $(X11OBJS)` $(X11LIB) $(LIBS)
	-chmod 644 *.o
	-chmod 755 netrek.paradise

udp_client.sun4_static : $(R_OBJS) $(MAINOBJ) $(INPUT) $(X11OBJS)
	rm -f $@
	$(CC) $(CDEBUGFLAGS) -o udp_client.sun4_static  $(R_OBJS) $(INPUT) $(MAINOBJ) $(X11OBJS) ${LINKSTATIC} $(X11LIB) $(LIBS)
	strip $@

udp_client.sun4 : $(R_OBJS) $(MAINOBJ) $(INPUT) $(X11OBJS)
	rm -f $@
	$(CC) $(CDEBUGFLAGS) -o udp_client.sun4  $(R_OBJS) $(INPUT) $(MAINOBJ) $(X11OBJS) $(X11LIB) $(LIBS)
	strip $@

paradise.solaris : $(R_OBJS) $(MAINOBJ) $(INPUT) $(X11OBJS)
	rm -f $@
	$(CC) $(CDEBUGFLAGS) -o paradise.solaris  `$(SCRAMBLER) $(R_OBJS) $(INPUT) $(MAINOBJ) $(X11OBJS)` $(X11LIB) $(LIBS)
	strip $@

paradise.solaris.static : $(R_OBJS) $(MAINOBJ) $(INPUT) $(X11OBJS)
	rm -f $@
	$(CC) $(CDEBUGFLAGS) -o $@ `$(SCRAMBLER) $(R_OBJS) $(INPUT) $(MAINOBJ) $(X11OBJS)` -ldl -lintl -lw -Bstatic $(X11LIB) $(LIBS) 
	strip $@

rwatch: $(R_OBJS) $(MAINOBJ) $(INPUT) $(X11OBJS)
	rm -f $@
	$(CC) $(CDEBUGFLAGS) -o rwatch $(R_OBJS) $(INPUT) $(MAINOBJ) $(X11OBJS) $(X11LIB) $(LIBS)

clean:
	rm -f $(R_OBJS) $(MAINOBJ) $(INPUT) $(X10OBJS) $(X11OBJS) $(GLOBJS)

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

install: netrek
	mv netrek $(BIN)

#####

depend:
	makedepend $(CDEFS) -f Makefile -I${OPENWINHOME}/include $(MAINSRC) $(R_FILES) $(X11SRC)

# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
blk_parsemotd.o : blk_parsemotd.c Wlib.h copyright2.h defs.h copyright.h struct.h \
  data.h proto.h 
colors.o : colors.c copyright2.h Wlib.h defs.h copyright.h struct.h data.h proto.h 
dashboard.o : dashboard.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h \
  proto.h 
data.o : data.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h proto.h 
death.o : death.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h proto.h \
  gameconf.h 
defaults.o : defaults.c copyright2.h Wlib.h defs.h copyright.h struct.h data.h \
  proto.h 
defwin.o : defwin.c 
detonate.o : detonate.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h \
  proto.h 
distress.o : distress.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h \
  gameconf.h proto.h 
dmessage.o : dmessage.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h \
  proto.h 
enter.o : enter.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h proto.h \
  packets.h 
expire.o : expire.c 
findslot.o : findslot.c copyright2.h Wlib.h defs.h copyright.h struct.h data.h \
  proto.h 
gameconf.o : gameconf.c gameconf.h Wlib.h copyright2.h proto.h defaultlogos.h \
  data.h copyright.h struct.h defs.h gppackets.h packets.h 
getname.o : getname.c copyright2.h Wlib.h defs.h copyright.h struct.h data.h \
  proto.h 
getship.o : getship.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h \
  proto.h 
helpwin.o : helpwin.c Wlib.h copyright2.h defs.h copyright.h struct.h data.h 
inform.o : inform.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h proto.h \
  gameconf.h 
input.o : input.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h packets.h \
  proto.h 
interface.o : interface.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h \
  packets.h proto.h 
keymap.o : keymap.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h proto.h 
macros.o : macros.c 
macrowin.o : macrowin.c 
main.o : main.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h packets.h \
  proto.h gameconf.h 
motdwin.o : motdwin.c \
  Wlib.h copyright2.h defs.h copyright.h struct.h data.h 
newwin.o : newwin.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h gameconf.h \
  proto.h oldbitmaps.h bitmaps_pr.h bitmaps3.h hullbitmaps.h planetbitmaps.h packets.h 
option.o : option.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h packets.h \
  proto.h 
parsemeta.o : parsemeta.c 
ping.o : ping.c copyright2.h Wlib.h defs.h copyright.h struct.h data.h packets.h \
  proto.h 
pingstats.o : pingstats.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h \
  proto.h 
planetlist.o : planetlist.c copyright.h Wlib.h copyright2.h defs.h struct.h \
  data.h proto.h 
planets.o : planets.c copyright2.h Wlib.h defs.h copyright.h struct.h data.h \
  proto.h 
playerlist.o : playerlist.c copyright.h Wlib.h copyright2.h defs.h struct.h \
  data.h proto.h gameconf.h 
ranklist.o : ranklist.c copyright2.h Wlib.h defs.h copyright.h struct.h data.h \
  proto.h 
redraw.o : redraw.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h packets.h \
  proto.h gameconf.h 
reserved.o : reserved.c copyright2.h defs.h copyright.h packets.h 
rotate.o : rotate.c copyright2.h Wlib.h defs.h copyright.h struct.h data.h packets.h 
rsa-client.o : rsa-client.c copyright2.h defs.h copyright.h packets.h Wlib.h \
  struct.h data.h keys.h 
rsa_util.o : rsa_util.c 
rsa_utilmp.o : rsa_utilmp.c 
senddist.o : senddist.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h 
shipbitmaps.o : shipbitmaps.c Wlib.h copyright2.h defs.h copyright.h struct.h \
  data.h gameconf.h proto.h bitmaps_NEW.h 
shortcomm.o : shortcomm.c 
sintab.o : sintab.c copyright.h 
smessage.o : smessage.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h \
  proto.h gameconf.h 
socket.o : socket.c copyright2.h Wlib.h defs.h copyright.h struct.h data.h packets.h \
  proto.h gameconf.h 
spopt.o : spopt.c 
stats.o : stats.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h proto.h 
udpopt.o : udpopt.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h proto.h 
util.o : util.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h proto.h \
  gameconf.h 
varydamage.o : varydamage.c copyright.h Wlib.h copyright2.h defs.h struct.h \
  data.h packets.h proto.h gameconf.h 
war.o : war.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h packets.h \
  proto.h 
warning.o : warning.c copyright.h Wlib.h copyright2.h defs.h struct.h data.h 
x11window.o : x11window.c Wlib.h copyright2.h defs.h copyright.h struct.h data.h \
  proto.h 
