f23c406129599c47492278f6217655bee7b24113
[madwifi/.git] / Makefile.inc
1 #
2 # Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer,
10 #    without modification.
11 # 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 #    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
13 #    redistribution must be conditioned upon including a substantially
14 #    similar Disclaimer requirement for further binary redistribution.
15 # 3. Neither the names of the above-listed copyright holders nor the names
16 #    of any contributors may be used to endorse or promote products derived
17 #    from this software without specific prior written permission.
18 #
19 # Alternatively, this software may be distributed under the terms of the
20 # GNU General Public License ("GPL") version 2 as published by the Free
21 # Software Foundation.
22 #
23 # NO WARRANTY
24 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 # LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
27 # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
28 # THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
29 # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
32 # IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
34 # THE POSSIBILITY OF SUCH DAMAGES.
35 #
36 # $Id: //depot/sw/linuxsrc/src/802_11/madwifi/madwifi/Makefile.inc#11 $
37 #
38
39 # other locales sometimes cause trouble
40 export LC_ALL = POSIX
41
42 # BUS defines the bus type to which the wireless devices is attached.
43 # Currently, the valid BUS types are PCI and AHB.  If BUS is not
44 # defined, then, we assume the bus type is PCI
45 ifndef BUS
46 BUS=            PCI
47 endif
48
49 # DESTDIR is used as path prefix during installation.
50 DESTDIR ?=
51
52 # KERNELPATH is the path to the Linux kernel build tree.  Unless a
53 # separate build directory was used for the kernel build, it's the same
54 # as the kernel source tree.  KERNELPATH is used to access the kernel
55 # configuration, include files and the build system.  To build for
56 # another kernel, set KERNELPATH manually, for example with:
57 # make KERNELPATH=/path/to/kernel/source
58
59 # The default KERNELPATH points to the directory where the currently
60 # running kernel was compiled.  Note that the configuration and the
61 # version of the kernel tree might have changed since then.
62 ifeq ($(wildcard $(KERNELPATH)),)
63 KERNELPATH = /lib/modules/$(shell uname -r)/build
64 # sanity check: does KERNELPATH exist?
65 ifeq ($(shell cd $(KERNELPATH) && pwd),)
66 $(error $(KERNELPATH) is missing, please set KERNELPATH)
67 endif
68 export KERNELPATH
69 endif
70
71 # KERNELRELEASE is the target kernel's version.  It's always taken from
72 # the kernel build tree.  Kernel Makefile doesn't always know the exact
73 # kernel version (especially for vendor stock kernels), so we get it
74 # from <linux/version.h> instead. But simply grepping it from version.h
75 # doesn't work, since some distributions have multiple UTS_RELEASE
76 # in that file.
77 # This trick has been inspired by the lm_sensors project.
78 ifndef KERNELRELEASE
79 KERNELRELEASE := $(shell $(CC) -I $(KERNELPATH)/include -E $(TOP)/kernelversion.c | grep uts_release | cut -f2 -d'"')
80 ifeq (,$(KERNELRELEASE))
81 $(error Cannot detect kernel version - please check compiler and KERNELPATH)
82 endif
83 endif
84
85 # KERNELCONF is the name of the file that holds the configuration
86 # of the target kernel.
87 KERNELCONF ?=   $(KERNELPATH)/.config
88
89 # sanity check: does KERNELCONF exist?
90 ifeq ($(wildcard $(KERNELCONF)),)
91 $(error KERNELCONF: $(KERNELCONF) does not exist.)
92 endif
93 include $(KERNELCONF)
94
95 # Determine architecture of the kernel.
96 include $(TOP)/scripts/get_arch.mk
97 export ARCH
98
99 # Determine TARGET
100 include $(TOP)/ath_hal/ah_target.inc
101 export TARGET
102 COPTS += -DTARGET='"$(TARGET)"'
103
104 # KMODPATH nominates the directory where the modules will be
105 # installed to
106 KMODPATH :=     /lib/modules/$(KERNELRELEASE)/net
107
108 # Recognize 2.4.x kernels to support the old build system
109 ifeq ($(filter-out 2.4%,$(KERNELRELEASE)),)
110 LINUX24 = y
111 endif
112
113 ifndef LINUX24
114 KMODSUF         := ko
115 else
116 export-objs     = $(foreach m, $(obj-m), $($(m:.o=-objs)))
117 list-multi      = $(obj-m)
118 KMODSUF         := o
119 endif
120
121 NM=             nm
122
123 #
124 # Path to the HAL source code.
125 #
126 ifeq ($(HAL),)
127 HAL=    $(TOP)/hal
128 endif
129 #
130 # Path to HAL/OS interface code
131 #
132 ATH_HAL= $(TOP)/ath_hal
133 #
134 # Path to the 802.11 include files.
135 #
136 WLAN=   $(TOP)/net80211
137 #
138 # Path to the Atheros device driver.
139 #
140 ATH=    $(TOP)/ath
141 #
142 # Path to the rate control algorithms.
143 #
144 ATH_RATE=       $(TOP)/ath_rate
145 #
146 # Path to the userspace utilities. 
147
148 TOOLS=  $(TOP)/tools 
149
150 WARNINGS = -Werror -Wall
151 COPTS+= $(WARNINGS)
152 INCS=   -include $(TOP)/include/compat.h -I$(TOP)/include
153
154 # TARGET defines the target platform architecture. It must match one of
155 # the target platforms supported by the HAL. The default target is the
156 # host machine architecture. You can override TARGET on the make command
157 # line or in the environment. See hal/linux/*.inc for the list of
158 # supported targets.
159 ifeq (,$(wildcard $(HAL)/public/$(TARGET).inc))
160 TARGETS=$(basename $(notdir $(wildcard $(HAL)/public/*.inc)))
161 $(error TARGET $(TARGET) is invalid, valid targets are: $(TARGETS))
162 endif
163
164 ifndef ATH_DEBUG_SPINLOCKS
165 export ATH_DEBUG_SPINLOCKS=0
166 endif
167
168 ifndef IEEE80211_DEBUG_REFCNT
169 export IEEE80211_DEBUG_REFCNT=0
170 endif
171
172 ifndef HAL_DEBUG
173 export HAL_DEBUG=0
174 endif
175
176 ifndef ALQ
177 export ALQ=0
178 endif
179
180 ifndef ATH_DEBUG
181 export ATH_DEBUG=1
182 endif
183
184 ifndef MMIOTRACE
185 export MMIOTRACE=0
186 endif
187
188 ifeq ($(strip $(MMIOTRACE)),1)
189 EXTRA_CFLAGS += -DMMIOTRACE=1
190 endif
191
192 ifeq ($(strip $(ATH_DEBUG_SPINLOCKS)),1)
193 COPTS+= -DATH_DEBUG_SPINLOCKS=1
194 endif
195
196 ifeq ($(strip $(IEEE80211_DEBUG_REFCNT)),1)
197 COPTS+= -DIEEE80211_DEBUG_REFCNT=1
198 endif
199
200 # HAL_DEBUG enables HAL debugging code
201 # At the moment this consists of wrappers around HAL functions so that 
202 # stack traces are more decipherable.
203 ifeq ($(strip $(HAL_DEBUG)),1)
204 COPTS+= -fno-inline -DAH_DEBUG=1
205 endif
206
207 ifeq ($(strip $(ALQ)),1)
208 obj-m += alq.o
209 alq-objs := kern_alq.o
210 EXTRA_CFLAGS += -DAH_DEBUG_ALQ -DAH_DEBUG
211 endif
212
213 # Don't let HAL mess with the toolchain - save toolchain variables
214 save_CC := $(CC)
215 save_LD := $(LD)
216 save_STRIP := $(STRIP)
217 save_OBJCOPY := $(OBJCOPY)
218 save_NM := $(NM)
219
220 include $(HAL)/public/$(TARGET).inc
221
222 # Restore toolchain variables
223 CC := $(save_CC)
224 LD := $(save_LD)
225 STRIP := $(save_STRIP)
226 OBJCOPY := $(save_OBJCOPY)
227 NM := $(save_NM)
228
229 include $(TOP)/BuildCaps.inc
230
231 ifeq ($(strip $(ATH_DEBUG)),1)
232 EXTRA_CFLAGS += -DAR_DEBUG -DIEEE80211_DEBUG 
233 endif
234
235 ifeq ($(strip $(ATH_DEBUG_SPINLOCKS)),1)
236 EXTRA_CFLAGS += -DATH_DEBUG_SPINLOCKS
237 endif
238
239 ifeq ($(strip $(IEEE80211_DEBUG_REFCNT)),1)
240 EXTRA_CFLAGS += -DIEEE80211_DEBUG_REFCNT
241 endif
242
243 # Ensure correct endianess
244 LDFLAGS += $(LDOPTS)
245
246 # Filter out compiler options that are not supported by all compilers
247 # and that are not needed to ensure compatible architecture and calling
248 # conventions.
249 COPTS := $(filter-out -mshort-load-bytes -mapcs-32,$(COPTS))
250
251
252 # The following variables will affect developers only, and are used in the
253 # make-release.bash script.
254 #
255 # RELEASE_TMP is used as a temporary store for the files needed to create the
256 # release tarball. Packaging will take place in TMPDIR/madwifi-release.
257 # Defaults to /tmp.
258 RELEASE_TMP=/tmp
259
260 # RELEASE_STORE is the (local) directory where the release tarball should be
261 # stored in. Defaults to the parent directory of the working copy used to
262 # create the release.
263 RELEASE_STORE=..
264
265 # expose these settings to make-release.bash
266 export RELEASE_TMP RELEASE_STORE