#!/usr/bin/make
# Makefile for building Linux Broadcom Gigabit ethernet driver as a module.
# $id$

# PREFIX may be set by the RPM build to set the effective root.
PREFIX=
#ifeq ($(shell ls /lib/modules/`uname -r`/build > /dev/null 2>&1 && echo build),)
#LINUX=/usr/src/linux
#else
#LINUX=/lib/modules/`uname -r`/build
#endif

KVER=`cat $(PREFIX)/version`

ifeq ($(shell which kgcc > /dev/null 2>&1 && echo kgcc),)
CC = gcc
else
CC = kgcc
endif
LD = ld
CFLAGS=-DMODULE -D__KERNEL__ -DDBG=0 -DPCIX_TARGET_WORKAROUND=1 -DINCLUDE_TBI_SUPPORT -Wall -Wstrict-prototypes -O6 -I$(LINUX)/include

# If the modversion.h file exists we should pass a flag.
# Most of my drivers have been updated to not need this, but not the other
# kernel source files.
#MODVER_H = $(LINUX)/include/linux/modversions.h
#ifneq ($(wildcard $(MODVER_H)),"")
#  CFLAGS += -DMODVERSIONS
#endif

all: at29xx.o

at29xx.o: ac1000um.o ac1000lm.o ac1000an.o
	$(LD) -i $^ -o $@

install: at29xx.o
	@if [ -d $(PREFIX)/lib/modules/$(KVER)/kernel/drivers/net ];\
	then install -m 444 at29xx.o $(PREFIX)/lib/modules/$(KVER)/kernel/drivers/net;\
	else install -m 444 at29xx.o $(PREFIX)/lib/modules/$(KVER)/net/;\
	fi
	@if [ "$(PREFIX)" = "" ]; then /sbin/depmod -a ;\
	else echo " *** Run '/sbin/depmod -a' to update the module database.";\
	fi

.PHONEY: all clean install tar

clean:
	-rm -f at29xx.o ac1000um.o ac1000lm.o ac1000an.o 
