drivers/net/wireless/wl12xx: Use available error codes
[pandora-wifi.git] / Makefile
1 export KMODDIR?=       updates
2 KMODDIR_ARG:=   "INSTALL_MOD_DIR=$(KMODDIR)"
3 ifneq ($(origin KLIB), undefined)
4 KMODPATH_ARG:=  "INSTALL_MOD_PATH=$(KLIB)"
5 else
6 export KLIB:=          /lib/modules/$(shell uname -r)
7 endif
8 export KLIB_BUILD ?=    $(KLIB)/build
9 # Sometimes not available in the path
10 MODPROBE := /sbin/modprobe
11 MADWIFI=$(shell $(MODPROBE) -l ath_pci)
12 OLD_IWL=$(shell $(MODPROBE) -l iwl4965)
13
14 DESTDIR?=
15
16 ifneq ($(KERNELRELEASE),)
17
18 NOSTDINC_FLAGS := -I$(M)/include/ -include $(M)/include/linux/compat-2.6.h $(CFLAGS)
19
20 obj-y := compat/
21
22 obj-$(CONFIG_COMPAT_RFKILL) += net/rfkill/
23
24 ifeq ($(BT),)
25 obj-$(CONFIG_COMPAT_WIRELESS) += net/wireless/ net/mac80211/
26 obj-$(CONFIG_COMPAT_WIRELESS_MODULES) += drivers/net/wireless/
27
28 obj-$(CONFIG_COMPAT_NET_USB_MODULES) += drivers/net/usb/
29
30 obj-$(CONFIG_COMPAT_NETWORK_MODULES) += drivers/net/
31 obj-$(CONFIG_COMPAT_VAR_MODULES) +=  drivers/ssb/ drivers/misc/eeprom/
32 endif
33
34 obj-$(CONFIG_COMPAT_BLUETOOTH) += net/bluetooth/
35 obj-$(CONFIG_COMPAT_BLUETOOTH_MODULES) += drivers/bluetooth/
36
37 else
38
39 export PWD :=   $(shell pwd)
40
41 # These exported as they are used by the scripts
42 # to check config and compat autoconf
43 export COMPAT_CONFIG=config.mk
44 export CONFIG_CHECK=.$(COMPAT_CONFIG)_md5sum.txt
45 export COMPAT_AUTOCONF=include/linux/compat_autoconf.h
46 export CREL=$(shell cat $(PWD)/compat-release)
47 export CREL_PRE:=.compat_autoconf_
48 export CREL_CHECK:=$(CREL_PRE)$(CREL)
49
50 include $(PWD)/$(COMPAT_CONFIG)
51
52 all: modules
53
54 modules: $(CREL_CHECK)
55         @./scripts/check_config.sh
56         $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules
57         @touch $@
58
59 bt: $(CREL_CHECK)
60         @./scripts/check_config.sh
61         $(MAKE) -C $(KLIB_BUILD) M=$(PWD) BT=TRUE modules
62         @touch $@
63
64 # With the above and this we make sure we generate a new compat autoconf per
65 # new relase of compat-wireless-2.6 OR when the user updates the 
66 # $(COMPAT_CONFIG) file
67 $(CREL_CHECK):
68         @# Force to regenerate compat autoconf
69         @rm -f $(CONFIG_CHECK)
70         @./scripts/check_config.sh
71         @touch $@
72         @md5sum $(COMPAT_CONFIG) > $(CONFIG_CHECK)
73
74 btinstall: btuninstall bt-install-modules
75
76 bt-install-modules: bt
77         $(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) BT=TRUE \
78                 modules_install
79         @/sbin/depmod -ae
80         @echo
81         @echo "Currently detected bluetooth subsystem modules:"
82         @echo
83         @$(MODPROBE) -l sco
84         @$(MODPROBE) -l l2cap
85         @$(MODPROBE) -l hidp
86         @$(MODPROBE) -l rfcomm
87         @$(MODPROBE) -l bnep
88         @$(MODPROBE) -l btusb
89         @$(MODPROBE) -l bluetooth
90         @echo
91         @echo Now run:
92         @echo
93         @echo sudo make btunload:
94         @echo
95         @echo And the load the needed bluetooth modules. If unsure reboot.
96         @echo
97
98 btuninstall:
99         @# New location, matches upstream
100         @rm -rf $(KLIB)/$(KMODDIR)/net/bluetooth/
101         @rm -rf $(KLIB)/$(KMODDIR)/drivers/bluetooth/
102         @# Lets only remove the stuff we are sure we are providing
103         @# on the misc directory.
104         @/sbin/depmod -ae
105         @echo
106         @echo "Your old bluetooth subsystem modules were left intact:"
107         @echo
108         @$(MODPROBE) -l sco
109         @$(MODPROBE) -l l2cap
110         @$(MODPROBE) -l hidp
111         @$(MODPROBE) -l rfcomm
112         @$(MODPROBE) -l bnep
113         @$(MODPROBE) -l btusb
114         @$(MODPROBE) -l bluetooth
115         @
116         @echo
117
118 btclean:
119         make -C /lib/modules/$(shell uname -r)/build M=$(PWD) BT=TRUE clean
120         @rm -f $(CREL_PRE)*
121
122 install: uninstall install-modules install-scripts
123
124 install-modules: modules
125         $(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \
126                 modules_install
127         @./scripts/update-initramfs
128
129 install-scripts:
130         @# All the scripts we can use
131         @mkdir -p $(DESTDIR)/usr/lib/compat-wireless/
132         @install scripts/modlib.sh      $(DESTDIR)/usr/lib/compat-wireless/
133         @install scripts/madwifi-unload $(DESTDIR)/usr/sbin/
134         @# This is to allow switching between drivers without blacklisting
135         @install scripts/athenable      $(DESTDIR)/usr/sbin/
136         @install scripts/b43enable      $(DESTDIR)/usr/sbin/
137         @install scripts/iwl-enable     $(DESTDIR)/usr/sbin/
138         @install scripts/athload        $(DESTDIR)/usr/sbin/
139         @install scripts/b43load        $(DESTDIR)/usr/sbin/
140         @install scripts/iwl-load       $(DESTDIR)/usr/sbin/
141         @if [ ! -z "$(MADWIFI)" ] && [ -z "$(DESTDIR)" ]; then \
142                 echo ;\
143                 echo -n "Note: madwifi detected, we're going to disable it. "  ;\
144                 echo "If you would like to enable it later you can run:"  ;\
145                 echo "    sudo athenable madwifi"  ;\
146                 echo ;\
147                 echo Running athenable ath5k...;\
148                 /usr/sbin/athenable ath5k ;\
149         fi
150         @if [ ! -z "$(OLD_IWL)" ] && [ -z "$(DESTDIR)" ]; then \
151                 echo ;\
152                 echo -n "Note: iwl4965 detected, we're going to disable it. "  ;\
153                 echo "If you would like to enable it later you can run:"  ;\
154                 echo "    sudo iwl-load iwl4965"  ;\
155                 echo ;\
156                 echo Running iwl-enable iwlagn...;\
157                 /usr/sbin/iwl-enable iwlagn ;\
158         fi
159         @# If on distributions like Mandriva which like to
160         @# compress their modules this will find out and do
161         @# it for you. Reason is some old version of modutils
162         @# won't know mac80211.ko should be used instead of
163         @# mac80211.ko.gz
164         @./scripts/compress_modules
165         @# Mandrake doesn't have a depmod.d/ conf file to prefer
166         @# the updates/ dir which is what we use so we add one for it
167         @# (or any other distribution that doens't have this).
168         @./scripts/check_depmod
169         @# Udev stuff needed for the new compat_firmware_class.
170         @./compat/scripts/compat_firmware_install
171         @/sbin/depmod -a
172         @echo
173         @echo "Currently detected wireless subsystem modules:"
174         @echo 
175         @$(MODPROBE) -l mac80211
176         @$(MODPROBE) -l cfg80211
177         @$(MODPROBE) -l lib80211
178         @$(MODPROBE) -l adm8211
179         @$(MODPROBE) -l ar9170usb
180         @$(MODPROBE) -l at76c50x-usb
181         @$(MODPROBE) -l ath
182         @$(MODPROBE) -l ath5k
183         @$(MODPROBE) -l ath9k
184         @$(MODPROBE) -l b43
185         @$(MODPROBE) -l b43legacy
186         @$(MODPROBE) -l b44
187         @$(MODPROBE) -l cdc_ether
188         @$(MODPROBE) -l eeprom_93cx6
189         @$(MODPROBE) -l ipw2100
190         @$(MODPROBE) -l ipw2200
191         @$(MODPROBE) -l iwl3945
192         @$(MODPROBE) -l iwlagn
193         @$(MODPROBE) -l iwlcore
194         @$(MODPROBE) -l lib80211_crypt_ccmp
195         @$(MODPROBE) -l lib80211_crypt_tkip
196         @$(MODPROBE) -l lib80211_crypt_wep
197         @$(MODPROBE) -l libertas
198         @$(MODPROBE) -l libertas_cs
199         @$(MODPROBE) -l libertas_sdio
200         @$(MODPROBE) -l libertas_spi
201         @$(MODPROBE) -l libertas_tf
202         @$(MODPROBE) -l libertas_tf_usb
203         @$(MODPROBE) -l libipw
204         @$(MODPROBE) -l mac80211_hwsim
205         @$(MODPROBE) -l mwl8k
206         @$(MODPROBE) -l p54common
207         @$(MODPROBE) -l p54pci
208         @$(MODPROBE) -l p54spi
209         @$(MODPROBE) -l p54usb
210         @$(MODPROBE) -l rndis_host
211         @$(MODPROBE) -l rndis_wlan
212         @$(MODPROBE) -l rt2400pci
213         @$(MODPROBE) -l rt2500pci
214         @$(MODPROBE) -l rt2500usb
215         @$(MODPROBE) -l rt2x00lib
216         @$(MODPROBE) -l rt2x00pci
217         @$(MODPROBE) -l rt2x00usb
218         @$(MODPROBE) -l rt61pci
219         @$(MODPROBE) -l rt73usb
220         @$(MODPROBE) -l rtl8180
221         @$(MODPROBE) -l rtl8187
222         @$(MODPROBE) -l ssb
223         @$(MODPROBE) -l usb8xxx
224         @$(MODPROBE) -l usbnet
225         @$(MODPROBE) -l zd1211rw
226         @echo
227         @echo "Currently detected bluetooth subsystem modules:"
228         @echo
229         @$(MODPROBE) -l sco
230         @$(MODPROBE) -l l2cap
231         @$(MODPROBE) -l hidp
232         @$(MODPROBE) -l rfcomm
233         @$(MODPROBE) -l bnep
234         @$(MODPROBE) -l btusb
235         @$(MODPROBE) -l bluetooth
236         @echo 
237         @echo Now run:
238         @echo 
239         @echo sudo make unload to unload both wireless and bluetooth modules
240         @echo sudo make wlunload to unload wireless modules
241         @echo sudo make btunload to unload bluetooth modules
242         @echo
243         @echo And then load the wireless or bluetooth module you need. If unsure reboot.
244         @echo Alternatively use "sudo make load/wlload/btload" to load modules
245         @echo
246
247 uninstall:
248         @# New location, matches upstream
249         @rm -rf $(KLIB)/$(KMODDIR)/net/mac80211/
250         @rm -rf $(KLIB)/$(KMODDIR)/net/rfkill/
251         @rm -rf $(KLIB)/$(KMODDIR)/net/wireless/
252         @rm -rf $(KLIB)/$(KMODDIR)/drivers/ssb/
253         @rm -rf $(KLIB)/$(KMODDIR)/drivers/net/usb/
254         @rm -rf $(KLIB)/$(KMODDIR)/drivers/net/wireless/
255         @# Lets only remove the stuff we are sure we are providing
256         @# on the misc directory.
257         @rm -f $(KLIB)/$(KMODDIR)/drivers/misc/eeprom/eeprom_93cx6.ko*
258         @rm -f $(KLIB)/$(KMODDIR)/drivers/misc/eeprom_93cx6.ko*
259         @rm -f $(KLIB)/$(KMODDIR)/drivers/net/b44.ko*
260         @/sbin/depmod -a
261         @echo
262         @echo "Your old wireless subsystem modules were left intact:"
263         @echo 
264         @$(MODPROBE) -l mac80211
265         @$(MODPROBE) -l cfg80211
266         @$(MODPROBE) -l lib80211
267         @$(MODPROBE) -l adm8211
268         @$(MODPROBE) -l ar9170usb
269         @$(MODPROBE) -l at76c50x-usb
270         @$(MODPROBE) -l ath
271         @$(MODPROBE) -l ath5k
272         @$(MODPROBE) -l ath9k
273         @$(MODPROBE) -l b43
274         @$(MODPROBE) -l b43legacy
275         @$(MODPROBE) -l b44
276         @$(MODPROBE) -l cdc_ether
277         @$(MODPROBE) -l eeprom_93cx6
278         @$(MODPROBE) -l ipw2100
279         @$(MODPROBE) -l ipw2200
280         @$(MODPROBE) -l iwl3945
281         @$(MODPROBE) -l iwlagn
282         @$(MODPROBE) -l iwlcore
283         @$(MODPROBE) -l lib80211_crypt_ccmp
284         @$(MODPROBE) -l lib80211_crypt_tkip
285         @$(MODPROBE) -l lib80211_crypt_wep
286         @$(MODPROBE) -l libertas
287         @$(MODPROBE) -l libertas_cs
288         @$(MODPROBE) -l libertas_sdio
289         @$(MODPROBE) -l libertas_spi
290         @$(MODPROBE) -l libertas_tf
291         @$(MODPROBE) -l libertas_tf_usb
292         @$(MODPROBE) -l libipw
293         @$(MODPROBE) -l mac80211_hwsim
294         @$(MODPROBE) -l mwl8k
295         @$(MODPROBE) -l p54common
296         @$(MODPROBE) -l p54pci
297         @$(MODPROBE) -l p54spi
298         @$(MODPROBE) -l p54usb
299         @$(MODPROBE) -l rndis_host
300         @$(MODPROBE) -l rndis_wlan
301         @$(MODPROBE) -l rt2400pci
302         @$(MODPROBE) -l rt2500pci
303         @$(MODPROBE) -l rt2500usb
304         @$(MODPROBE) -l rt2x00lib
305         @$(MODPROBE) -l rt2x00pci
306         @$(MODPROBE) -l rt2x00usb
307         @$(MODPROBE) -l rt61pci
308         @$(MODPROBE) -l rt73usb
309         @$(MODPROBE) -l rtl8180
310         @$(MODPROBE) -l rtl8187
311         @$(MODPROBE) -l ssb
312         @$(MODPROBE) -l usb8xxx
313         @$(MODPROBE) -l usbnet
314         @$(MODPROBE) -l zd1211rw
315         @echo
316         @echo "Your old bluetooth subsystem modules were left intact:"
317         @echo
318         @$(MODPROBE) -l sco
319         @$(MODPROBE) -l l2cap
320         @$(MODPROBE) -l hidp
321         @$(MODPROBE) -l rfcomm
322         @$(MODPROBE) -l bnep
323         @$(MODPROBE) -l btusb
324         @$(MODPROBE) -l bluetooth
325         @
326         @echo 
327
328 clean:
329         @if [ -d net -a -d $(KLIB_BUILD) ]; then \
330                 $(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean ;\
331         fi
332         @rm -f $(CREL_PRE)*
333 unload:
334         @./scripts/unload.sh
335
336 load: unload
337         @./scripts/load.sh
338
339 btunload:
340         @./scripts/btunload.sh
341
342 btload: btunload
343         @./scripts/btload.sh
344
345 wlunload:
346         @./scripts/wlunload.sh
347
348 wlload: wlunload
349         @./scripts/wlload.sh
350
351 .PHONY: all clean install uninstall unload load btunload btload wlunload wlload modules bt
352
353 endif
354
355 clean-files += Module.symvers Module.markers modules modules.order
356 clean-files += $(CREL_CHECK) $(CONFIG_CHECK)