4dadc3ef131d02570d91cbf43ff502a443098942
[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
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 # HAL_DEBUG enables HAL debugging code
165 # At the moment this consists of wrappers around HAL functions so that 
166 # stack traces are more decipherable.
167
168 ifdef HAL_DEBUG
169 COPTS+= -fno-inline
170 endif
171
172 # Don't let HAL mess with the toolchain - save toolchain variables
173 save_CC := $(CC)
174 save_LD := $(LD)
175 save_STRIP := $(STRIP)
176 save_OBJCOPY := $(OBJCOPY)
177 save_NM := $(NM)
178
179 include $(HAL)/public/$(TARGET).inc
180
181 # Restore toolchain variables
182 CC := $(save_CC)
183 LD := $(save_LD)
184 STRIP := $(save_STRIP)
185 OBJCOPY := $(save_OBJCOPY)
186 NM := $(save_NM)
187
188 include $(TOP)/BuildCaps.inc
189
190 # Ensure correct endianess
191 LDFLAGS += $(LDOPTS)
192
193 # Filter out compiler options that are not supported by all compilers
194 # and that are not needed to ensure compatible architecture and calling
195 # conventions.
196 COPTS := $(filter-out -mshort-load-bytes -mapcs-32,$(COPTS))
197
198
199 # The following variables will affect developers only, and are used in the
200 # make-release.bash script.
201 #
202 # RELEASE_TMP is used as a temporary store for the files needed to create the
203 # release tarball. Packaging will take place in TMPDIR/madwifi-release.
204 # Defaults to /tmp.
205 RELEASE_TMP=/tmp
206
207 # RELEASE_STORE is the (local) directory where the release tarball should be
208 # stored in. Defaults to the parent directory of the working copy used to
209 # create the release.
210 RELEASE_STORE=..
211
212 # expose these settings to make-release.bash
213 export RELEASE_TMP RELEASE_STORE