2 # Makefile for IC Plus Ethernet Adapter driver for Linux
3 # Copyright (c) 2004 by IC Plus Corporation.
8 MAPPING_MODE= -DUSE_IO_OPS
9 #MAPPING_MODE= -DUSE_IO_OPS -DJUMBO_FRAME -DJUMBO_FRAME_SIZE_4K
11 KernelVersion := $(shell uname -r)
12 KernelBuildDir := /lib/modules/$(KernelVersion)/build
13 kernelMisc := /lib/modules/$(KernelVersion)/kernel/drivers/net/
14 kernelExtension := $(shell echo $(KernelVersion) | sed -ne 's/^2\.[567]\..*/k/p')o
15 kernelFlag26 := kernel2$(shell echo $(KernelVersion) | sed -ne 's/^2\.[6]\..*/6/p')x
18 #======================Makefile for kernel 2.2.x and 2.4.x======================
19 ifneq ($(kernelFlag26),kernel26x)
21 CFLAGS = -D__KERNEL__ -DMODULE -O -Wall -Wstrict-prototypes -I$(INCLUDEDIR)
22 EXTRA_CFLAGS := $(MAPPING_MODE)
23 EXTRA_CFLAGS := $(EXTRA_CFLAGS) -D_COMPAT_WITH_OLD_KERNEL
26 KernelSrcPath := /lib/modules/$(shell uname -r)/build \
27 /usr/src/linux-$(shell uname -r) \
28 /usr/src/linux-$(shell uname -r | sed 's/-.*//') \
29 /usr/src/kernel-headers-$(shell uname -r) \
30 /usr/src/kernel-source-$(shell uname -r) \
31 /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
33 FindDir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
34 KernelSrcPath := $(foreach dir, $(KernelSrcPath), $(FindDir))
35 KernelSrc := $(firstword $(KernelSrcPath))
37 # Support Linux software VLAN
38 #EXTRA_CFLAGS := $(EXTRA_CFLAGS) -DCONFIG_VLAN_8021Q
40 #EXTRA_CFLAGS := $(EXTRA_CFLAGS) -DEXTRA_STATS
41 #DEBUG_FLAGS = -O -g -DALTA_DEBUG
42 K_VER=$(shell uname -r)
43 INCLUDEDIR=$(shell if [ -e /usr/src/linux-$(K_VER)/include ]; \
44 then echo "/usr/src/linux-$(K_VER)/include"; \
45 elif [ -e /usr/src/linux-2.4/include ]; \
46 then echo "/usr/src/linux-2.4/include"; \
47 elif [ -e /usr/src/linux/include ]; \
48 then echo "/usr/src/linux/include"; \
49 else echo "/usr/include"; fi)
51 # Old kernel need to configure modversions.h
53 #EXTRA_CFLAGS := $(EXTRA_CFLAGS) \
54 # $(shell if [ -e $(INCLUDEDIR)/linux/modversions.h ]; \
55 # then echo -DCONFIG_MODVERSIONS; fi)
57 CFLAGS+=$(shell [ -f $(KernelSrc)/include/linux/modversions.h ] && \
58 echo "-DMODVERSIONS -include $(KernelSrc)/include/linux/modversions.h")
61 $(LD) -r -o $@ $(OBJS)
63 # Dependency to create object file.
71 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(DEBUG_FLAGS) -c -o $@ $<
75 #===========================Makefile for kernel 2.6.x===========================
76 ifeq ($(kernelFlag26),kernel26x)
77 EXTRA_CFLAGS+=$(MAPPING_MODE)
80 $(MAKE) -C $(KernelBuildDir) SUBDIRS=$(PWD) modules
83 install -m 644 -c ipg.$(kernelExtension) $(kernelMisc)
89 #===========================Makefile common section============================
90 # Delete existing object file
93 rm -f *.o *.ko *~ core* .dep* .*.d .*.cmd *.mod.c *.a *.s .*.flags