3 # PRIV_OBJ := 1 for object version
10 KSP := /lib/modules/$(shell uname -r)/build \
11 /usr/src/linux-$(shell uname -r) \
12 /usr/src/linux-$(shell uname -r | sed 's/-.*//') \
13 /usr/src/kernel-headers-$(shell uname -r) \
14 /usr/src/kernel-source-$(shell uname -r) \
15 /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
18 test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
19 KSP := $(foreach dir, $(KSP), $(test_dir))
21 KSRC := $(firstword $(KSP))
24 $(error Linux kernel source not found)
27 # check kernel version
28 KVER := $(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
29 KERVER2=$(shell uname -r | cut -d. -f2)
40 INSTDIR := $(shell find /lib/modules/$(shell uname -r) -name $(TARGET) -printf "%h\n" | sort | head -1)
43 ifneq (,$(wildcard /lib/modules/$(shell uname -r)/kernel))
44 INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
46 INSTDIR := /lib/modules/$(shell uname -r)/net
50 INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
52 INSTDIR := /lib/modules/$(shell uname -r)/net
58 SRC = device_main.c card.c mac.c baseband.c wctl.c 80211mgr.c \
59 wcmd.c wmgr.c bssdb.c wpa2.c rxtx.c dpc.c power.c datarate.c \
60 srom.c mib.c rc4.c tether.c tcrc.c ioctl.c hostap.c wpa.c key.c \
61 tkip.c michael.c wroute.c rf.c iwctl.c wpactl.c aes_ccmp.c
72 CFLAGS += -DPRIVATE_OBJ
75 CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/../solomon
83 KERNEL_CONF= $(KSRC)/.config
86 include ${KERNEL_CONF}
90 viawget-objs := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
91 wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
92 mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
93 michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o
96 $(CC) $(CFLAGS) -o $@ $<
99 make -C $(KSRC) SUBDIRS=$(shell pwd) modules
104 OBJS := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
105 wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
106 mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
107 michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o
109 VERSION_FILE := $(KSRC)/include/linux/version.h
110 CONFIG_FILE := $(KSRC)/include/linux/config.h
113 ifeq (,$(wildcard $(VERSION_FILE)))
114 $(error Linux kernel source not configured - missing version.h)
117 ifeq (,$(wildcard $(CONFIG_FILE)))
118 $(error Linux kernel source not configured - missing config.h)
121 ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
127 test_cc = $(shell which $(cc) > /dev/null 2>&1 && echo $(cc))
128 CC := $(foreach cc, $(CC), $(test_cc))
129 CC := $(firstword $(CC))
131 CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe
132 CFLAGS += -I$(KSRC)/include -Wstrict-prototypes -fomit-frame-pointer
133 CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
134 echo "-DMODVERSIONS -include $(KSRC)/include/linux/modversions.h")
136 .SILENT: $(TARGET) clean
139 # look for SMP in config.h
140 SMP := $(shell $(CC) $(CFLAGS) -E -dM $(CONFIG_FILE) | \
141 grep CONFIG_SMP | awk '{ print $$3 }')
153 ifeq ($(PRIV_OBJ), 1)
154 CFLAGS += -DPRIVATE_OBJ
165 SUBARCH := $(shell uname -m)
166 ifeq ($(SUBARCH),x86_64)
167 CFLAGS += -mcmodel=kernel -mno-red-zone
171 $(TARGET): $(filter-out $(TARGET), $(SRC:.c=.o))
174 echo "**************************************************"
175 echo "Build options:"
176 echo " VERSION $(KVER)"
178 if [ "$(SMP)" = "1" ]; \
179 then echo "Enabled"; else echo "Disabled"; fi
183 endif # ifeq ($(KVER),2.6)
189 install: clean $(TARGET)
191 mkdir -p $(MOD_ROOT)$(INSTDIR)
192 install -m 644 -o root $(TARGET) $(MOD_ROOT)$(INSTDIR)
195 /sbin/depmod -a || true
197 /sbin/depmod -b $(MOD_ROOT) -a || true
202 rm -f $(INSTDIR)/$(TARGET)
206 rm -f $(TARGET) $(SRC:.c=.o) *~
207 rm -f .*.o.d .*.o.cmd .*.ko.cmd *.mod.c *.mod.o