# Makefile for Services


include Makefile.inc


########################## Configuration section ##########################


# Compilation options:
#	-DSKELETON	Compile a "skeleton" version of Services, with only
#			    OperServ enabled
#
# If you change this value, REMEMBER to "make clean", or you may
# (read: will) come out with a confused executable!

CDEFS =


######################## End configuration section ########################


CFLAGS = $(CDEFS) $(EXTRA_CFLAGS)


OBJS =	actions.o channels.o chanserv.o compat.o datafiles.o encrypt.o \
	helpserv.o list.o main.o memory.o memoserv.o messages.o misc.o \
	nickserv.o operserv.o process.o send.o sockutil.o timeout.o users.o
SRCS =	actions.c channels.c chanserv.c compat.c datafiles.c encrypt.c \
	helpserv.c list.c main.c memory.c memoserv.c messages.c misc.c \
	nickserv.c operserv.c process.c send.c sockutil.c timeout.c users.c


all: services

# Commented out--tests don't work
#test: services do-test
#
#do-test:
#	make -C test test-services DATA_DIR=`pwd`/test/data
#	test/test-services $(TEST_OPTIONS) 0 ./services

clean:
	/bin/rm -f *.o services listnicks listchans version.h.old

spotless: clean
	/bin/rm -f config.cache configure.log sysconf.h Makefile.inc

install: all
	$(INSTALL) services $(BINDEST)/services
	/bin/rm -f $(BINDEST)/listnicks $(BINDEST)/listchans
	ln $(BINDEST)/services $(BINDEST)/listnicks
	ln $(BINDEST)/services $(BINDEST)/listchans

install-data:
	$(CP_ALL) data/* $(DATDEST)
	@if [ "$(RUNGROUP)" ] ; then \
		echo chgrp -R $(RUNGROUP) $(DATDEST) ; \
		chgrp -R $(RUNGROUP) $(DATDEST) ; \
		echo chmod -R g+rw $(DATDEST) ; \
		chmod -R g+rw $(DATDEST) ; \
		echo chmod g+xs \`find $(DATDEST) -type d -print\` ; \
		chmod g+xs `find $(DATDEST) -type d -print` ; \
	fi

install-help:
	/bin/rm -rf $(DATDEST)/helpfiles/chanserv $(DATDEST)/helpfiles/memoserv $(DATDEST)/helpfiles/nickserv $(DATDEST)/helpfiles/operserv $(DATDEST)/helpfiles/ircii $(DATDEST)/helpfiles/help $(DATDEST)/helpfiles/index
	$(CP_ALL) data/helpfiles $(DATDEST)
	@if [ "$(RUNGROUP)" ] ; then \
		echo chgrp -R $(RUNGROUP) $(DATDEST)/helpfiles ; \
		chgrp -R $(RUNGROUP) $(DATDEST)/helpfiles ; \
		echo chmod -R g+rw $(DATDEST)/helpfiles ; \
		chmod -R g+rw $(DATDEST)/helpfiles ; \
		echo chmod g+xs \`find $(DATDEST)/helpfiles -type d -print\` ; \
		chmod g+xs `find $(DATDEST)/helpfiles -type d -print` ; \
	fi


########


services: version.h $(OBJS)
	$(CC) $(LFLAGS) $(LIBS) $(OBJS) -o $@


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

actions.o:	actions.c	services.h
channels.o:	channels.c	services.h
chanserv.o:	chanserv.c	cs-help.c services.h timeout.h encrypt.h
compat.o:	compat.c	services.h
datafiles.o:	datafiles.c	services.h
encrypt.o:	encrypt.c	encrypt.h sysconf.h
helpserv.o:	helpserv.c	services.h
list.o:		list.c		services.h
main.o:		main.c		services.h timeout.h
memory.o:	memory.c	services.h
memoserv.o:	memoserv.c	ms-help.c services.h
messages.o:	messages.c	messages.h
misc.o:		misc.c		services.h
nickserv.o:	nickserv.c	ns-help.c services.h timeout.h encrypt.h
operserv.o:	operserv.c	os-help.c services.h
process.o:	process.c	services.h messages.h version.h
send.o:		send.c		services.h
sockutil.o:	sockutil.c	services.h
timeout.o:	timeout.c	services.h timeout.h
users.o:	users.c		services.h


services.h: config.h extern.h
	touch $@

config.h: sysconf.h
	touch $@

version.h: Makefile version.sh services.h $(SRCS)
	sh version.sh
