#
# Makefile for the Atheros HAL Module.
#

src=.
obj=.

TARGET=armv4-le-elf
#
# Use ARCH to guess the target platform.
# XXX use .config contents in addition?
#
ifeq ($(strip ${ARCH}),i386)
TARGET=	i386-elf
endif
ifeq ($(strip ${ARCH}),mips)
TARGET=	mipsisa32-be-elf
endif
ifeq ($(strip ${ARCH}),x86_64)
TARGET=	x86_64-elf
endif

EXTRA_CFLAGS+=	-I. -I${HAL}/.. -I${HAL}

ifndef OS
OS = linux
endif

ifndef HAL_OBJDIR
#
# Use release version of HAL.
#
# NB: binary HAL's are distributed in a uuencode'd file; on some
#     systems uuencode is not installed by default and you must
#     specially install it from the sharutils package.
#
UUDECODE?=	uudecode

HAL=		$(src)/../hal
OPT_AH_H=	${HAL}/public/${TARGET}.opt_ah.h
else
#
# Use private version of HAL.
#
HAL=		$(shell dirname `dirname ${HAL_OBJDIR}`)
OPT_AH_H=	${HAL_OBJDIR}/opt_ah.h
endif


obj-$(CONFIG_ATHEROS_HAL) := ah_osdep.o hal.o

export-objs	:= ah_osdep.o
list-multi	:= ath_hal.o

O_TARGET	:= ath_hal.o
include $(TOPDIR)/Rules.make

ifndef HAL_OBJDIR
$(obj)/hal.o:	${HAL}/public/${TARGET}.hal.o.uu
	${UUDECODE} -o $(obj)/hal.o < $<
else
$(obj)/hal.o:	${HAL_OBJDIR}/hal.o
	cp ${HAL_OBJDIR}/hal.o $(obj)/hal.o
endif

# XXX need opt_ah.h to do dependencies so give this bogus dependency
$(obj)/ah_osdep.c: ${HAL}/linux/ah_osdep.c $(obj)/opt_ah.h
	cp ${HAL}/${OS}/ah_osdep.c $(obj)/ah_osdep.c
$(obj)/opt_ah.h: ${OPT_AH_H}
	cp ${OPT_AH_H} $(obj)/opt_ah.h
