#
# 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

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/


CFLAGS += -I$(LDDINCDIR)        \
          -I$(LDDCOMDIR)        \
          -I$(LDDGPIODIR)


#-------------------------          
# log the build process
#-------------------------
LOGFILE = $(PWD)/output.log

# comment/uncomment to output to file
#CFLAGS += 2>>$(LOGFILE)



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 
obj-m	:= gpio.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: force

	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 uart/*.ko uart/*.o uart/*.mod.o uart/*.mod.c uart/.*.ko.cmd uart/.*.mod.o.cmd uart/.*.o.cmd
	rm -f *.ko *.o *.mod.o *.mod.c .*.ko.cmd .*.mod.o.cmd .*.o.cmd
force:
##
#
#
#clean: force
#	rm -f *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions /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 ../../../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
#
#force:
#depend .depend dep:
#	$(CC) $(CFLAGS) -M *.c > .depend
#
#
#ifeq (.depend,$(wildcard .depend))
#include .depend
#endif
