#*HEADER*******************************************************************
#Copyright (c)
#All rights reserved
#This software embodies materials and concepts that are confidential
#to Redpine Signals and is made available solely pursuant to the terms
#of a written license agreement with Redpine Signals
#
#Project name : Ganges
#Module name  : Linux SDIO Driver
#File Name    : Makefile
#
#File Description:
#    This is the Makefile For Ganges Linux SDIO Driver
#    Default Stack is Open Source Stack
#
#Author :
#
#Rev History:
#Ver        By             date       Description
#---------------------------------------------------------
#1.1        Fariya                    Initial version
#---------------------------------------------------------
#*END*********************************************************************

KERNELRELEASE=$(shell uname -r)
KERNELDIR=/lib/modules/$(KERNELRELEASE)/build
#if u enable this one BB, RF and channel parameters are extracted in runtime
#otherwise static variables will be taken
DYNAMIC_PARAMS=y
#Enable this to download TA code from the host
TA_CODE_HOST_DOWNLOAD=y
#Enable this flag to download TA SRAM code from the host
#TA_EXT_SRAM_CODE_DOWNLOAD=y
#Enable this flag for polling based driver
#POLLING_ENABLED=y
#Enable this flag for SDIO high speed mode
#ENABLE_SDIO_HIGH_SPEED=y
#Enable this flag for BG Scan
ENABLE_BGSCAN=y
#Enable this flag for roaming
ENABLE_ROAMING=y
#Enable this flag for a Big Endian driver
#ENABLE_BIGENDIAN=y
#ENABLE_SDIO_CHANGE=y

DRIVER_DIR=$(PWD)
EXTRA_CFLAGS += -DLINUX 
EXTRA_CFLAGS += -I$(DRIVER_DIR)/include 
EXTRA_CFLAGS += -Wimplicit -Wall 
#EXTRA_CFLAGS += -Werror
EXTRA_CFLAGS += -Wstrict-prototypes

ifeq ($(DRIVER_DIR),)
DRIVER_DIR=$(PWD)
endif

SRC_FILES =   ganges_linux_main.o  ganges_linux_data.o\
              ganges_linux_specific.o ganges_linux_sdio.o \
              ganges_fsm.o ganges_mgmt.o ganges_parser.o\
	      ganges_linux_ioctl.o ganges_misc.o ganges_spectrum.o

ifdef ARASAN_SDIO_STACK 
  EXTRA_CFLAGS += -DARASAN_SDIO_STACK
  EXTRA_CFLAGS += -I$(DRIVER_DIR)/../Arasan_SDIO_1305/include
  SRC_FILES += ganges_linux_sdio_arasan.o 
else
  EXTRA_CFLAGS += -DOPEN_SOURCE_SDIO_STACK
  SRC_FILES += ganges_linux_sdio_opensrc.o 
endif

ifdef DYNAMIC_PARAMS
  EXTRA_CFLAGS += -DDYNAMIC_VARIABLES
else
  EXTRA_CFLAGS += -I$(DRIVER_DIR)/../release/
endif

ifdef TA_CODE_HOST_DOWNLOAD
  EXTRA_CFLAGS += -DTA_HOST_DOWNLOAD
endif 

ifdef TA_EXT_SRAM_CODE_DOWNLOAD
  EXTRA_CFLAGS += -DTA_EXT_SRAM_CODE_DOWNLOAD
endif 

ifdef POLLING_ENABLED  
  EXTRA_CFLAGS += -DPOLLING_ENABLED
endif 

ifdef ENABLE_BGSCAN 
  EXTRA_CFLAGS += -DENABLE_BGSCAN
endif 

ifdef ENABLE_ROAMING
  EXTRA_CFLAGS += -DENABLE_ROAMING
endif

ifdef ENABLE_SDIO_HIGH_SPEED  
  EXTRA_CFLAGS += -DENABLE_SDIO_HIGH_SPEED
endif 

ifdef ENABLE_BIGENDIAN 
  EXTRA_CFLAGS += -DENABLE_BIGENDIAN
endif 

ifdef ENABLE_SDIO_CHANGE
  EXTRA_CFLAGS += -DENABLE_SDIO_CHANGE
endif 

obj-m := rwlpsdio.o
rwlpsdio-objs :=  ${SRC_FILES}
        
all:
	@echo "Compiling driver code"
	make -C$(KERNELDIR) SUBDIRS=$(PWD) modules
	cp rwlpsdio.ko ../release/. 

clean:
	@echo "Cleaning driver binary files"
	rm -rf rwlpsdio.* 
	rm -rf *.rwlpsdio.*.*
	rm -rf *.o
