#!/usr/bin/make all
# Makefile for building updated Linux PCI network device drivers as modules by pioklo.
# $id$

# PREFIX may be set by the RPM build to set the effective root.
PREFIX=
PCMCIA=/usr/src/pcmcia/include
LINUX=/usr/src/linux
CC=gcc
CFLAGS=-DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -I$(LINUX)/include

# Some architectures require magic gcc flags for kernel files.
ARCH:=$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
ifeq ($(ARCH),i386)
    CFLAGS+=-pipe -fno-strength-reduce
endif
ifeq ($(ARCH),alpha)
    CFLAGS+=-pipe -mno-fp-regs -ffixed-8 -mcpu=ev5
endif


# 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

DRV_OFILES =  winbond-840.o 


OFILES= $(DRV_OFILES) pci-scan.o
ifeq ($(wildcard $(PCMCIA)/pcmcia/driver_ops.h),$(PCMCIA)/pcmcia/driver_ops.h)
  OFILES += cb_shim.o
  CARDBUS-FLAGS = -DCARDBUS -I$(LINUX)/include -I/usr/include -I$(PCMCIA)
endif

all:  pci-scan.o $(DRV_OFILES)

$(OFILES) pci-scan.o : pci-scan.h kern_compat.h

pci-scan.o: pci-scan.h

install: $(OFILES)
	install -m 444 pci-scan.o $(DRV_OFILES) $(PREFIX)/lib/modules/`uname -r`/net/
	@if [ "$(PREFIX)" = "" ]; then /sbin/depmod -a ;\
	else echo " *** Run '/sbin/depmod -a' to update the module database.";\
	fi


clean:
	-rm -f *.o netdrivers.tgz
