#include "../Calvin.tmpl"

   TOP = ..

#if !HaveRInt
RINT_SRCS = rint.c
RINT_OBJS = rint.o
#endif

#if !HaveRandom
RAND_SRCS = random.c
RAND_OBJS = random.o
#endif

#if UseERobot
EROBOT_SRCS = erobot.c
EROBOT_OBJS = erobot.o
#endif

COMMON_SRCS = sintab.c mypopen.c data.c sysdefaults.c util.c realnumships.c \
		$(RINT_SRCS) $(RAND_SRCS) $(EROBOT_SRCS)
COMMON_OBJS = sintab.o mypopen.o data.o sysdefaults.o util.o realnumships.o \
		$(RINT_OBJS) $(RAND_OBJS) $(EROBOT_OBJS)

#if RCDistress
RCD_SRCS = distress.c
RCD_OBJS = distress.o
#endif

#if RSA
RSA_SRCS = rsa_key.c rsa_util.c
RSA_OBJS = rsa_key.o rsa_util.o
#endif

#if Feature
FEATURE_SRCS = feature.c
FEATURE_OBJS = feature.o
#endif

#if BorgDetect
BD_SRCS = bd.c
BD_OBJS = bd.o
#endif

DAEMON_SRCS = daemonII.c
DAEMON_OBJS = daemonII.o $(COMMON_OBJS)

NTSERV_SRCS = coup.c death.c detonate.c enter.c findslot.c getentry.c \
	      getname.c getship.c input.c interface.c main.c mine.c orbit.c \
	      parsexbm.c \
	      plasma.c phaser.c redraw.c reserved.c ping.c socket.c smessage.c \
	      startdaemon.c torp.c transwarp.c warning.c
NTSERV_OBJS = coup.o death.o detonate.o enter.o findslot.o getentry.o \
	      getname.o getship.o input.o interface.o main.o mine.o orbit.o \
	      parsexbm.o \
	      plasma.o phaser.o redraw.o reserved.o ping.o socket.o smessage.o \
	      startdaemon.o torp.o transwarp.o warning.o $(COMMON_OBJS) \
	      $(RSA_OBJS) $(FEATURE_OBJS) $(RCD_OBJS) $(BD_OBJS) 

ROBOTII_SRCS = detonate.c enter.c getship.c interface.c phaser.c plasma.c \
	       robotII.c rmove.c startdaemon.c torp.c
ROBOTII_OBJS = detonate.o enter.o getship.o interface.o phaser.o plasma.o \
	       robotII.o rmove.o startdaemon.o torp.o $(COMMON_OBJS)

SNAKE_SRCS = enter.c getship.c snake.c snakemove.c startdaemon.c
SNAKE_OBJS = enter.o getship.o snake.o snakemove.o startdaemon.o $(COMMON_OBJS)

BIRD_SRCS = enter.c getship.c bird.c birdmove.c startdaemon.c
BIRD_OBJS = enter.o getship.o bird.o birdmove.o startdaemon.o $(COMMON_OBJS)

#if Organian
ORG_SRCS = enter.c getship.c organian.c orgmove.c startdaemon.c 
ORG_OBJS = enter.o getship.o organian.o orgmove.o startdaemon.o $(COMMON_OBJS)
#endif

#if Borg
BORG_SRCS = enter.c getship.c borg.c borgmove.c startdaemon.c 
BORG_OBJS = enter.o getship.o borg.o borgmove.o startdaemon.o $(COMMON_OBJS)
#endif

#if BasePractice
BASEP_SRCS = basep.c
BASEP_OBJS = basep.o $(COMMON_OBJS)
#endif

SRCS =  $(COMMON_SRCS) $(RSA_SRCS) $(DAEMON_SRCS) $(NTSERV_SRCS) \
	$(ROBOTII_SRCS) $(SNAKE_SRCS) $(BIRD_SRCS) $(BASEP_SRCS) \
	$(ORG_SRCS) $(BORG_SRCS) $(FEATURE_SRCS) $(RCD_SRCS) $(BD_SRCS)

AllTarget(daemonII)
NormalProgramTarget(daemonII, $(DAEMON_OBJS),,,)
AllTarget(ntserv)
NormalProgramTarget(ntserv, $(NTSERV_OBJS),,$(RSALIB),)
AllTarget(robotII)
NormalProgramTarget(robotII, $(ROBOTII_OBJS),,,)
AllTarget(snake)
NormalProgramTarget(snake, $(SNAKE_OBJS),,,)
AllTarget(bird)
NormalProgramTarget(bird, $(BIRD_OBJS),,,)
#if Organian
AllTarget(organian)
NormalProgramTarget(organian, $(ORG_OBJS),,,)
#endif
#if Borg
AllTarget(borg)
NormalProgramTarget(borg, $(BORG_OBJS),,,)
#endif
#if BasePractice
AllTarget(basep)
NormalProgramTarget(basep, $(BASEP_OBJS),,,)
#endif

DependTarget()

InstallProgram(daemonII, $(NETREK_BIN))
InstallProgram(ntserv, $(NETREK_BIN))
InstallProgram(robotII, $(NETREK_BIN))
InstallProgram(snake, $(NETREK_BIN))
InstallProgram(bird, $(NETREK_BIN))
#if Organian
InstallProgram(organian, $(NETREK_BIN))
#endif
#if Borg
InstallProgram(borg, $(NETREK_BIN))
#endif
#if BasePractice
InstallProgram(basep, $(NETREK_BIN))
#endif

Protos($(NETREK_INCLUDE)/ntserv_protos.h, $(NTSERV_SRCS) $(RSA_SRCS) $(COMMON_SRCS) $(FEATURE_SRCS) $(RCD_SRCS) $(BD_SRCS))
Protos($(NETREK_INCLUDE)/daemon_protos.h, $(DAEMON_SRCS) $(COMMON_SRCS))
Protos($(NETREK_INCLUDE)/robotII_protos.h, $(ROBOTII_SRCS) $(COMMON_SRCS))
Protos($(NETREK_INCLUDE)/snake_protos.h, $(SNAKE_SRCS) $(COMMON_SRCS))
Protos($(NETREK_INCLUDE)/bird_protos.h, $(BIRD_SRCS) $(COMMON_SRCS))
#if Organian
Protos($(NETREK_INCLUDE)/organian_protos.h, $(ORG_SRCS) $(COMMON_SRCS))
#endif
#if Borg
Protos($(NETREK_INCLUDE)/borg_protos.h, $(BORG_SRCS) $(COMMON_SRCS))
#endif
#if BasePractice
Protos($(NETREK_INCLUDE)/basep_protos.h, $(BASEP_SRCS) $(COMMON_SRCS))
#endif

SaberProgramTarget(ntserv,$(NTSERV_SRCS) $(COMMON_SRCS) $(RSA_SRCS) $(FEATURE_SRCS) $(RCD_SRCS) $(BD_SRCS),$(NTSERV_OBJS),$(RSALIB),)
SaberProgramTarget(daemonII,$(DAEMON_SRCS) $(COMMON_SRCS),$(DAEMON_OBJS),,)

#if Borg
SaberProgramTarget(borg,$(BORG_SRCS) $(COMMON_SRCS),$(BORG_OBJS),,)
#endif
