#
# Copyright (c) 2006 Atheros Communications, Inc.
# All rights reserved.
#

#
# Makefile for the Atheros DFS/AR support
#

ifeq ($(obj),)
obj=	.
endif

DEPTH=	../

# release tag versioning
-include $(KERNELPATH)/ath_version.mk
export EXTRAVERSION

obj-m		+= ath_dfs.o
ath_dfs-objs	:= dfs_module.o
ifeq ($(findstring 2.6,$(KERNELRELEASE)),)
export-objs	:= dfs_module.o
list-multi	:= ath_dfs.o
endif

include $(obj)/${DEPTH}/Makefile.inc

ifneq ($(MAKING_MODULES),1)
obj-$(CONFIG_DFS_ATHEROS) := $(ath_dfs-objs)
ifeq ($(findstring 2.6,$(KERNELRELEASE)),)
O_TARGET := ath_dfs.o
endif
endif

ifneq ($(strip $(TOOLPREFIX)),)
CROSS:=$(TOOLPREFIX)
endif
STRIP           =$(CROSS)strip
STRIPFLAGS      = --strip-all --remove-section=.note --remove-section=.comment

ifeq ($(strip $(TOOLPREFIX)), mips-linux-)
CFLAGS += -mips2 -Os
STRIPFLAGS += --remove-section=.pdr
else
CFLAGS += -O2
endif
STRIPCMD        =$(STRIP) $(STRIPFLAGS)

INCS+=	-I${DEPTH}/../ath_hal_50 -I${HAL} -I${HAL}/${OS} -I${obj}/${ATH} -I${obj}/${WLAN} \
	-I${obj}/${DEPTH}

EXTRA_CFLAGS+= ${INCS} ${COPTS} -DAH_SUPPORT_DFS=${AH_SUPPORT_DFS}

-include $(TOPDIR)/Rules.make

all:
	$(MAKE) -C $(KERNELPATH) SUBDIRS=$(shell pwd) modules

install: all
	test -d ${DESTDIR}/${MODULEPATH} || mkdir -p ${DESTDIR}/${MODULEPATH}
	${TOOLPREFIX}strip -S ath_dfs.$(KMODSUF)
	cp ath_dfs.${KMODSUF} ${DESTDIR}/${MODULEPATH}

clean:
	-rm -f *~ *.o *.ko *.mod.c
	-rm -f .depend .version .*.o.flags .*.o.d .*.o.cmd .*.ko.cmd

ath_dfs.o: ${ath_dfs-objs}
	test ! -e dfs.o && cp -f ${DEPTH}/../ath_dfs/dfs.o . || true
	test ! -e dfs.o && cp -f ../dfs/dfs.o . || true
	$(LD) $(LDOPTS) -o ath_dfs.$(KMODSUF) -r $(ath_dfs-objs) dfs.o

radartool: radartool.c
	${CC} -o radartool -I${HAL}/diag ${INCS} ${CFLAGS} ${LDFLAGS} radartool.c
	$(STRIPCMD) radartool

radartool-install: radartool
	cp radartool ${DESTDIR}${BINDIR}/radartool
