# Change CONFIG to the .mk file that matches your system

CONFIG = system.mk


# Do Not Change anything below this line. It should be setup in config

include ../$(CONFIG)

# this is for revised ntserv/struct.h

CFLAGS =  $(OPT) $(EXTRAINCS) $(DIRS) $(FLAGS)

LIBS = $(EXTRALIBS)

TOOLDIR= $(LIBDIR)/tools

GETPATH = getpath.o data.o

LINTFLAGS = -habxc $(EXTRAINCS) $(FLAGS)

#     Memory Objects

M_OBJS = data.o openmem.o


SRCS = loadchecker.c mess.c mergescores.c newscores.c \
       planets.c players.c scores.c setgalaxy.c \
       showgalaxy.c stat.c trimscores.c watchmes.c fun.c\
       xtkill.c keyman.c ../ntserv/getpath.c ../ntserv/data.c \
       ../ntserv/distress.c getship.c update.c openmem.c  \
       convert.c conq_vert.c ../ntserv/slotmaint.c $(RANDOMC) \
       sortdb.c ../robots/roboshar.c ../ntserv/smessage.c

EXECS =	loadchecker mess message newscores planets players scores \
        setgalaxy showgalaxy stat trimscores watchmes xtkill \
        mergescores keyman updated fun conq_vert convert sortdb cambot

all: $(PMAKE) $(EXECS)

clean: rmdependencies
	rm -f *.o *.ln

reallyclean:; rm -f $(EXECS) *~ #*#


install: $(EXECS) 
	-@if [ ! -d $(LIBDIR)/tools ]; then \
          /bin/mkdir $(LIBDIR)/tools; \
        fi
	$(INSTALL) $(INSTALLOPTS) loadchecker $(LIBDIR)/tools/loadchecker
	$(INSTALL) $(INSTALLOPTS) mess $(LIBDIR)/tools/mess
	$(INSTALL) $(INSTALLOPTS) message $(LIBDIR)/tools/message
	$(INSTALL) $(INSTALLOPTS) newscores $(LIBDIR)/tools/newscores
	$(INSTALL) $(INSTALLOPTS) planets $(LIBDIR)/tools/planets
	$(INSTALL) $(INSTALLOPTS) players $(LIBDIR)/tools/players
	$(INSTALL) $(INSTALLOPTS) scores $(LIBDIR)/tools/scores
	$(INSTALL) $(INSTALLOPTS) setgalaxy $(LIBDIR)/tools/setgalaxy
	$(INSTALL) $(INSTALLOPTS) showgalaxy $(LIBDIR)/tools/showgalaxy
	$(INSTALL) $(INSTALLOPTS) stat $(LIBDIR)/tools/stat
	$(INSTALL) $(INSTALLOPTS) trimscores $(LIBDIR)/tools/trimscores
	$(INSTALL) $(INSTALLOPTS) watchmes $(LIBDIR)/tools/watchmes
	$(INSTALL) $(INSTALLOPTS) xtkill $(LIBDIR)/tools/xtkill
	$(INSTALL) $(INSTALLOPTS) mergescores $(LIBDIR)/tools/mergescores
	$(INSTALL) $(INSTALLOPTS) keyman $(LIBDIR)/tools/keyman
	$(INSTALL) $(INSTALLOPTS) fun $(LIBDIR)/tools/fun
	$(INSTALL) $(INSTALLOPTS) sortdb $(LIBDIR)/tools/sortdb
	$(INSTALL) $(INSTALLOPTS) updated $(LIBDIR)/updated
	$(INSTALL) $(INSTALLOPTS) cambot $(LIBDIR)/cambot

cb_sock.o: packets.h ../ntserv/socket.c
#	$(CC) -o ./cb_sock.o -g $(CFLAGS) -DCAMBOT -c ../ntserv/socket.c

cambot: cambot.o $(M_OBJS) $(GETPATH)
	$(CC) -o $@ $(CFLAGS) cambot.o ../ntserv/genspkt.o ../ntserv/sysdefaults.o ../ntserv/getship.o ../ntserv/warning.o ../ntserv/smessage.o ../ntserv/distress.o $(M_OBJS) getpath.o

sortdb: sortdb.c struct.h defs.h
	$(CC) -o $@ $(CFLAGS) sortdb.c

loadchecker: loadchecker.o struct.h defs.h data.h $(M_OBJS)
	$(CC) -o $@ $(CFLAGS) loadchecker.o $(M_OBJS) $(LIBS)

mess: mess.o struct.h defs.h data.h $(M_OBJS)
	$(CC) -o $@ $(CFLAGS) mess.o $(M_OBJS) $(LIBS)

