CC =$(shell if which kgcc > /dev/null 2>&1; then echo kgcc; else echo gcc; fi)

SRCPATH =$(shell if uname -r | grep '2.4' > /dev/null 2>&1; then echo /usr/src/linux-2.4; else echo /usr/src/linux; fi)

CFLAGS =-D__KERNEL__ -DMODULE $(shell if uname -r | grep '2.4.2-2' > /dev/null 2>&1; then echo "-DEXPORT_SYMTAB"; fi) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer

CFLAGS += $(shell if $(CC) -fno-strict-aliasing -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo -fno-strict-aliasing; fi)


OBJS = iteraid.o
iteraid.o:iteraid.c iteraid.h
	$(CC) $(CFLAGS) $(shell if uname -r | grep '2.2.' > /dev/null 2>&1; then echo "-DMODVERSIONS"; fi) -I. -I$(SRCPATH)/drivers/scsi -I$(SRCPATH)/include -include $(SRCPATH)/include/linux/modversions.h -c -o iteraid.o iteraid.c


BOOTOBJS = iteraid.bot
iteraid.bot:iteraid.c iteraid.h
	$(CC) $(CFLAGS) $(shell if echo $(CC) | grep 'kgcc' > /dev/null 2>&1 || uname -r | grep '2.4' > /dev/null 2>&1; then echo "-D__module__BOOT"; fi) $(shell if uname -r | grep '2.2.' > /dev/null 2>&1; then echo "-DMODVERSIONS"; fi) -I. -I$(SRCPATH)/drivers/scsi -I$(SRCPATH)/include -include $(SRCPATH)/include/linux/modversions.h -c -o iteraid.bot iteraid.c


SMPOBJS = iteraid.smp
iteraid.smp:iteraid.c iteraid.h
	$(CC) $(CFLAGS) -D__SMP__ $(shell if echo $(CC) | grep 'kgcc' > /dev/null 2>&1 || uname -r | grep '2.4' > /dev/null 2>&1; then echo "-D__module__smp"; fi) $(shell if uname -r | grep '2.2.' > /dev/null 2>&1; then echo "-DMODVERSIONS"; fi) -I. -I$(SRCPATH)/drivers/scsi -I$(SRCPATH)/include -include $(SRCPATH)/include/linux/modversions.h -c -o iteraid.smp iteraid.c


up: $(OBJS)

all: $(OBJS) $(BOOTOBJS) $(SMPOBJS)

bot: $(BOOTOBJS)

smp: $(SMPOBJS)

clean:
	rm -rf iteraid.o iteraid.smp iteraid.bot *~
