# $Id: Makefile,v 1.4 2003/02/08 21:07:21 da Exp $
#
# issue "Make install" as root to install files for demo
#
APACHE_DOC_ROOT = /var/www

## warning: these next two dirs will be erased by "make clean"
CGI_BIN_DIR = ${APACHE_DOC_ROOT}/cgi-bin/mrg
HTML_ROOT = /home/mrg/public_html
CVS_DEMODIR = ..

# copy all CVS files to locations
#
install: apache-config clean
	mkdir -p ${CGI_BIN_DIR}
	cp -rf ${CVS_DEMODIR}/cgi-bin/* ${CGI_BIN_DIR}
	chmod u+x ${CGI_BIN_DIR}/*
	mkdir -p ${HTML_ROOT}
	cp -rf ${CVS_DEMODIR}/cgi-dat ${HTML_ROOT}
	mkdir ${HTML_ROOT}/cgi-dat/log
	mkdir ${HTML_ROOT}/cgi-dat/thy
	cp -f ${CVS_DEMODIR}/RH8/demo-setup-rh8.pl ${CGI_BIN_DIR}/demo-setup.pl
	cp -f ${CVS_DEMODIR}/RH8/path_module.pm ${CGI_BIN_DIR}
	cp -prf ${CVS_DEMODIR}/Htmls/* ${HTML_ROOT}
	cp -rf ${HTML_ROOT}/cgi-dat/code/ours ${HTML_ROOT}/cgi-dat/code/users
	chown -R mrg:mrg ${HTML_ROOT}
# Fix perms for current policy dir and temporary working dir
	chown -R apache:apache ${HTML_ROOT}/pcc/consumer/{PolicyCurrent,PCCtmp}
# Remove working directory and CVS dirs
	rm -rf ${HTML_ROOT}/pcc/producer/IsabelleScratch
	find ${HTML_ROOT} -type d -depth -path "*/CVS" -exec rm -rf {} ';'
	find ${CGI_BIN_DIR} -type d -depth -path "*/CVS" -exec rm -rf {} ';'
	/sbin/service httpd restart
	##################################################################
	# Installed: Use http://localhost/~mrg/ for frontend
	##################################################################


apache-config:
	##################################################################
	#  Current Apache config will be backed up to http.conf.pre-mrg
	##################################################################
	${CVS_DEMODIR}/RH8/./apache-config.sh  ${CVS_DEMODIR}/RH8

clean:
	rm -rf ${HTML_ROOT}
	rm -rf ${CGI_BIN_DIR}
