# $Cambridge: hermes/src/prayer/Makefile,v 1.5 2008/10/02 07:07:03 dpc22 Exp $
# Prayer - a Webmail Interface
#
# Copyright (c) University of Cambridge 2000 - 2008
# See the file NOTICE for conditions of use and distribution.

ifeq ($(strip $(RPM_BUILD)), true)
include Config-RPM
else
include Config
endif

SUBDIRS = files lib shared session cmd templates servers utils

ifeq ($(strip $(ACCOUNTD_ENABLE)), true)
SUBDIRS += accountd
endif

all:
	for i in $(SUBDIRS); do $(MAKE) -C $$i all || exit; done

cert:
	(cd files; $(MAKE) cert)

install-cert:
	(cd files; $(MAKE) install-cert)

install:
	$(MAKE) -C files install
	$(MAKE) -C man   install
#	$(MAKE) -C templates install
	$(MAKE) -C servers install
	$(MAKE) -C utils install
ifeq ($(strip $(ACCOUNTD_ENABLE)), true)
	$(MAKE) -C accountd install
endif
ifeq ($(strip $(RPM_BUILD)), true)
	(cd files;  $(MAKE) redhat-install-init.d)
endif

redhat-start:
	(cd files; $(MAKE) redhat-install-init.d)
	chkconfig prayer --level 2345 on
	/etc/init.d/prayer start

redhat-stop:
	@if [ -x /etc/init.d/prayer ]; then \
	/etc/init.d/prayer stop; \
	fi

clean:
	rm -f core *.o *.flc *~ \#*\#
	rm -f defaults/*~ defaults/\#*\#
	rm -rf docs/*~ docs/\#*\#
	for i in $(SUBDIRS); do $(MAKE) -C $$i clean || exit; done

distclean: clean
	(cd files; $(MAKE) distclean)
	cp defaults/Config defaults/Config-RPM .
