# Generated automatically from Makefile.in by configure.
# Makefile
#
# Copyright (C)  1997 - 2000  Heinz Mauelshagen, Germany
#
# February 1997
# May 1998
#
# 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. 
#

# The following 3 vars are set up by autoconf
KERNEL_DIR=/usr/src/linux
LVM_VERSION=1.0.8
KERNEL_VERSION=

DRIVER_DIR=/home/build/tmp/build-lvm/LVM/1.0.8/kernel
CLEANED_DIR=cleaned
CLEANER=/home/build/tmp/build-lvm/LVM/1.0.8/scripts/select_version
PATCHER=/home/build/tmp/build-lvm/LVM/1.0.8/scripts/patch_fragment
FRAGGER=../scripts/select_fragments
LVM_PATCH=./lvm-$(LVM_VERSION)-$(KERNEL_VERSION).patch

ifneq (,$(findstring 2.2,$(KERNEL_VERSION)))
K_DRIVER_DIR=$(KERNEL_DIR)/drivers/block
else
K_DRIVER_DIR=$(KERNEL_DIR)/drivers/md
endif

$(LVM_PATCH): \
	check_rawio \
	$(CLEANED_DIR)/lvm.h \
	$(CLEANED_DIR)/lvm-internal.h \
	$(CLEANED_DIR)/lvm.c	\
	$(CLEANED_DIR)/lvm-snap.c \
	$(CLEANED_DIR)/lvm-fs.c 
	$(PATCHER) $(KERNEL_DIR) $(KERNEL_DIR)/include/linux/lvm.h $(CLEANED_DIR)/lvm.h > $@
	$(PATCHER) $(KERNEL_DIR) $(K_DRIVER_DIR)/lvm.c $(CLEANED_DIR)/lvm.c >> $@
	$(PATCHER) $(KERNEL_DIR) $(K_DRIVER_DIR)/lvm-internal.h $(CLEANED_DIR)/lvm-internal.h >> $@
	$(PATCHER) $(KERNEL_DIR) $(K_DRIVER_DIR)/lvm-snap.c $(CLEANED_DIR)/lvm-snap.c >> $@
	$(PATCHER) $(KERNEL_DIR) $(K_DRIVER_DIR)/lvm-fs.c $(CLEANED_DIR)/lvm-fs.c >> $@
	(cd /home/build/tmp/build-lvm/LVM/1.0.8/PATCHES/ ; $(FRAGGER) $(KERNEL_VERSION)) >> $@

$(CLEANED_DIR)/lvm.h: $(DRIVER_DIR)/lvm.h cleaned
	$(CLEANER) $(KERNEL_VERSION) < $< > $@

$(CLEANED_DIR)/lvm.c: $(DRIVER_DIR)/lvm.c cleaned
	$(CLEANER) $(KERNEL_VERSION) < $< > $@

$(CLEANED_DIR)/lvm-internal.h: $(DRIVER_DIR)/lvm-internal.h cleaned
	$(CLEANER) $(KERNEL_VERSION) < $< > $@

$(CLEANED_DIR)/lvm-snap.c: $(DRIVER_DIR)/lvm-snap.c cleaned
	$(CLEANER) $(KERNEL_VERSION) < $< > $@

$(CLEANED_DIR)/lvm-fs.c: $(DRIVER_DIR)/lvm-fs.c cleaned
	$(CLEANER) $(KERNEL_VERSION) < $< > $@

cleaned:
	mkdir cleaned

clean:
	rm -f $(CLEANED_DIR)/*
	rm -f $(LVM_PATCH)

distclean: clean
	rm -f Makefile

check_rawio:
	@[ -e $(KERNEL_DIR)/include/linux/iobuf.h ] || \
	(echo "You haven't applied the rawio patch, please see the README";\
	 exit 1;)

