#
# Makefile for the rsync-backup package
#FIXME - replace mason references. :-)
#
#Copyleft:
#    Rsync-backup provides an encrypted backup solution with lots of features.
#    Copyright (C) 2001-2003 William Stearns <wstearns@pobox.com>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#    The author can also be reached at:
#        William Stearns
#email:  wstearns@pobox.com              (preferred)
#web:    http://www.stearns.org/rsync-backup/
#snail:  6 Manchester Dr.
#        Lebanon NH, 05446, USA
#

# Modified for Debian GNU/Linux.
DESTDIR =

##Make sure rsync-backup has RSYNCBACKUPVER updated when this changes
RSYNCBACKUPVER=0.2.5

#No quotes around multi file specs.
BINDIR=$(DESTDIR)/usr/bin/
BINFILES=rsync-backup-client
SBINDIR=$(DESTDIR)/usr/sbin
SBINFILES=rsync-backup-server
#CONFDIR=$(DESTDIR)/etc/
#CONFFILE=masonrc
LIBDIR=$(DESTDIR)/usr/lib/rsync-backup/
LIBFILES=localbackuponly.default exclude.default
DOCDIR=$(DESTDIR)/usr/share/doc/rsync-backup-${RSYNCBACKUPVER}/
DOCFILES=COPYING CREDITS ChangeLog INSTALL Makefile NEWS README TODO
DAILYMAINTDIR=$(DESTDIR)/etc/cron.daily
DAILYMAINTFILES=rsync-backup-daily-maintenance
WEEKLYMAINTDIR=$(DESTDIR)/etc/cron.weekly
WEEKLYMAINTFILES=rsync-backup-weekly-maintenance
#DOCDIR=$(DESTDIR)/usr/doc/mason/
#DOCFILES=index.html mason.sgml mason.txt mason.html mason-1.html mason-2.html mason-3.html mason-4.html mason-5.html mason-6.html mason-7.html mason-8.html mason-9.html mason-10.html mason-11.html toc.gif prev.gif next.gif
#MANDIR=$(DESTDIR)/usr/man/man1/
#MANFILES=mason.1 mason-gui-text.1
#SYSVDIR=$(DESTDIR)/etc/rc.d/init.d/
#SYSVFILES=firewall
# SYSVDIR=/etc/rc.d/init.d/
# SYSVFILES=firewall

install:
	@echo -n "Installing files... "
	@echo -n "${BINFILES}... "
	@install -o root -g root -m 0755 ${BINFILES} ${BINDIR}
	@echo -n "${SBINFILES}... "
	@install -o root -g root -m 0755 ${SBINFILES} ${SBINDIR}
	@echo -n "lib directory... "
	@install -o root -g root -m 0755 -d ${LIBDIR}
	@echo -n "${LIBFILES}... "
	@install -o root -g root -m 0644 ${LIBFILES} ${LIBDIR}
	@echo -n "doc directory... "
	@install -o root -g root -m 0755 -d ${DOCDIR}
	@echo -n "${DOCFILES}... "
	@install -o root -g root -m 0644 ${DOCFILES} ${DOCDIR}
	@if [ ! -d ${DAILYMAINTDIR} ] ; then \
	echo -n "daily maint directory... " ; \
	install -o root -g root -m 0755 -d ${DAILYMAINTDIR} ; \
	fi
	@echo -n "${DAILYMAINTFILES}... "
	@install -o root -g root -m 0755 ${DAILYMAINTFILES} ${DAILYMAINTDIR}
	@if [ ! -d ${WEEKLYMAINTDIR} ] ; then \
	echo -n "weekly maint directory... " ; \
	install -o root -g root -m 0755 -d ${WEEKLYMAINTDIR} ; \
	fi
	@echo -n "${WEEKLYMAINTFILES}... "
	@install -o root -g root -m 0755 ${WEEKLYMAINTFILES} ${WEEKLYMAINTDIR}
