ifeq (,$(KERNELVERSION))
   KERNELVERSION := $(shell uname -r)
endif

ifeq (,$(BASEINCLUDE))
   BASEINCLUDE := /lib/modules/$(KERNELVERSION)/build
endif

# Presume SCST has been built and installed
EXTRA_CFLAGS += -I/usr/local/include/scst


# KERNELRELEASE is in the second pass of the 2.6 make process
ifneq (,$(KERNELRELEASE))

obj-$(CONFIG_LPFC_SCST) := lpfc_scst.o

lpfc_scst-objs := lpfc_scst_main.o

else

# Building for 2.6 kernel

clean-files := *.o *.ko *.mod.o *.mod.c .*.cmd .*.flags .tmp_versions Module.* *.out

build:
	$(MAKE) -C $(BASEINCLUDE) SUBDIRS=`pwd` CONFIG_LPFC_SCST=m modules
install:
	@rm -f /lib/modules/$(KERNELVERSION)/kernel/drivers/scsi/lpfc_scst.ko
	install -d /lib/modules/$(KERNELVERSION)/kernel/drivers/scsi/lpfc_scst
	install -c lpfc_scst.ko /lib/modules/$(KERNELVERSION)/kernel/drivers/scsi/lpfc_scst
	depmod -a


clean:
	rm -rf $(clean-files) 
endif
