######################################################################
#	Module Name: Makefile
#	Abstract: Makefile for rt73 linux driver on kernel series 2.6 
######################################################################
PLATFORM=PC
#PLATFORM=CMPC

#Enable for wpa_supplicant's spcific driver "driver_ralink.c", default enabled.
HAS_RALINK_WPA_SUPPLICANT_SUPPORT=y

#Enable for wpa_supplicant's generic driver "driver_wext.c", used for NetworkManager
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=n

#Support Block Net-If during TxSw queue full.
HAS_BLOCK_NET_IF=y

WFLAGS := -Wall -Wstrict-prototypes -Wno-trigraphs

ifeq ($(HAS_RALINK_WPA_SUPPLICANT_SUPPORT),y)
WFLAGS += -DRALINK_WPA_SUPPLICANT_SUPPORT
endif

ifeq ($(HAS_NATIVE_WPA_SUPPLICANT_SUPPORT),y)
WFLAGS += -DNATIVE_WPA_SUPPLICANT_SUPPORT
endif

ifeq ($(HAS_BLOCK_NET_IF),y)
WFLAGS += -DBLOCK_NET_IF
endif

## Comment/uncomment the following line to enable/disable debugging
#EXTRA_CFLAGS += -DDBG -DRALINK_ATE

EXTRA_CFLAGS += $(WFLAGS)

ifeq ($(PLATFORM),PC)
LINUX_SRC = ${MYPATH}/kernel/linux
endif
ifeq ($(PLATFORM),CMPC)
LINUX_SRC = ${MYPATH}/kernel/linux
endif

EXTRA_CFLAGS += -I$(LINUX_SRC)/include

obj-m := rt73.o

rt73-objs := \
	rtmp_main.o \
	mlme.o \
	connect.o \
	rtusb_bulk.o \
	rtusb_io.o \
	sync.o \
	assoc.o \
	auth.o \
	auth_rsp.o \
	rtusb_data.o \
	rtmp_init.o \
	sanity.o \
	rtmp_wep.o \
	rtmp_info.o \
	rtmp_tkip.o \
	wpa.o md5.o

ifeq ($(HAS_NATIVE_WPA_SUPPLICANT_SUPPORT),y)
rt73-objs += rtmp_wext.o
endif

ifeq ($(HAS_BLOCK_NET_IF),y)
rt73-objs += netif_block.o
endif

## Configuration files on SuSE
#NDDIR=/etc/sysconfig/network
#MOD_CONF=/etc/modprobe.d/module-renames

## NDDIR/ifcfg-rausb0
#ND_CONF=/etc/sysconfig/network-scripts/ifcfg-rausb0

ifdef NDDIR
	NDDIR := $(NDDIR)
else
# 	NDDIR := /etc/sysconfig/network-scripts
endif

ifdef MOD_CONF
	MOD_CONF := $(MOD_CONF)	
else
	MOD_CONF := /etc/modprobe.conf 
endif

all: 
	make -C $(LINUX_SRC) 'EXTRA_CFLAGS=$(EXTRA_CFLAGS) -DRTMP_EMBEDDED' \
	SUBDIRS=$(shell pwd) modules ARCH=arm

clean:
	rm -rf *.o *~ .*.cmd *.ko *.mod.c .tmp_versions built-in.o

install:
	cp -af rt73.ko ${MYPATH}/rootfs/lib/modules/
	mkdir -p ${MYPATH}/rootfs/lib/firmware
	cp -af rt73.bin ${MYPATH}/rootfs/lib/firmware/
#install:
#	make -C $(LINUX_SRC) \
#	SUBDIRS=$(shell pwd) \
#	modules_install 
	
config:
	@touch config.mk
	@./Configure
