192b96797SForest Bond# 292b96797SForest Bond# Build options: 392b96797SForest Bond# 492b96797SForest Bond# 592b96797SForest Bond 692b96797SForest BondHOSTAP := 1 792b96797SForest Bond 892b96797SForest Bond 992b96797SForest BondKSP := /lib/modules/$(shell uname -r)/build \ 1092b96797SForest Bond /usr/src/linux-$(shell uname -r) \ 1192b96797SForest Bond /usr/src/linux-$(shell uname -r | sed 's/-.*//') \ 1292b96797SForest Bond /usr/src/kernel-headers-$(shell uname -r) \ 1392b96797SForest Bond /usr/src/kernel-source-$(shell uname -r) \ 1492b96797SForest Bond /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \ 1592b96797SForest Bond /usr/src/linux 1692b96797SForest Bond 1792b96797SForest Bondtest_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir)) 1892b96797SForest BondKSP := $(foreach dir, $(KSP), $(test_dir)) 1992b96797SForest Bond 2092b96797SForest BondKSRC := $(firstword $(KSP)) 2192b96797SForest Bond 2292b96797SForest Bondifeq (,$(KSRC)) 2392b96797SForest Bond $(error Linux kernel source not found) 2492b96797SForest Bondendif 2592b96797SForest Bond 2692b96797SForest Bond# check kernel version 2792b96797SForest BondKVER := $(shell uname -r | cut -c1-3 | sed 's/2\.[56]/2\.6/') 2892b96797SForest BondKERVER2=$(shell uname -r | cut -d. -f2) 2992b96797SForest Bond 3092b96797SForest Bondifeq ($(KVER), 2.6) 3192b96797SForest Bond# 2.6 kernel 3292b96797SForest BondTARGET = vntwusb.ko 3392b96797SForest Bond 3492b96797SForest Bondelse 3592b96797SForest BondTARGET = vntwusb.o 3692b96797SForest Bond 3792b96797SForest Bondendif 3892b96797SForest Bond 3992b96797SForest BondINSTDIR := $(shell find /lib/modules/$(shell uname -r) -name $(TARGET) -printf "%h\n" | sort | head -1) 4092b96797SForest Bondifeq (,$(INSTDIR)) 4192b96797SForest Bond ifeq (,$(KERVER2)) 4292b96797SForest Bond ifneq (,$(wildcard /lib/modules/$(shell uname -r)/kernel)) 4392b96797SForest Bond INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net 4492b96797SForest Bond else 4592b96797SForest Bond INSTDIR := /lib/modules/$(shell uname -r)/net 4692b96797SForest Bond endif 4792b96797SForest Bond else 4892b96797SForest Bond ifneq ($(KERVER2),2) 4992b96797SForest Bond INSTDIR := /lib/modules/$(shell uname -r)/kernel/drivers/net 5092b96797SForest Bond else 5192b96797SForest Bond INSTDIR := /lib/modules/$(shell uname -r)/net 5292b96797SForest Bond endif 5392b96797SForest Bond endif 5492b96797SForest Bondendif 5592b96797SForest Bond 5692b96797SForest Bond 5792b96797SForest BondSRC = main_usb.c card.c mac.c baseband.c wctl.c 80211mgr.c \ 5892b96797SForest Bond wcmd.c wmgr.c bssdb.c wpa2.c rxtx.c dpc.c power.c datarate.c \ 5992b96797SForest Bond mib.c rc4.c tether.c tcrc.c ioctl.c hostap.c wpa.c key.c \ 6092b96797SForest Bond tkip.c michael.c rf.c iwctl.c wpactl.c aes_ccmp.c \ 6192b96797SForest Bond usbpipe.c channel.c control.c firmware.c int.c 6292b96797SForest Bond 6392b96797SForest Bond 6492b96797SForest Bondifeq ($(HOSTAP), 1) 6592b96797SForest Bond# CFLAGS += -DHOSTAP 6692b96797SForest Bond EXTRA_CFLAGS += -DHOSTAP 6792b96797SForest Bondendif 6892b96797SForest Bond 6992b96797SForest Bond 7092b96797SForest Bond#CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/include 7192b96797SForest BondEXTRA_CFLAGS += -I$(PWD) -I$(PWD)/../include -I$(PWD)/include 7292b96797SForest Bond 7392b96797SForest Bond# build rule 7492b96797SForest Bondifeq ($(KVER), 2.6) 7592b96797SForest Bond# 2.6 kernel 7692b96797SForest Bond 7792b96797SForest Bondifndef KERNEL_CONF 7892b96797SForest BondKERNEL_CONF= $(KSRC)/.config 7992b96797SForest Bondendif 8092b96797SForest Bond 8192b96797SForest Bondinclude ${KERNEL_CONF} 8292b96797SForest Bond 8392b96797SForest Bondobj-m += vntwusb.o 8492b96797SForest Bond 8592b96797SForest Bondvntwusb-objs := main_usb.o card.o mac.o baseband.o wctl.o 80211mgr.o \ 8692b96797SForest Bond wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o \ 8792b96797SForest Bond mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \ 8892b96797SForest Bond michael.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o \ 8992b96797SForest Bond usbpipe.o channel.o control.o firmware.o int.o 9092b96797SForest Bond 9192b96797SForest Bond.c.o: 9292b96797SForest Bond# $(CC) $(CFLAGS) -o $@ $< 9392b96797SForest Bond $(CC) $(EXTRA_CFLAGS) -o $@ $< 9492b96797SForest Bond 9592b96797SForest Bonddefault: 9692b96797SForest Bond make -C $(KSRC) SUBDIRS=$(shell pwd) modules 9792b96797SForest Bond 9892b96797SForest Bondelse 9992b96797SForest Bond 10092b96797SForest Bond# 2.2/2.4 kernel 10192b96797SForest BondOBJS := main_usb.o card.o mac.o baseband.o wctl.o 80211mgr.o \ 10292b96797SForest Bond wcmd.o wmgr.o bssdb.o rxtx.o dpc.o power.o datarate.o \ 10392b96797SForest Bond mib.o rc4.o tether.o tcrc.o ioctl.o hostap.o wpa.o key.o tkip.o \ 10492b96797SForest Bond michael.o rf.o iwctl.o wpactl.o wpa2.o aes_ccmp.o \ 10592b96797SForest Bond usbpipe.o channel.o control.o 10692b96797SForest Bond 10792b96797SForest BondVERSION_FILE := $(KSRC)/include/linux/version.h 10892b96797SForest BondCONFIG_FILE := $(KSRC)/include/linux/config.h 10992b96797SForest Bond 11092b96797SForest Bond 11192b96797SForest Bondifeq (,$(wildcard $(VERSION_FILE))) 11292b96797SForest Bond $(error Linux kernel source not configured - missing version.h) 11392b96797SForest Bondendif 11492b96797SForest Bond 11592b96797SForest Bondifeq (,$(wildcard $(CONFIG_FILE))) 11692b96797SForest Bond $(error Linux kernel source not configured - missing config.h) 11792b96797SForest Bondendif 11892b96797SForest Bond 11992b96797SForest Bondifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version))) 12092b96797SForest Bond CC := kgcc gcc cc 12192b96797SForest Bondelse 12292b96797SForest Bond CC := gcc cc 12392b96797SForest Bondendif 12492b96797SForest Bond 12592b96797SForest Bondtest_cc = $(shell which $(cc) > /dev/null 2>&1 && echo $(cc)) 12692b96797SForest BondCC := $(foreach cc, $(CC), $(test_cc)) 12792b96797SForest BondCC := $(firstword $(CC)) 12892b96797SForest Bond 12992b96797SForest Bond#CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe 13092b96797SForest Bond#CFLAGS += -I$(KSRC)/include -Wstrict-prototypes -fomit-frame-pointer -fno-strict-aliasing 13192b96797SForest Bond#CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \ 13292b96797SForest Bond# echo "-DMODVERSIONS -include $(KSRC)/include/linux/modversions.h") 13392b96797SForest BondEXTRA_CFLAGS += -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe 13492b96797SForest BondEXTRA_CFLAGS += -I$(KSRC)/include -Wstrict-prototypes -fomit-frame-pointer -fno-strict-aliasing 13592b96797SForest BondEXTRA_CFLAGS += $(shell [ -f $(KSRC)/include/linux/modversions.h ] && \ 13692b96797SForest Bond echo "-DMODVERSIONS -include $(KSRC)/include/linux/modversions.h") 13792b96797SForest Bond 13892b96797SForest Bond.SILENT: $(TARGET) clean 13992b96797SForest Bond 14092b96797SForest Bond 14192b96797SForest Bond# look for SMP in config.h 14292b96797SForest Bond#SMP := $(shell $(CC) $(CFLAGS) -E -dM $(CONFIG_FILE) | \ 14392b96797SForest Bond# grep CONFIG_SMP | awk '{ print $$3 }') 14492b96797SForest BondSMP := $(shell $(CC) $(EXTRA_CFLAGS) -E -dM $(CONFIG_FILE) | \ 14592b96797SForest Bond grep CONFIG_SMP | awk '{ print $$3 }') 14692b96797SForest Bondifneq ($(SMP),1) 14792b96797SForest Bond SMP := 0 14892b96797SForest Bondendif 14992b96797SForest Bond 15092b96797SForest Bond 15192b96797SForest Bondifeq ($(SMP), 1) 15292b96797SForest Bond# CFLAGS += -D__SMP__ 15392b96797SForest Bond EXTRA_CFLAGS += -D__SMP__ 15492b96797SForest Bondendif 15592b96797SForest Bond 15692b96797SForest Bond 15792b96797SForest Bond 15892b96797SForest Bond# check x86_64 15992b96797SForest BondSUBARCH := $(shell uname -m) 16092b96797SForest Bondifeq ($(SUBARCH),x86_64) 16192b96797SForest Bond# CFLAGS += -mcmodel=kernel -mno-red-zone 16292b96797SForest Bond EXTRA_CFLAGS += -mcmodel=kernel -mno-red-zone 16392b96797SForest Bondendif 16492b96797SForest Bond 16592b96797SForest Bond 16692b96797SForest Bond$(TARGET): $(filter-out $(TARGET), $(SRC:.c=.o)) 16792b96797SForest Bond $(LD) -r $^ -o $@ 16892b96797SForest Bond echo; echo 16992b96797SForest Bond echo "**************************************************" 17092b96797SForest Bond echo "Build options:" 17192b96797SForest Bond echo " VERSION $(KVER)" 17292b96797SForest Bond echo -n " SMP " 17392b96797SForest Bond if [ "$(SMP)" = "1" ]; \ 17492b96797SForest Bond then echo "Enabled"; else echo "Disabled"; fi 17592b96797SForest Bond 17692b96797SForest Bond 17792b96797SForest Bond 17892b96797SForest Bondendif # ifeq ($(KVER),2.6) 17992b96797SForest Bond 18092b96797SForest Bond 18192b96797SForest Bondifeq ($(KVER), 2.6) 18292b96797SForest Bondinstall: default 18392b96797SForest Bondelse 18492b96797SForest Bondinstall: clean $(TARGET) 18592b96797SForest Bondendif 18692b96797SForest Bond mkdir -p $(MOD_ROOT)$(INSTDIR) 18792b96797SForest Bond install -m 644 -o root $(TARGET) $(MOD_ROOT)$(INSTDIR) 18892b96797SForest Bond 18992b96797SForest Bondifeq (,$(MOD_ROOT)) 19092b96797SForest Bond /sbin/depmod -a || true 19192b96797SForest Bondelse 19292b96797SForest Bond /sbin/depmod -b $(MOD_ROOT) -a || true 19392b96797SForest Bondendif 19492b96797SForest Bond 19592b96797SForest Bond 19692b96797SForest Bonduninstall: 19792b96797SForest Bond rm -f $(INSTDIR)/$(TARGET) 19892b96797SForest Bond /sbin/depmod -a 19992b96797SForest Bond 20092b96797SForest Bondclean: 20192b96797SForest Bond rm -f $(TARGET) $(SRC:.c=.o) *~ *.o 20292b96797SForest Bond rm -f .*.o.d .*.o.cmd .*.ko.cmd *.mod.c *.mod.o 20392b96797SForest Bond 20492b96797SForest Bond-include .depend.mak 205