#
# Author: Heinz Mauelshagen, Sistina Software <linux.LVM@Sistina.com>
#
# Februar 1997
#
# lvm 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.
# 
# lvm 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 GNU CC; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA. 
#
#

include ../Makefile
include /usr/src/linux/.config

SUBDIRS = .

#ifdef CONFIG_SMP
CFLAGS += -D__SMP__
#endif

#ifdef CONFIG_MODVERSIONS
CFLAGS += -DMODVERSIONS
#endif

lvm_dep = lvm.h Makefile

CFLAGS += -D__KERNEL__ -Wall -I.

all_this:	lvm-mod.o
	@echo ""
	@echo "Done kernel part"
	@echo ""

lvm-mod.o:	lvm.o lvm-snap.o
	$(LD) -r -o $@ lvm.o lvm-snap.o 

install-module:	lvm.o
	rm -f $(LVM_DEST)
	install -o root -g root -m 644 lvm.o $(LVM_DEST)
	rm -f /dev/lvm; mknod /dev/lvm c $(LVM_MAJOR) 0; chmod 640 /dev/lvm

remove-module:	lvm.o
	rm -f $(LVM_DEST) /dev/lvm

remove-ll_rw_blk:	$(LL_RW_BLK)
	@if [ ! -f $(LL_RW_BLK) ]; \
	then \
           @echo "Fatal ERROR: invalid OS version\n"; \
	fi
	@if [ -f $(LL_RW_BLK_DEST).ORG ]; \
	then \
           cp -p $(LL_RW_BLK_DEST).ORG $(LL_RW_BLK_DEST); \
	fi
	@if [ $$? -eq 0 ]; \
	then \
	   rm -f $(LL_RW_BLK_DEST).ORG; \
	fi
	@if [ -f $(KSYMS_DEST).ORG ]; \
	then \
           cp -p $(KSYMS_DEST).ORG $(KSYMS_DEST); \
	fi
	@if [ $$? -eq 0 ]; \
	then \
	   rm -f $(KSYMS_DEST).ORG; \
	fi

install-ll_rw_blk:	$(LL_RW_BLK)
	@if [ ! -f $(LL_RW_BLK) ]; \
	then \
           @echo "Fatal ERROR: invalid OS version\n"; \
	fi
	@if [ ! -f $(LL_RW_BLK_DEST).ORG ]; \
	then \
           cp -p $(LL_RW_BLK) $(LL_RW_BLK_DEST).ORG; \
	fi
	@if [ ! -f $(KSYMS_DEST).ORG ]; \
	then \
           cp -p $(KSYMS_DEST) $(KSYMS_DEST).ORG; \
	fi
	install -o root -g root -m 555 $(LL_RW_BLK) $(LL_RW_BLK_DEST)
	install -o root -g root -m 555 $(KSYMS) $(KSYMS_DEST)

install_this:	install-ll_rw_blk install-module

remove_this:	remove-ll_rw_blk remove-module

lvm.o:	lvm.c $(lvm_dep)
lvm-snap.o:	lvm-snap.c $(lvm_dep)

clean_this:
	rm -f lvm.o lvm-snap.o lvm-mod.o
