#################################################
# config

#KERNEL_LOCATION=/usr/src/kernel/2.0.33
KERNEL_LOCATION=/usr/src/linux

#################################################
# some magic for using linux kernel settings
# when compiling the module
VERSION=$(shell cat VERSION)

M_OBJS       = ch.o
EXTRA_CFLAGS = -I$(KERNEL_LOCATION)/drivers/scsi -DVERSION='"$(VERSION)"'

% : %.c
	$(CC) -g -Wall -o $@ $<

all: here userland unload load autojuke

here:
	DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)

load: unload
	ln -s unload load

clean:
	rm -f .ch.o.flags ch.o *~ mail.uu userland unload load autojuke

include $(KERNEL_LOCATION)/Rules.make

#################################################
# for mailing it around the world :-)

DISTFILES=README VERSION TODO ChangeLog Makefile scsi-changer.lsm \
	MAKEDEV.sch ch.c chio.h userland.c unload.c \
	autojuke.c autojuke.conf

mail.uu mail: $(DISTFILES)
	tar cvzf - $(DISTFILES) |\
		uuencode scsi-changer-current.tar.gz > mail.uu


tar dist: clean
	rm -f scsi-changer-*.tar.gz
	(cd ..; tar cvzf scsi-changer-`cat changer/VERSION`.tar.gz changer)
	mv ../scsi-changer-*.tar.gz .
