# file: src/web-interfaces/pub/cmds/Makefile
#
#  2001 OpenCA Group

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

DEST_CGI_CMDDIR		= ${lib_prefix}/cmds
DEST_PUB_CGI_CMDDIR	= ${lib_prefix}/servers/${pub_prefix}/cmds
DEST_LINK_PATH		= ../../../cmds

# commands derived from .in files:
AC_CMDS	=

# commands not derived from .in files:
STATIC_CMDS	= \
	confirm_revreq		\
	basic_csr		\
	getcert			\
	lists			\
	pkcs10_req		\
	revoke_req		\
	scepGetCACert		\
	scepPKIOperation	\
	search			\
	sendcert		\
	send_email_cert		\
	serverInfo		\
	submit_revreq		\
	test_cert		\
	verifySignature		\
	viewCert

CMDS	= $(AC_CMDS) $(STATIC_CMDS)

DEST_CMDS	= $(CMDS:%=$(DEST_CGI_CMDDIR)/%)

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

.PHONY:	default install clean distclean

default::

$(DEST_PUB_CGI_CMDDIR):
		$(INSTALL) -d -o ${openca_user} -g ${openca_group} -m 755 $@

install::	$(DEST_CMDS)

$(DEST_CMDS)::	$(DEST_PUB_CGI_CMDDIR)
$(DEST_CMDS)::
		@if [ -e $(DEST_PUB_CGI_CMDDIR)/$(@:$(DEST_CGI_CMDDIR)/%=%) ]; then \
			echo "software update detected, removing old link"; \
			$(RM) $(DEST_PUB_CGI_CMDDIR)/$(@:$(DEST_CGI_CMDDIR)/%=%); \
		fi
		@## only linking relative to support "rpm -ba"
		@## $(LN_S) $@ $(DEST_PUB_CGI_CMDDIR)/$(@:$(DEST_CGI_CMDDIR)/%=%)
		cd $(DEST_PUB_CGI_CMDDIR); \
		$(LN_S) $(DEST_LINK_PATH)/$(@:$(DEST_CGI_CMDDIR)/%=%)

distclean::
		#$(RM) $(AC_CMDS)
