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

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

DEST_CGI_CMDDIR		= ${lib_prefix}/cmds
DEST_CA_CGI_CMDDIR	= ${lib_prefix}/servers/${ca_prefix}/cmds
DEST_LINK_PATH		= ../../../cmds

# commands derived from .in files:
AC_CMDS	= \

# commands not derived from .in files:
STATIC_CMDS	= \
	add_module		\
	add_operation		\
	add_right		\
	add_role		\
	add_script		\
	basic_csr		\
	bpApprovePendingCSR	\
	bpApproveRenewedCSR	\
	bpBackupKey		\
	bpCreateCSR		\
	bpCreateKey		\
	bpCreatePIN		\
	bpDeletePIN		\
	bpExportPIN		\
	bpExportPKCS12		\
	bpImportACL		\
	bpImportNewUser		\
	bpImportUpdateUser	\
	bpIssueCertificate	\
	bpListUser		\
	bpRecoverCert		\
	bpRecoverKey		\
	bpRevokeCertificate	\
	bpViewUser		\
	changeCSR		\
	changePasswd		\
	crlList			\
	delete_module		\
	delete_operation	\
	delete_right		\
	delete_script		\
	deleteCRR		\
	deleteCSR		\
	editCSR			\
	exportCAReqCert		\
	exportCAReq		\
	genCACert		\
	genDB			\
	genCAReq		\
	genCRL			\
	genCRLfromFile		\
	genSKey			\
	getcert			\
	hsmLogin		\
	hsmLogout		\
	importDB		\
	importCACert		\
	issueCertificate	\
	listCerts		\
	listReqs		\
	new_module		\
	new_operation		\
	new_right		\
	new_role		\
	new_script		\
	nodeEnrollConfig	\
	rebuildChain		\
	removeKey		\
	replayLog		\
	revokeCertificate	\
	search			\
	search_rights		\
	send_cert_key		\
	send_cert_key_openssl	\
	send_cert_key_pkcs12	\
	send_cert_key_pkcs8	\
	serverInfo		\
	setupInitialCert	\
	show_modules		\
	show_operations		\
	show_prepared_module	\
	show_prepared_operation	\
	show_prepared_right	\
	show_prepared_role	\
	show_prepared_script	\
	show_rights		\
	show_roles		\
	show_script		\
	show_scripts		\
	signConfig		\
	viewCRL			\
	viewCRR			\
	viewCSR			\
	viewCert		\
	viewSignature		\
	warnExpiring

CMDS	= $(AC_CMDS) $(STATIC_CMDS)

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

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

.PHONY:	default install clean distclean

default::

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

install::	$(DEST_CMDS)

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

distclean::
