#
# Makefile for the Oxford Semiconductor MIO device drivers.
#
#


# Comment/uncomment the following line to disable/enable debugging
DEBUG = y


# Add your debugging flag (or not) to CFLAGS
ifeq ($(DEBUG),y)
  DEBFLAGS = -O -g -DDBG # "-O" is needed to expand inlines
else
  DEBFLAGS = -O2
endif

EXTRA_CFLAGS += $(DEBFLAGS)

#--------------------------------------------------
# directory paths to be included at compile time
#--------------------------------------------------

# common code to be included
LDDINCDIR = $(PWD)/../../../common/driver/linux2.6/
LDDCOMDIR = $(PWD)/../../../common/driver/

# core GPIO code to be included
LDDGPIODIR = $(PWD)/../../../gpio/driver/


EXTRA_CFLAGS += -I$(LDDINCDIR) -I$(LDDCOMDIR) -I$(LDDGPIODIR)



ifneq ($(KERNELRELEASE),)
#---------------------------------
# call from kernel build system
#---------------------------------
#obj-$(CONFIG_OXSEMI_GPIO) += gpio.o

obj-m	:= gpio.o

gpio-objs := main.o \
             /../../../common/driver/linux2.6/DbgTrace.o \
	     /../../../common/driver/linux2.6/OsHwAccess.o \
	     /../../../common/driver/linux2.6/OsMemory.o \
	     /../../../common/driver/linux2.6/OsSpinLock.o \
	     /../../../gpio/driver/GpioCore.o 



else
#---------------------------------------------------
# otherwise we were called directly from command 
# line; invoke the kernel build system
#---------------------------------------------------

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD       := $(shell pwd)

modules:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

endif

clean: 
	rm -f ../../../common/driver/linux2.6/*.ko \
        ../../../common/driver/linux2.6/*.o \
        ../../../common/driver/linux2.6/*.mod.o \
        ../../../common/driver/linux2.6/*.mod.c \
        ../../../common/driver/linux2.6/.*.ko.cmd \
        ../../../common/driver/linux2.6/.*.mod.o.cmd \
        ../../../common/driver/linux2.6/.*.o.cmd
	rm -f ../../../gpio/driver/linux2.6/*.ko \
        ../../../gpio/driver/linux2.6/*.o \
        ../../../gpio/driver/linux2.6/*.mod.o \
        ../../../gpio/driver/linux2.6/*.mod.c \
        ../../../gpio/driver/linux2.6/.*.ko.cmd \
        ../../../gpio/driver/linux2.6/.*.mod.o.cmd \
        ../../../gpio/driver/linux2.6/.*.o.cmd
	rm -f ../../../common/driver/*.ko \
        ../../../common/driver/*.o \
        ../../../common/driver/*.mod.o \
        ../../../common/driver/*.mod.c \
        ../../../common/driver/.*.ko.cmd \
        ../../../common/driver/.*.mod.o.cmd \
        ../../../common/driver/.*.o.cmd
	rm -f *.ko *.o *.mod.o *.mod.c .*.ko.cmd .*.mod.o.cmd .*.o.cmd


#endif