#	@echo -n "${MANFILES}... "
#	@install -o root -g root -m 0644 ${MANFILES} ${MANDIR}
#	@echo -n "${SYSVFILES}... "
#	@install -o root -g root -m 0755 ${SYSVFILES} ${SYSVDIR}
#	@if [ ! -f ${LIBDIR}baserules ] ; then \
#	install -o root -g root -m 0600 ${LIBDIR}baserules.sample ${LIBDIR}baserules ; \
#	echo -n "baserules... " ; \
#	else \
#	echo -n "${LIBDIR}baserules already exists, not overwriting... " ; \
#	fi
#	@if [ ! -f ${CONFDIR}${CONFFILE} ] ; then \
#	install -o root -g root -m 0600 ${CONFFILE} ${CONFDIR}${CONFFILE} ; \
#	echo -n "${CONFFILE}... " ; \
#	else \
#	rm -f ${CONFDIR}${CONFFILE}.old ; \
#	mv -f ${CONFDIR}${CONFFILE} ${CONFDIR}${CONFFILE}.old ; \
#	install -o root -g root -m 0600 ${CONFFILE} ${CONFDIR}${CONFFILE} ; \
#	echo "" >>${CONFDIR}${CONFFILE} ; \
#	echo "#Your previous settings, if any:" >>${CONFDIR}${CONFFILE} ; \
#	cat ${CONFDIR}${CONFFILE}.old | grep -v "^#" | grep -v "^$$" >>${CONFDIR}${CONFFILE} ; \
#	echo -n "${CONFDIR}${CONFFILE} already exists, appending your settings to the new ${CONFFILE}... " ; \
#	fi
#	@echo done!

#docs:
#	sgml2html --imagebuttons mason.sgml \
#	&& sgml2txt -f mason.sgml \
#	&& makedoc mason.txt mason.pdb 'The Mason HOWTO'

#regress:
#	@if ./regression-test ; then \
#	echo Regression test succeeded. ; \
#	else \
#	echo Regression test failed, exiting. ; \
#	exit 1 ; \
#	fi

#distribs: regress docs
distribs:
	@echo This should only need to be used by the author in 
	@echo packing up the rsync-backup package.
	cd .. \
	&& tar cf - rsync-backup-${RSYNCBACKUPVER}/ | \
	gzip -9 > rsync-backup-${RSYNCBACKUPVER}.tar.gz \
	&& rm -f rsync-backup-current \
	&& ln -sf rsync-backup-${RSYNCBACKUPVER} rsync-backup-current \
	&& tar cf - rsync-backup-current/* | \
	gzip -9 > rsync-backup-current.tar.gz \
	&& cp rsync-backup-${RSYNCBACKUPVER}.tar.gz /usr/src/redhat/SOURCES/ \
	&& cd rsync-backup-${RSYNCBACKUPVER} \
	&& cp -f redhat/rsync-backup.spec /usr/src/redhat/SPECS/ \
	&& rpm --sign -ba /usr/src/redhat/SPECS/rsync-backup.spec \
	&& cp -p /usr/src/rsync-backup-*.tar.gz /usr/src/mysource/ \
	&& cp -p /usr/src/redhat/RPMS/noarch/rsync-backup-*.noarch.rpm /usr/src/mysource/ \
	&& cp -p /usr/src/redhat/SRPMS/rsync-backup-*.src.rpm /usr/src/mysource/

mini-install:
	cp -pf rsync-backup-daily-maintenance /etc/cron.daily
	cp -pf rsync-backup-weekly-maintenance /etc/cron.weekly
	cp -pf rsync-backup-server /usr/sbin
	cp -pf rsync-backup-client /usr/bin
	chown root.root /etc/cron.daily/rsync-backup-daily-maintenance /etc/cron.weekly/rsync-backup-weekly-maintenance /usr/sbin/rsync-backup-server /usr/bin/rsync-backup-client
	chmod 755 /etc/cron.daily/rsync-backup-daily-maintenance /etc/cron.weekly/rsync-backup-weekly-maintenance /usr/sbin/rsync-backup-server /usr/bin/rsync-backup-client

