################################################################
# Makefile: static creating and uploading to web server
#
# $Id: Makefile.in,v 1.26 2001/02/06 05:01:59 tom Exp $
################################################################

################
# Site Setting
PREFIX		=	@prefix@
PERL5		=	@PERL5@
SENDMAIL	=	@SENDMAIL@
MKDIR		=	mkdir -p
SHAREDIR	=	${PREFIX}/share
BINDIR		=	${PREFIX}/bin
DOCDIR		=	${SHAREDIR}/doc
TDS_ROOT	=	${SHAREDIR}/tds

################

TMPFILE		=	/tmp/tds.install.tmp

################################################################
dummy:
	@echo "do % make install"

install: install-message install-tds-root install-doc install-site-conf install-tds-setup
	@echo "Thank you for using TDS:"
	@echo "edit '${TDS_ROOT}/site_conf.ph' manualy. "
	@echo "for user setup, su to the user and do 'tds-setup'"

install-message:
	@echo "[installing...]"
	@echo "* copy the package"

install-tds-root:
	# copy to ${installdir}${TDS_ROOT} 
	${MKDIR} ${installdir}${TDS_ROOT}
	cp -r . ${installdir}${TDS_ROOT}

install-doc:
	# cp documents to share/doc
	${MKDIR} ${installdir}${DOCDIR}
	if [ -d ${installdir}${DOCDIR}/tds ]; then \
		rm -rf ${installdir}${DOCDIR}/tds; \
	fi
	cp -r ${installdir}${TDS_ROOT}/doc ${installdir}${DOCDIR}/tds

install-site-conf:
	# store to site_conf.ph
	@if [ -f ${TDS_ROOT}/site_conf.ph ] ; then \
		echo "  ${TDS_ROOT}/site_conf.ph is found." ;\
		echo "  do NOT update it" ;\
	else \
		echo "  create site_conf.ph" ;\
		sed -e "s!%PERL5%!${PERL5}!; s!%SENDMAIL%!${SENDMAIL}!; s!%TDS_ROOT%!${TDS_ROOT}!" site_conf.ph.in > ${installdir}${TDS_ROOT}/site_conf.ph ;\
	fi

install-tds-setup:
	# output setup script : ${installdir}${BINDIR}/tds-setup
	${MKDIR} ${installdir}${BINDIR}
	@echo "#!/bin/sh" > ${installdir}${BINDIR}/tds-setup
#	@echo "(cd ${TDS_ROOT} ; ${PERL5} install.pl -s \$$@ )" >> ${installdir}${BINDIR}/tds-setup
#	@echo "${PERL5} -I${TDS_ROOT} -I${TDS_ROOT}/web_diary_dir/lib ${TDS_ROOT}/install.pl -s \$$@" >> ${installdir}${BINDIR}/tds-setup
	@echo "${PERL5} ${TDS_ROOT}/install.pl -s \$$@" >> ${installdir}${BINDIR}/tds-setup
	@chmod a+x ${installdir}${BINDIR}/tds-setup

uninstall:
	rm -rf ${TDS_ROOT}
	rm -rf ${DOCDIR}/tds
	rm -f ${PREFIX}/bin/tds-setup

################################################################
setup:
	perl install.pl -s

clean:
	rm -f config.* *~ Makefile

# for use of CVS management
update:
	cvs update; perl autosplit.pl ; perl install.pl -y

prepare: autosplit chmod

autosplit:
	perl autosplit.pl

chmod:
	chmod 755 configure contrib/*/configure

# end of Makefile
################################################################
