# Makefile for Cygnus

include ../Makefile.inc

VERSION=0.2.0

OBJS=main.o rootserv.o nickserv.o chanserv.o memoserv.o process.o socket.o function.o server.o conf.o timeout.o help.o

all: version dbtool cygnus

clean:
	rm -f *.o cygnus dbtool;

distclean:
	rm -rf *.o cygnus dbtool ../inc/version.h ../inc/sysconf.h ../configure.cache ../Makefile.inc ../tmp ../makeconf.cache;

version:
	sh version.sh $(VERSION);

install:
	cp cygnus $(DEST)/cygnus
	@if [ ! -d $(DEST)/doc ] ; then \
		cp -r ../doc $(DEST)/doc; \
	fi
	@if [ ! -r $(DEST)/cygnus.conf ]; then \
		cp ../dist/cygnus.conf $(DEST)/cygnus.conf; \
	fi
	@if [ ! -r $(DEST)/cygnus.motd ] ; then \
		cp ../dist/cygnus.motd $(DEST)/cygnus.motd; \
	fi
	@if [ ! -r $(DEST)/csregister.email ] ; then \
		cp ../dist/csregister.email $(DEST)/csregister.email; \
	fi
	@if [ ! -r $(DEST)/cssendpass.email ] ; then \
		cp ../dist/cssendpass.email $(DEST)/cssendpass.email; \
	fi
	@if [ ! -r $(DEST)/nsregister.email ] ; then \
		cp ../dist/nsregister.email $(DEST)/nsregister.email; \
	fi
	@if [ ! -r $(DEST)/nschange.email ] ; then \
		cp ../dist/nschange.email $(DEST)/nschange.email; \
	fi
	@if [ ! -r $(DEST)/nssendpass.email ] ; then \
		cp ../dist/nssendpass.email $(DEST)/nssendpass.email; \
	fi
	@if [ ! -r $(DEST)/msmemomail.email ] ; then \
		cp ../dist/msmemomail.email $(DEST)/msmemomail.email; \
	fi
	@if [ ! -r $(DEST)/cygnus.news ] ; then \
		cp ../dist/cygnus.news $(DEST)/cygnus.news; \
	fi
	@if [ ! -r $(DEST)/nickserv.db ]; then \
		cp ../dist/nickserv.db $(DEST)/nickserv.db; \
	fi
	@if [ ! -r $(DEST)/chanserv.db ]; then \
		cp ../dist/chanserv.db $(DEST)/chanserv.db; \
	fi
	@if [ ! -r $(DEST)/rootserv.db ]; then \
		cp ../dist/rootserv.db $(DEST)/rootserv.db; \
	fi
	@if [ $(CONVERT) ] ; then \
		echo ""; \
		./dbtool; \
	fi
	../misc/makeconf -auto

dbtool:
	@if [ $(CONVERT) ] ; then \
		echo "$(CC) $(CFLAGS) $(LIBS) -o dbtool dbtool.c"; \
		$(CC) $(CFLAGS) $(LIBS) -o dbtool dbtool.c; \
	fi

cygnus: $(OBJS)
	$(CC) $(OBJS) $(LFLAGS) $(LIBS) -o $@

	@echo " ";
	@echo "*** Now run 'make install'.";
	@echo " ";

.c.o:
	$(CC) $(CFLAGS) -c $<

main.o:		main.c		../inc/services.h ../inc/config.h ../inc/sysconf.h
rootserv.o:	rootserv.c	../inc/services.h ../inc/config.h ../inc/sysconf.h
nickserv.o:	nickserv.c	../inc/services.h ../inc/config.h ../inc/sysconf.h
chanserv.o:	chanserv.c	../inc/services.h ../inc/config.h ../inc/sysconf.h
memoserv.o:	memoserv.c	../inc/services.h ../inc/config.h ../inc/sysconf.h
process.o:	process.c	../inc/services.h ../inc/config.h ../inc/sysconf.h
socket.o:	socket.c	../inc/services.h ../inc/config.h ../inc/sysconf.h
function.o:	function.c	../inc/services.h ../inc/config.h ../inc/sysconf.h
server.o:	server.c	../inc/services.h ../inc/config.h ../inc/sysconf.h
conf.o:		conf.c		../inc/services.h ../inc/config.h ../inc/sysconf.h
timeout.o:	timeout.c	../inc/services.h ../inc/config.h ../inc/sysconf.h
help.o:		help.c		../inc/services.h
