# Makefile for Services


include Makefile.inc


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

# Note that changing any of these options (or, in fact, anything in this
# file) will automatically cause a full rebuild of Services.

# Compilation options:
#	-DSKELETON	Compile a "skeleton" version of Services, with only
#			    OperServ enabled

CDEFS =

# Add any extra flags you want here.  The commented-out example line
# enables warnings on GCC (but disables parentheses warnings, because GCC
# complains about the perfectly reasonable construct "if (a = b)").

#MORE_CFLAGS =
MORE_CFLAGS = -Wall -Wno-parentheses


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


CFLAGS = $(CDEFS) $(BASE_CFLAGS) $(MORE_CFLAGS)


OBJS =	actions.o channels.o chanserv.o commands.o compat.o datafiles.o \
	encrypt.o helpserv.o init.o language.o list.o log.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 commands.c compat.c datafiles.c \
	encrypt.c helpserv.c init.c language.c list.c log.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

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


all: $(PROGRAM) languages

#/*boink*/
test: $(PROGRAM) do-test

do-test:
	$(MAKE) -C test test-services DATA_DIR=`pwd`/test/data
	rm -f test/data/services.log
	test/test-services $(TEST_OPTIONS) 0 ./services

#/*bonkle*/
myclean:
	rm -f *.o $(PROGRAM) listnicks listchans version.h.old

clean: myclean
	(cd lang ; $(MAKE) clean)

spotless: myclean
	(cd lang ; $(MAKE) spotless)
	rm -f config.cache configure.log sysconf.h Makefile.inc language.h

install: all
	$(INSTALL) services $(BINDEST)/services
	rm -f $(BINDEST)/listnicks $(BINDEST)/listchans
	ln $(BINDEST)/services $(BINDEST)/listnicks
	ln $(BINDEST)/services $(BINDEST)/listchans
	(cd lang ; $(MAKE) install)

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

########


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

languages: FRC
	(cd lang ; $(MAKE) CFLAGS="$(CFLAGS)")


# Catch any changes in compilation options at the top of this file
$(OBJS): Makefile

actions.o:	actions.c	services.h
channels.o:	channels.c	services.h
chanserv.o:	chanserv.c	services.h pseudo.h
commands.o:	commands.c	services.h commands.h language.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 language.h
init.o:		init.c		services.h
language.o:	language.c	services.h language.h
list.o:		list.c		services.h
log.o:		log.c		services.h
main.o:		main.c		services.h timeout.h version.h
memory.o:	memory.c	services.h
memoserv.o:	memoserv.c	services.h pseudo.h
messages.o:	messages.c	services.h messages.h language.h
misc.o:		misc.c		services.h
nickserv.o:	nickserv.c	services.h pseudo.h
operserv.o:	operserv.c	services.h pseudo.h
process.o:	process.c	services.h messages.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 $@

pseudo.h: commands.h language.h timeout.h encrypt.h
	touch $@

config.h: sysconf.h
	touch $@

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

language.h: lang/language.h
	cp -p lang/language.h .

lang/language.h: lang/Makefile lang/index
	(cd lang ; $(MAKE) language.h)

#/*boink*/
lang/index: lang/en_us.l
	$(MAKE) -C lang index

#/*bonkle*/
FRC:
