# Makefile for scripts
#
# This file is part of drbd by Philipp Reisner
#
# drbd 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, or (at your option)
# any later version.
#
# drbd 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 drbd; see the file COPYING.  If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#
# for Debian:
#   update-rc.d drbd defaults 70 08
#

include ../Makefile.vars

ifeq ($(DIST),slackware)
  INITD=etc/rc.d/
endif

ifeq ($(DIST),debian)
  INITD=etc/init.d/
endif

ifeq ($(DIST),redhat)
  INITD=etc/rc.d/init.d/
endif

ifeq ($(DIST),suse)
   INITD=etc/init.d/
endif

ifeq ($(DIST),rock)
  INITD=etc/rc.d/init.d/
endif

ifeq ($(INITD),,)
   $(warning Can not guess distribution INITD, please fix Makefile.vars)
   $(warning Assume INITD=etc/init.d according to LSB)
   INITD=etc/init.d
endif

all:
	ln -sf drbd datadisk

install:
	mkdir -p $(PREFIX)etc/ha.d/resource.d
	install -D -m 755 drbd $(PREFIX)$(INITD)/drbd
	@ if [ ! -e $(PREFIX)etc/drbd.conf ]; then \
		install -D -m 644 drbd.conf $(PREFIX)etc/drbd.conf; \
	fi
	ln -sf ../../../$(INITD)drbd $(PREFIX)etc/ha.d/resource.d/datadisk
ifeq ($(DIST),suse)
	ln -sf ../$(INITD)drbd $(PREFIX)sbin/rcdrbd
endif
	@ echo
	@ echo "Don't forget to run update-rc.d or chkconfig"

clean:
	rm -f *~
	rm -f datadisk

uninstall:
	rm $(PREFIX)$(INITD)drbd
	rm $(PREFIX)etc/ha.d/resource.d/datadisk
	test "$(DIST)" = suse && rm $(PREFIX)sbin/rcdrbd
