rt2x00 fixes after [8548]:
[openwrt/svn-archive/archive.git] / package / rt2x00 / src / Makefile
1 # Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
2 # <http://rt2x00.serialmonkey.com>
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the
16 # Free Software Foundation, Inc.,
17 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 # Module: Makefile
20 # Abstract: Makefile for rt2x00 kernel module
21
22 #
23 # Set the enviroment variables.
24 #
25 ifndef SUBDIRS
26 SUBDIRS=$(shell pwd)
27 endif
28
29 ifdef KERNDIR
30 KERNEL_SOURCES := $(KERNDIR)
31 else
32 KERNEL_SOURCES := /lib/modules/$(shell uname -r)/build
33 endif
34
35 ifdef KERNOUT
36 KERNEL_OUTPUT := KBUILD_OUTPUT=$(KERNOUT)
37 else
38 KERNEL_OUTPUT :=
39 endif
40
41 #
42 # Determine if and with what options the rt2x00 drivers should be build
43 #
44 rt2x00lib-objs := rt2x00dev.o rt2x00mac.o
45
46 ifeq ($(CONFIG_RT2X00),y)
47 obj-m += rt2x00lib.o
48
49 ifneq ($(CONFIG_PCI),)
50 obj-m += rt2x00pci.o
51 endif
52
53 ifneq ($(CONFIG_USB),)
54 obj-m += rt2x00usb.o
55 endif
56
57 ifeq ($(CONFIG_RT2X00_LIB_DEBUGFS),y)
58 rt2x00lib-objs += rt2x00debug.o
59 endif
60
61 ifeq ($(CONFIG_RT2400PCI),y)
62 obj-m += rt2400pci.o
63 ifeq ($(CONFIG_RT2400PCI_RFKILL),y)
64 rt2x00lib-objs += rt2x00rfkill.o
65 CFLAGS += -DCONFIG_RT2X00_LIB_RFKILL
66 endif
67 endif
68
69 ifeq ($(CONFIG_RT2500PCI),y)
70 obj-m += rt2500pci.o
71 ifeq ($(CONFIG_RT2500PCI_RFKILL),y)
72 rt2x00lib-objs += rt2x00rfkill.o
73 CFLAGS += -DCONFIG_RT2X00_LIB_RFKILL
74 endif
75 endif
76
77 ifeq ($(CONFIG_RT2500USB),y)
78 obj-m += rt2500usb.o
79 endif
80
81 ifeq ($(CONFIG_RT61PCI),y)
82 CFLAGS += -DCONFIG_RT2X00_LIB_FIRMWARE
83 rt2x00lib-objs += rt2x00firmware.o
84 obj-m += rt61pci.o
85 ifeq ($(CONFIG_RT61PCI_RFKILL),y)
86 rt2x00lib-objs += rt2x00rfkill.o
87 CFLAGS += -DCONFIG_RT2X00_LIB_RFKILL
88 endif
89 endif
90
91 ifeq ($(CONFIG_RT73USB),y)
92 CFLAGS += -DCONFIG_RT2X00_LIB_FIRMWARE
93 rt2x00lib-objs += rt2x00firmware.o
94 obj-m += rt73usb.o
95 endif
96
97 endif
98
99 MAKEFLAGS += --no-print-directory
100 CFLAGS := -include $(SUBDIRS)/rt2x00_compat.h $(CFLAGS)
101
102 all: default
103
104 config_header:
105 @if [ ! -f "rt2x00_config.h" ] || [ "rt2x00_config.h" -ot "config" ]; \
106 then \
107 awk -F = > rt2x00_config.h < config '/^CONFIG.*$\/ \
108 { \
109 if($$2 == "y") { \
110 print "#ifndef " $$1; \
111 print "#define " $$1; \
112 print "#endif"; \
113 print "" \
114 } else { \
115 print "#undef " $$1; \
116 print ""; \
117 } \
118 }'; \
119 fi
120
121 default: config_header
122 @$(MAKE) -C $(KERNEL_SOURCES) SUBDIRS=$(SUBDIRS) $(KERNEL_OUTPUT) \
123 modules
124
125 sparse: config_header
126 @$(MAKE) -C $(KERNEL_SOURCES) SUBDIRS=$(SUBDIRS) $(KERNEL_OUTPUT) \
127 modules C=1 CF=-D__CHECK_ENDIAN__
128
129 install: config_header
130 @$(MAKE) -C $(KERNEL_SOURCES) SUBDIRS=$(SUBDIRS) $(KERNEL_OUTPUT) \
131 INSTALL_MOD_DIR=rt2x00 $(KERNEL_OUTPUT) modules_install
132 /sbin/depmod -a
133
134 clean:
135 @rm -f rt2x00_config.h
136 @rm -f Modules.symvers Module.symvers
137 @for folder in $(EXTMODDIRS); \
138 do \
139 rm -f $${folder}/*.o \
140 rm -f $${folder}/*.ko \
141 rm -f $${folder}/*.s \
142 rm -f $${folder}/*.mod.c \
143 rm -f $${folder}/.*.cmd \
144 rm -f $${folder}/.*.flags \
145 rm -f $${folder}/.*.o.d \
146 rm -f $${folder}/.*.s.d \
147 rm -f $${folder}/.#* \
148 rm -f $${folder}/*~ \
149 rm -fr $${folder}/.tmp_versions; \
150 done