message: message.o struct.h defs.h data.h $(M_OBJS)
	$(CC) -o $@ $(CFLAGS) message.o $(M_OBJS) $(LIBS)

mergescores: mergescores.o $(GETPATH) struct.h defs.h
	$(CC) -o $@ $(CFLAGS) mergescores.o $(GETPATH) $(LIBS)

newscores: newscores.o $(GETPATH) struct.h defs.h
	$(CC) -o $@ $(CFLAGS) newscores.o $(GETPATH) $(LIBS)

planets: planets.o struct.h defs.h data.h $(M_OBJS)
	$(CC) -o $@ $(CFLAGS) planets.o $(M_OBJS) $(LIBS)

players: players.o struct.h defs.h data.h $(M_OBJS) $(RANDOMO)
	$(CC) -o $@ $(CFLAGS) players.o $(M_OBJS) $(RANDOMO) $(LIBS)

# some weird problem with the MIPS RISC compiler for DECstations...
# gcc seems to compile working executables (TC)
#
scores: scores.o $(GETPATH) struct.h defs.h
	$(CC) -o $@ $(CFLAGS) scores.o $(GETPATH) $(LIBS)
#	gcc -o $@ $(CFLAGS) -g scores.o -L/usr/users/terence/lib
#	cp scores /usr/users/terence/bin/trekscores

setgalaxy: setgalaxy.o $(RANDOMO) struct.h defs.h data.h $(M_OBJS)
	$(CC) -o $@ $(CFLAGS) setgalaxy.o $(RANDOMO) $(M_OBJS) $(LIBS)

showgalaxy: showgalaxy.o distress.o struct.h defs.h data.h $(M_OBJS)
	$(CC) -o $@ $(CFLAGS) showgalaxy.o distress.o $(M_OBJS) $(LIBS) -lcurses -ltermcap

stat: stat.o struct.h defs.h data.h $(M_OBJS)
	$(CC) -o $@ $(CFLAGS) stat.o $(M_OBJS) $(LIBS)

trimscores: trimscores.o $(GETPATH) struct.h defs.h
	$(CC) -o $@ $(CFLAGS) trimscores.o $(GETPATH) $(LIBS)

watchmes: watchmes.o distress.o struct.h defs.h data.h $(M_OBJS)
	$(CC) $(CFLAGS) watchmes.o distress.o $(M_OBJS) $(LIBS) -o $@

xtkill: xtkill.o $(GETPATH) struct.h getship.o data.h openmem.o slotmaint.o
	$(CC) -o $@ $(CFLAGS) xtkill.o getship.o openmem.o slotmaint.o $(GETPATH) $(LIBS)

keyman: keyman.o $(GETPATH) struct.h defs.h data.h
	$(CC) -o $@ $(CFLAGS) keyman.o $(GETPATH) $(LIBS)

fun: $(RANDOMO) fun.o struct.h defs.h data.h $(M_OBJS)
	$(CC) -o $@ $(CFLAGS) fun.o $(RANDOMO) $(M_OBJS) $(LIBS)

convert: $(GETPATH) convert.o struct.h defs.h data.h
	$(CC) -o $@ $(CFLAGS) convert.o $(GETPATH) $(LIBS)

updated: update.o data.o getpath.o
	$(CC) $(CFLAGS) -o updated  update.o data.o getpath.o $(EXTRALIBS)

conq_vert: conq_vert.o defs.h struct.h
	$(CC) -o $@ $(CFLAGS) conq_vert.o

trekon: mktrekon trekon.bitmap trekoff.bitmap
	./mktrekon $(LIBDIR)
	chmod a+x trekon

installtrekon: trekon
	@if [ -f $(LIBDIR)/trekon ]; then touch $(LIBDIR)/trekon; \
	 else cp trekon $(LIBDIR)/trekon; \
	 fi
	@if [ -f $(LIBDIR)/trekon.bitmap ]; then touch $(LIBDIR)/trekon.bitmap; \
	 else cp trekon.bitmap $(LIBDIR)/trekon.bitmap; \
	 fi
	@if [ -f $(LIBDIR)/trekoff.bitmap ]; then touch $(LIBDIR)/trekoff.bitmap; \
	 else cp trekoff.bitmap $(LIBDIR)/trekoff.bitmap; \
	 fi

lint: $(SRCS)
	lint $(LINTFLAGS) -u $?
	touch lint

depend:
	makedepend $(CFLAGS) -f Makefile $(SRCS)

rmdependencies:
	makedepend

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