# if HW is PC_24 or PC_26 it compiles for kernel 2.4 resp 2.6
HW=UC_24
#HW=UC_26

#---------- FOR PC 2.6 kernel -----------------------------------
ifeq ($(HW),PC_26)
ifneq ($(KERNELRELEASE),)
obj-m := noz.o
noz-y := nozomi.o
else
KDIR:=/lib/modules/$(shell uname -r)/build
PWD		:= $(shell pwd)

default:
	@echo "Warning: Compiling for 2.6: $(FOR26)"
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
endif
endif

#---------- FOR UC 2.6 kernel -----------------------------------
ifeq ($(HW),UC_26)
ifneq ($(KERNELRELEASE),)
obj-m := noz.o
noz-y := nozomi.o
else
KDIR:=../../../kernel
PWD             := $(shell pwd)

default:
	@echo "Warning: Compiling for 2.6: $(FOR26)"
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
install:
	cp ./noz.ko ../../../rootdiskdir/lib/modules/2.6.10_dev-ixdp42x-arm_xscale_be/kernel/drivers/net/
endif
endif
#---------- FOR PC 2.4 kernel -----------------------------------
ifeq ($(HW),PC_24)
#CC 			= gcc-2.95
CC 			= mxscaleb-gcc
KERNELDIR	= -I/mnt/vmware/UC-7420/source_code/kernel/include/asm-arm
CFLAGS		= -Wall $(KERNELDIR) -O3 -D__KERNEL__ -DMODULE -c -DPC_KERNEL_24
PWD			:= $(shell pwd)

default:
	@echo "Warning: Compiling for 2.4: $(FOR26)"
	$(CC) $(CFLAGS) nozomi.c -c
	$(CC) $(CFLAGS) kfifo.c -c
	mxscaleb-ld -r -o noz.o nozomi.o kfifo.o

install:
	cp noz.o ../../usrdiskdir/lib/modules/2.4.18_mvl30-ixdp425/kernel/drivers/net/

endif
# Add by Jared
#---------- FOR UC 2.4 kernel -----------------------------------
ifeq ($(HW),UC_24)
PWD             := $(shell pwd)
prefix		= mxscaleb-
CC		= $(prefix)gcc
LD		= $(prefix)ld
KERNELDIR	= $(PWD)/../../kernel/include/
CFLAGS		= -Wall -O3 -D__KERNEL__ -DMODULE -D__ARMEB__ -isystem $(KERNELDIR)

default:
	@echo "Warning: Compiling for 2.4: $(FOR26)"
	$(CC) $(CFLAGS) nozomi.c -c
	$(CC) $(CFLAGS) kfifo.c -c
	$(LD) -r nozomi.o kfifo.o -o noz.o

install:
	cp noz.o ../../usrdiskdir/lib/modules/2.4.18_mvl30-ixdp425/kernel/drivers/net/
endif
#----------------------------------------------------------------


c: clean
clean:
	$(RM) *.o *.ko *.mod.* .*.o.cmd .*.mod.* .*.ko.cmd
	$(RM) .tmp_versions -rf
#----------------------------------------------------------------
t: tags
tags: ctags
ctags:
	ctags-exuberant -e *.c

ser: ser.c
	$(CC) ser.c -o ser
