# Makefile for OperStats

include ../Makefile.inc

VERSION=1.2.0

OBJS=main.o shared.o operserv.o statserv.o process.o socket.o function.o server.o conf.o help.o

all: version operstats

clean:
	rm -f *.o operstats;

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

version:
	sh version.sh $(VERSION);

install:
	cp operstats $(DEST)/operstats;
	@if [ ! -d $(DEST)/doc ] ; then \
		cp -r ../doc $(DEST)/doc; \
	fi
	@if [ ! -r $(DEST)/operstats.conf ]; then \
		cp ../dist/operstats.conf $(DEST)/operstats.conf; \
	fi
	@if [ ! -r $(DEST)/operstats.tld ]; then \
		cp ../dist/operstats.tld $(DEST)/operstats.tld; \
	fi
	@if [ ! -r $(DEST)/operstats.zone ]; then \
		cp ../dist/operstats.zone $(DEST)/operstats.zone; \
	fi
	@if [ ! -r $(DEST)/operstats.motd ] ; then \
		cp ../dist/operstats.motd $(DEST)/operstats.motd; \
	fi
	@if [ ! -r $(DEST)/channels.ost ] ; then \
		cp ../dist/channels.ost $(DEST)/channels.ost; \
	fi
	@if [ ! -r $(DEST)/serverstats.ost ] ; then \
		cp ../dist/serverstats.ost $(DEST)/serverstats.ost; \
	fi
	@if [ ! -r $(DEST)/tldstats.ost ] ; then \
		cp ../dist/tldstats.ost $(DEST)/tldstats.ost; \
	fi
	../misc/makeconf -auto

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

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

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

main.o:		main.c		../inc/operstats.h ../inc/config.h ../inc/sysconf.h
shared.o:	shared.c	../inc/operstats.h ../inc/config.h ../inc/sysconf.h
operserv.o:	operserv.c	../inc/operstats.h ../inc/config.h ../inc/sysconf.h
statserv.o:	statserv.c	../inc/operstats.h ../inc/config.h ../inc/sysconf.h
process.o:	process.c	../inc/operstats.h ../inc/config.h ../inc/sysconf.h
socket.o:	socket.c	../inc/operstats.h ../inc/config.h ../inc/sysconf.h
function.o:	function.c	../inc/operstats.h ../inc/config.h ../inc/sysconf.h
server.o:	server.c	../inc/operstats.h ../inc/config.h ../inc/sysconf.h
conf.o:		conf.c		../inc/operstats.h ../inc/config.h ../inc/sysconf.h
help.o:		help.c		../inc/operstats.h ../inc/config.h
