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

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

DEST_CGI_CMDDIR		= ${lib_prefix}/cmds
DEST_NODE_CGI_CMDDIR	= ${lib_prefix}/servers/${node_prefix}/cmds
DEST_LINK_PATH		= ../../../cmds

# commands derived from .in files:
AC_CMDS	= \

# commands not derived from .in files:
STATIC_CMDS	= \
	exportDB		\
	genDB			\
	importDB		\
	nodeDownloadAll		\
	nodeDownloadBP		\
	nodeDownloadCRL		\
	nodeDownloadCert	\
	nodeDownloadConfig	\
	nodeEnrollAll		\
	nodeEnrollBP		\
	nodeEnrollCACert	\
	nodeEnrollCRL		\
	nodeEnrollCert		\
	nodeEnrollConfig	\
	nodeReceiveAll		\
	nodeReceiveCRR		\
	nodeReceiveCSR		\
	nodeUploadAll		\
	nodeUploadCRR		\
	nodeUploadCSR		\
	rebuildChain		\
	rebuildOpenSSLindexDB	\
	removeFiles		\
	replayLog		\
	sendCRINMail		\
	serverInfo		\
	updateOCSPindexDB	\
	updateSearchAttributes

CMDS	= $(AC_CMDS) $(STATIC_CMDS)
# CMDS	= $(STATIC_CMDS)

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

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

.PHONY:	default install clean distclean

default::

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

install::	$(DEST_CMDS)

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


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