# file: src/common/etc/Makefile
#
#  2001 OpenCA Group

TOP	= ../../..
include $(TOP)/Makefile.global-vars

SUBDIRS	= \
	bp		\
	database	\
	openssl		\
	rbac

ETC_DIRS = \
	access_control/		\
	bp/			\
	database/		\
	init.d/			\
	openssl/		\
	openssl/openssl/	\
	openssl/extfiles/	\
	rbac/			\
	rbac/cmds/		\
	scep/			\
	servers/

STATIC_FILES	= \

AC_FILES	= \
	config.xml	\
	log.xml		\
	token.xml	\
	loa.xml

TEMPLATE_FILES = \
	backup.xml.template	\
	ldap.xml.template	\
	menu.xml.template

FILES = $(STATIC_FILES) $(AC_FILES) $(TEMPLATE_FILES)

PROGS	= \
	configure_etc.sh	\
	openca_start.template	\
	openca_stop.template	\
	openca_rc               \
        utf8_latin1_selector.sh.template

#---- variable settings above, rules below ----

.PHONY:	default test install install-conf clean distclean

default::	openssl

test::

install::	$(etc_prefix)

install-conf::	$(FILES) $(PROGS)

install-conf:: $(ETC_DIRS)

install-conf::
		$(MAKE) $(SUBDIRS) SUBTARGET=install

clean distclean::
		$(MAKE) $(SUBDIRS) SUBTARGET=$@

$(etc_prefix)::
	set -x ; \
	MODE=755 $(MAKE) __install_dir USER=${httpd_user} GROUP=${httpd_group} DIR=$(DEST_DIR)$@; \
	$(MAKE) install-conf; \

$(ETC_DIRS)::
	$(MAKE) __install_dir USER=${httpd_user} GROUP=${httpd_group} DIR=$(DEST_DIR)$(etc_prefix)/$@

$(SUBDIRS)::
		cd $@ && $(MAKE) $(SUBTARGET)

$(FILES)::
		$(INSTALL) -o ${openca_user} -g ${openca_group} -m 644 $@ $(DEST_DIR)$(etc_prefix)/$@

$(PROGS)::
		$(INSTALL) -o ${openca_user} -g ${openca_group} -m 755 $@ $(DEST_DIR)$(etc_prefix)/$@

distclean::
		for i in $(AC_FILES) ; do \
			if test -e $$i ; then $(RM) "$$i" ; fi ;\
		done

		# $(RM) $(AC_FILES)
