Code Sample |
all: module MODULE_NAME := rt2570 #PATCHLEVEL := 6 #KERNDIR=/usr/src/linux-2.6 #MODDIR=/lib/modules/2.6.12/extra ifeq ($(PATCHLEVEL),) PATCHLEVEL := $(shell uname -r | cut -d. -f2) endif RESMAN_CORE_OBJS := rtusb_main.o RESMAN_GLUE_OBJS := mlme.o rtusb_bulk.o connect.o sync.o rtusb_init.o rtmp_tkip.o wpa.o rtmp_wep.o rtusb_info.o assoc.o auth.o auth_rsp.o md5.o rtusb_io.o sanity.o rtusb_data.o $(MODULE_NAME)-objs := $(RESMAN_CORE_OBJS) $(RESMAN_GLUE_OBJS) ifdef TOPDIR obj-m += $(MODULE_NAME).o endif EXTRA_CFLAGS += -I$(src) ifdef KERNDIR KERNEL_SOURCES := $(KERNDIR) else KERNEL_SOURCES := /lib/modules/$(shell uname -r)/build endif ifdef MODDIR MODULE_ROOT := $(MODDIR) else MODULE_ROOT := /lib/modules/$(shell uname -r)/extra endif ifdef KERNOUT KERNEL_OUTPUT := KBUILD_OUTPUT=$(KERNOUT) else KERNEL_OUTPUT := endif src ?= . obj ?= . ifeq ($(PATCHLEVEL), 4) MODULE_OBJECT := $(MODULE_NAME).o MODULE_CONF := /etc/modules.conf else MODULE_OBJECT := $(MODULE_NAME).ko MODULE_CONF := /etc/modprobe.conf endif ifeq ($(PATCHLEVEL), 4) $(obj)/$(MODULE_NAME).o: $($(MODULE_NAME)-objs) $(LD) $(EXTRA_LDFLAGS) -r -o $@ $($(MODULE_NAME)-objs) endif KBUILD_PARAMS := -C $(KERNEL_SOURCES) SUBDIRS=$(CURDIR) $(KERNEL_OUTPUT) module: @$(MAKE) $(KBUILD_PARAMS) modules; \ if ! [ -f $(MODULE_OBJECT) ]; then \ echo "$(MODULE_OBJECT) failed to build!"; \ exit 1; \ fi arm: @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-mstructure-size-boundary=8 -I$(src)' modules; if ! [ -f $(MODULE_OBJECT) ]; then \ echo "$(MODULE_OBJECT) failed to build!"; \ exit 1; \ fi armdebug: @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-mstructure-size-boundary=8 -I$(src) -DRT2500_DBG' modules; if ! [ -f $(MODULE_OBJECT) ]; then \ echo "$(MODULE_OBJECT) failed to build!"; \ exit 1; \ fi debug: @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-I$(src) -DRT2500_DBG' modules; \ if ! [ -f $(MODULE_OBJECT) ]; then \ echo "$(MODULE_OBJECT) failed to build!"; \ exit 1; \ fi debugfs: @$(MAKE) $(KBUILD_PARAMS) 'EXTRA_CFLAGS=-I$(src) -DRT2500_DBG -DRT2X00DEBUGFS' modules; \ if ! [ -f $(MODULE_OBJECT) ]; then \ echo "$(MODULE_OBJECT) failed to build!"; \ exit 1; \ fi clean: @rm -f $(RESMAN_GLUE_OBJS) $(RESMAN_CORE_OBJS) .*.{cmd,flags} @rm -f $(MODULE_NAME).{o,ko,mod.{o,c}} built-in.o $(VERSION_HEADER) *~ @rm -fr .tmp_versions Module.symvers modules_install: @if ! [ -f $(MODULE_OBJECT) ]; then \ $(MAKE) module; \ fi ifeq ($(PATCHLEVEL),4) @echo "install '$(MODULE_OBJECT)' to $(MODULE_ROOT)" install -m 755 -o 0 -g 0 -d $(MODULE_ROOT) install -m 644 -o 0 -g 0 $(MODULE_OBJECT) $(MODULE_ROOT) /sbin/depmod -a else @echo "2.6 module install" make $(KBUILD_PARAMS) modules_install /sbin/depmod -a endif install: modules_install @if ! grep -q 'rausb0' $(MODULE_CONF); then \ echo "append 'alias rausb0 rt2570' to $(MODULE_CONF)"; \ echo "alias rausb0 rt2570" >> $(MODULE_CONF); \ fi install-fedora: if ! [ -f $(MODULE_OBJECT) ]; then \ module; \ fi @echo "install '$(MODULE_OBJECT)' to $(MODULE_ROOT)" install -m 755 -o 0 -g 0 -d $(MODULE_ROOT) install -m 644 -o 0 -g 0 $(MODULE_OBJECT) $(MODULE_ROOT) /sbin/depmod -a @if ! grep -q 'wlan0' /etc/modprobe.conf; then \ echo "append 'alias wlan0 rt2570' to /etc/modprobe.conf"; \ echo "alias wlan0 rt2570" >> /etc/modprobe.conf; \ echo "options rt2570 ifname=wlan%d" >> /etc/modprobe.conf; \ fi ifeq ($(PATCHLEVEL), 4) include $(KERNEL_SOURCES)/Rules.make endif |