496cbbdb42e363a24d563c876b1343d6752266a2
[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 # KMODPATH nominates the directory where the modules will be
96 # installed to
97 KMODPATH :=     /lib/modules/$(KERNELRELEASE)/net
98
99 # Recognize 2.4.x kernels to support the old build system
100 ifeq ($(filter-out 2.4%,$(KERNELRELEASE)),)
101 LINUX24 = y
102 endif
103
104 ifndef LINUX24
105 KMODSUF         := ko
106 else
107 export-objs     = $(foreach m, $(obj-m), $($(m:.o=-objs)))
108 list-multi      = $(obj-m)
109 KMODSUF         := o
110 endif
111
112 NM=             nm
113
114 #
115 # Path to the HAL source code.
116 #
117 ifeq ($(HAL),)
118 HAL=    $(TOP)/ath_hal
119 endif
120 #
121 # Path to the 802.11 include files.
122 #
123 WLAN=   $(TOP)/net80211
124 #
125 # Path to the Atheros device driver.
126 #
127 ATH=    $(TOP)/ath
128 #
129 # Path to the rate control algorithms.
130 #
131 ATH_RATE=       $(TOP)/ath_rate
132 #
133 # Path to the userspace utilities. 
134
135 TOOLS=  $(TOP)/tools
136
137 WARNINGS = -Werror -Wall
138 COPTS+= $(WARNINGS)
139 INCS=   -include $(TOP)/include/compat.h -I$(TOP)/include
140
141 ifndef ATH_DEBUG_SPINLOCKS
142 export ATH_DEBUG_SPINLOCKS=0
143 endif
144
145 ifndef IEEE80211_DEBUG_REFCNT
146 export IEEE80211_DEBUG_REFCNT=0
147 endif
148
149 ifndef HAL_DEBUG
150 export HAL_DEBUG=0
151 endif
152
153 ifndef ATH_DEBUG
154 export ATH_DEBUG=1
155 endif
156
157 ifeq ($(strip $(ATH_DEBUG_SPINLOCKS)),1)
158 COPTS+= -DATH_DEBUG_SPINLOCKS=1
159 endif
160
161 ifeq ($(strip $(IEEE80211_DEBUG_REFCNT)),1)
162 COPTS+= -DIEEE80211_DEBUG_REFCNT=1
163 endif
164
165 # HAL_DEBUG enables HAL debugging code
166 # At the moment this consists of wrappers around HAL functions so that 
167 # stack traces are more decipherable.
168 ifeq ($(strip $(HAL_DEBUG)),1)
169 COPTS+= -fno-inline -DAH_DEBUG=1
170 endif
171
172 include $(TOP)/BuildCaps.inc
173
174 ifeq ($(strip $(ATH_DEBUG)),1)
175 EXTRA_CFLAGS += -DAR_DEBUG -DIEEE80211_DEBUG 
176 endif
177
178 ifeq ($(strip $(ATH_DEBUG_SPINLOCKS)),1)
179 EXTRA_CFLAGS += -DATH_DEBUG_SPINLOCKS
180 endif
181
182 ifeq ($(strip $(IEEE80211_DEBUG_REFCNT)),1)
183 EXTRA_CFLAGS += -DIEEE80211_DEBUG_REFCNT
184 endif
185
186 # Ensure correct endianess
187 LDFLAGS += $(LDOPTS)
188
189 # Filter out compiler options that are not supported by all compilers
190 # and that are not needed to ensure compatible architecture and calling
191 # conventions.
192 COPTS := $(filter-out -mshort-load-bytes -mapcs-32,$(COPTS))
193
194
195 # The following variables will affect developers only, and are used in the
196 # make-release.bash script.
197 #
198 # RELEASE_TMP is used as a temporary store for the files needed to create the
199 # release tarball. Packaging will take place in TMPDIR/madwifi-release.
200 # Defaults to /tmp.
201 RELEASE_TMP=/tmp
202
203 # RELEASE_STORE is the (local) directory where the release tarball should be
204 # stored in. Defaults to the parent directory of the working copy used to
205 # create the release.
206 RELEASE_STORE=..
207
208 # expose these settings to make-release.bash
209 export RELEASE_TMP RELEASE_STORE