3 # PRIV_OBJ := 1 for object version
13 KSP := /lib/modules/$(shell uname -r)/build \
14 # /usr/src/linux-$(shell uname -r) \
15 # /usr/src/linux-$(shell uname -r | sed 's/-.*//') \
16 # /usr/src/kernel-headers-$(shell uname -r) \
17 # /usr/src/kernel-source-$(shell uname -r) \
18 # /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \
19 # /usr/src/linux /home/plice
21 #test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir))
23 #KSP := $(foreach dir, $(KSP), $(test_dir))
26 KSRC := $(firstword $(KSP))
29 # $( error Linux kernel source not found)
32 # check kernel version
33 KVER := $(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/')
34 KERVER2=$(shell uname -r | cut -d. -f2)
45 INSTDIR := $(shell find /lib/modules/$(shell uname -r) -name $(TARGET) -printf "%h\n" | sort | head -1)
48 ifneq (,$(wildcard /lib/modules/$(shell uname -r)/kernel))
49 INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
51 INSTDIR := /lib/modules/$(shell uname -r)/net
55 INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net
57 INSTDIR := /lib/modules/$(shell uname -r)/net
63 SRC = device_main.c card.c mac.c baseband.c wctl.c 80211mgr.c \
64 wcmd.c wmgr.c bssdb.c wpa2.c rxtx.c dpc.c power.c datarate.c \
65 srom.c mib.c rc4.c tether.c tcrc.c ioctl.c hostap.c wpa.c key.c \
66 tkip.c michael.c wroute.c rf.c iwctl.c wpactl.c aes_ccmp.c \
70 EXTRA_CFLAGS += -DIO_MAP
74 EXTRA_CFLAGS += -DHOSTAP
78 EXTRA_CFLAGS += -DPRIVATE_OBJ
81 EXTRA_CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/../solomon
83 EXTRA_CFLAGS += -I$(PWD)/include -I$(PWD)/solomon
90 KERNEL_CONF= $(KSRC)/.config
93 include ${KERNEL_CONF}
97 viawget-objs := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
98 wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
99 mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
100 michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o \
104 $(CC) $(CFLAGS) -o $@ $<
107 make -C $(KSRC) SUBDIRS=$(shell pwd) modules
112 OBJS := device_main.o card.o mac.o baseband.o wctl.o 80211mgr.o \
113 wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o srom.o \
114 mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \
115 michael.o wroute.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o \
118 VERSION_FILE := $(KSRC)/include/linux/version.h
119 CONFIG_FILE := $(KSRC)/include/linux/config.h
122 ifeq (,$(wildcard $(VERSION_FILE)))
123 $(error Linux kernel source not configured - missing version.h)
126 ifeq (,$(wildcard $(CONFIG_FILE)))
127 $(error Linux kernel source not configured - missing config.h)
130 ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
136 test_cc = $(shell which $(cc) > /dev/null 2>&1 && echo $(cc))
137 CC := $(foreach cc, $(CC), $(test_cc))
138 CC := $(firstword $(CC))
140 EXTRA_CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe
141 EXTRA_CFLAGS += -I$(KSRC)/include -Wstrict-prototypes -fomit-frame-pointer -fno-strict-aliasing
142 EXTRA_CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \
143 echo "-DMODVERSIONS -include $(KSRC)/include/linux/modversions.h")
145 .SILENT: $(TARGET) clean
148 # look for SMP in config.h
149 SMP := $(shell $(CC) $(CFLAGS) -E -dM $(CONFIG_FILE) | \
150 grep CONFIG_SMP | awk '{ print $$3 }')
158 EXTRA_CFLAGS += -D__SMP__
162 ifeq ($(PRIV_OBJ), 1)
163 EXTRA_CFLAGS += -DPRIVATE_OBJ
174 SUBARCH := $(shell uname -m)
175 ifeq ($(SUBARCH),x86_64)
176 EXTRA_CFLAGS += -mcmodel=kernel -mno-red-zone
180 $(TARGET): $(filter-out $(TARGET), $(SRC:.c=.o))
183 echo "**************************************************"
184 echo "Build options:"
185 echo " VERSION $(KVER)"
187 if [ "$(SMP)" = "1" ]; \
188 then echo "Enabled"; else echo "Disabled"; fi
192 endif # ifeq ($(KVER),2.6)
198 install: clean $(TARGET)
200 mkdir -p $(MOD_ROOT)$(INSTDIR)
201 install -m 644 -o root $(TARGET) $(MOD_ROOT)$(INSTDIR)
204 /sbin/depmod -a || true
206 /sbin/depmod -b $(MOD_ROOT) -a || true
211 rm -f $(INSTDIR)/$(TARGET)
215 rm -f $(TARGET) $(SRC:.c=.o) *.o *~
216 rm -f .*.o.d .*.o.cmd .*.ko.cmd *.mod.c *.mod.o