#
# Copyright (C) 2000-2015 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
# 
# This file is used as the template to create the
# Makefile for the RedHat specific installation.
#
#  15 November 2001 -- Kern Sibbald
#
#  for Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
#

INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ -m 754

nothing:

install: install-autostart

install-autostart: install-autostart-fd install-autostart-sd install-autostart-dir

install_logrotate:
	@$(INSTALL_PROGRAM) ../../scripts/logrotate $(DESTDIR)/etc/logrotate.d/bacula
	
install-autostart-fd:
	@if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-fd; then \
	   /sbin/chkconfig --del bacula-fd; \
	fi
	@$(INSTALL_PROGRAM) bacula-fd $(DESTDIR)/etc/rc.d/init.d/bacula-fd
	# set symlinks for script at startup and shutdown
	@if test x$(DESTDIR) = x ; then \
	   /sbin/chkconfig --add bacula-fd; \
	fi


install-autostart-sd:
	@if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-sd; then \
	    /sbin/chkconfig --del bacula-sd; \
	fi
	@$(INSTALL_PROGRAM) bacula-sd  $(DESTDIR)/etc/rc.d/init.d/bacula-sd
	# set symlinks for script at startup and shutdown
	@if test x$(DESTDIR) = x ; then \
	   /sbin/chkconfig --add bacula-sd; \
	fi


install-autostart-dir:
	@if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-dir; then \
	    /sbin/chkconfig --del bacula-dir; \
	fi
	@$(INSTALL_PROGRAM) bacula-dir	$(DESTDIR)/etc/rc.d/init.d/bacula-dir
	# set symlinks for script at startup and shutdown
	@if test x$(DESTDIR) = x ; then \
	   /sbin/chkconfig --add bacula-dir; \
	fi


uninstall: uninstall-autostart

uninstall-autostart: uninstall-autostart-fd uninstall-autostart-sd uninstall-autostart-dir

uninstall-logrotate:
	@rm -f $(DESTDIR)/etc/logrotate.d/bacula

uninstall-autostart-fd:
	@if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-fd; then \
	    /sbin/chkconfig --del bacula-fd; \
	fi
	@rm -f	$(DESTDIR)/etc/rc.d/init.d/bacula-fd


uninstall-autostart-sd:
	@if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-sd; then \
	    /sbin/chkconfig --del bacula-sd; \
	fi
	@rm -f	$(DESTDIR)/etc/rc.d/init.d/bacula-sd

uninstall-autostart-dir:
	@if test x$(DESTDIR) = x -a  -f /etc/rc.d/init.d/bacula-dir; then \
	    /sbin/chkconfig --del bacula-dir; \
	fi
	@rm -f	$(DESTDIR)/etc/rc.d/init.d/bacula-dir

clean:
	@rm -f 1 2 3

distclean: clean
	@rm -f Makefile 
	@rm -f bacula-sd bacula-fd bacula-dir

devclean: clean
	@rm -f Makefile 
	@rm -f bacula-sd bacula-fd bacula-dir
