#	$Id: Makefile,v 1.13 1999/07/16 13:31:11 cameron Exp $	
#
#	Installers, you should not need to edit this file.
#	Everything should be setup in the configuration script.
#

CONFIG = system.mk

include $(CONFIG)

DEP_INCS = cflags.h ntserv/data.c ntserv/data.h ntserv/defs.h \
	config.h system.mk null

all: $(PMAKE) server utils startup rsa_utils do_xsg do_pledit do_robots

depend: system.mk
	cd ntserv;    $(MAKE) depend
	cd robots;    $(MAKE) depend
	cd newstartd; $(MAKE) depend
	cd tools;     $(MAKE) depend
	cd pledit;    $(MAKE) depend
	cd keycomp;   $(MAKE) depend
	cd sequencer; $(MAKE) depend
	cd xsg;       $(MAKE) depend
	cd pledit;    $(MAKE) depend
	-@if [ -f res-rsa/Makefile ]; then \
		(cd res-rsa; $(MAKE) depend) \
	fi

null: 
	touch null
	$(MAKE) depend

system.mk: system.mk.in config.h.in configure
	./configure -v

config.h: system.mk
	touch config.h

# make the server binaries and such
server: $(DEP_INCS) rsalib
	cd ntserv; $(MAKE)

do_robots: $(DEP_INCS)
	cd robots; $(MAKE)

do_xsg: $(DEP_INCS)
	cd xsg; $(MAKE);

do_pledit: $(DEP_INCS)
	cd pledit; $(MAKE) 


rsalib:	$(DEP_INCS)
	-@if [ -f res-rsa/Makefile ]; then \
		(cd res-rsa; $(MAKE) librsa.a) \
	fi

utils: $(DEP_INCS) rsalib
	cd tools; $(MAKE) 
	cd sequencer; $(MAKE)

rsa_utils: $(DEP_INCS)
	cd keycomp; $(MAKE)

startup: $(DEP_INCS)
	cd newstartd; $(MAKE)

cflags.h: Makefile $(CONFIG)
	cd ntserv;  $(MAKE) cflags

lint:
	cd ntserv;  $(MAKE) lint
	cd robots;  $(MAKE) lint
	cd keycomp; $(MAKE) lint
	cd tools;   $(MAKE) lint

clean:
	cd ntserv;    $(MAKE) clean
	cd robots;    $(MAKE) clean
	cd newstartd; $(MAKE) clean
	cd tools;     $(MAKE) clean
	cd pledit;    $(MAKE) clean
	cd sequencer; $(MAKE) clean
	cd keycomp;   $(MAKE) clean
	cd xsg;       $(MAKE) clean
	-@if [ -f res-rsa/Makefile ]; then \
		cd res-rsa; echo "	cd res-rsa; make clean"; $(MAKE) clean; \
	fi
	rm -f make.out name.o name cflags.h *~ #*#

reallyclean:
	cd ntserv;    $(MAKE) reallyclean
	cd robots;    $(MAKE) reallyclean
	cd newstartd; $(MAKE) reallyclean
	cd tools;     $(MAKE) reallyclean
	cd pledit;    $(MAKE) reallyclean
	cd sequencer; $(MAKE) reallyclean
	cd keycomp;   $(MAKE) reallyclean
	cd xsg;       $(MAKE) reallyclean
	-@if [ -f res-rsa/Makefile ]; then \
		cd res-rsa; echo "	cd res-rsa; make reallyclean"; \
		$(MAKE) reallyclean; \
	fi
	rm -f make.out cflags.h tools/trekon *~ #*#

installbin: all
	cd ntserv;    $(MAKE) install
	cd robots;    $(MAKE) install
	cd newstartd; $(MAKE) install
	-@if [ -f res-rsa/Makefile ]; then \
		cd res-rsa; echo "	cd res-rsa; make install"; $(MAKE) install; \
	fi
	cd tools;     $(MAKE) install
	cd keycomp;   $(MAKE) install
	cd pledit;    $(MAKE) install
	cd sequencer; $(MAKE) install
	cd xsg;       $(MAKE) install

install: installbin 
	cd docs;   $(MAKE) install
	cd tools;  $(MAKE) installtrekon
	-cd tools; ./convert
	@echo
	@echo "Vanilla Netrek Server installation is completed."
	@echo "To start your Netrek server, type $(LIBDIR)/netrekd"
	@echo "Then start a Netrek client with '-h localhost'"

name: name.c version.h patchlevel.h
	$(CC) $(CFLAGS) -DMVERS -o name name.c

solarispatches: name rmdependencies
	cd $(PATCHDIR)/Server; $(MAKE) name
	cd $(SOURCE)
	./patches

# for people on dynix, parallel compiling:
# /bin/make BINDIR="$(BINDIR)"parallel
#parallel: & pntserv startup xsg
# commented out because of all the whining from Ultrix and other people
# whose make BINDIR="$(BINDIR)"BINDIR="$(BINDIR)"barfs on it.  All I can say is: compile gnumake.


# more fun parallel compiling
pntserv:
	cd ntserv; /bin/make BINDIR="$(BINDIR)"BINDIR="$(BINDIR)"-P10 CC="$(CC)" EXTRALIBS="$(EXTRALIBS)" \
	    EXTRACFLAGS="$(EXTRACFLAGS)" XTREKDIR="$(XTREKDIR)" parallel

rmdependencies:
	cd ntserv;    $(MAKE) rmdependencies
	cd robots;    $(MAKE) rmdependencies
	cd newstartd; $(MAKE) rmdependencies
	cd tools;     $(MAKE) rmdependencies
	cd pledit;    $(MAKE) rmdependencies
	cd keycomp;   $(MAKE) rmdependencies
	cd sequencer; $(MAKE) rmdependencies
	cd xsg;       $(MAKE) rmdependencies
	-@if [ -f res-rsa/Makefile ]; then \
		cd res-rsa; echo "      cd res-rsa; make rmdependencies"; \
		$(MAKE) rmdependencies; \
	fi
