1 2 # GNU Makefile for Broadcom Dongle Host Driver 3 # 4 # Copyright (C) 1999-2010, Broadcom Corporation 5 # 6 # Unless you and Broadcom execute a separate written software license 7 # agreement governing use of this software, this software is licensed to you 8 # under the terms of the GNU General Public License version 2 (the "GPL"), 9 # available at http://www.broadcom.com/licenses/GPLv2.php, with the 10 # following added to such license: 11 # 12 # As a special exception, the copyright holders of this software give you 13 # permission to link this software with independent modules, and to copy and 14 # distribute the resulting executable under terms of your choice, provided that 15 # you also meet, for each linked independent module, the terms and conditions of 16 # the license of that module. An independent module is a module which is not 17 # derived from this software. The special exception does not apply to any 18 # modifications of the software. 19 # 20 # Notwithstanding the above, under no circumstances may you combine this 21 # software in any way with any other Broadcom software provided under a license 22 # other than the GPL, without Broadcom's express prior written consent. 23 # 24 # $Id: Makefile,v 1.55.2.6.2.10.6.28 2010/03/26 21:49:31 Exp $ 25 # 26 27 # Try a couple of places for LINUXDIR if not specified 28 ifeq ($(LINUXDIR),) 29 ifeq ($(LINUXVER),) 30 # Neither one is specified, use uname for version 31 LINUXVER := $(shell uname -r) 32 endif 33 ifneq ($(wildcard /lib/modules/$(LINUXVER)/build/include/linux/version.h),) 34 LINUXDIR := /lib/modules/$(LINUXVER)/build 35 else 36 ifneq ($(wildcard /tools/linux/src/linux-$(LINUXVER)/include/linux/version.h),) 37 LINUXDIR := /tools/linux/src/linux-$(LINUXVER) 38 else 39 LINUXDIR := /usr/src/linux 40 endif 41 endif 42 endif 43 44 # Derive LINUXVER from LINUXDIR 45 MYKERNEL_RELEASE_KEYWORD:="KERNELRELEASE[[:space:]]*=.*kernel.release" 46 MYKERNEL_DEFINITION:=$(if \ 47 $(shell grep $(MYKERNEL_RELEASE_KEYWORD) $(LINUXDIR)/Makefile 2> /dev/null),\ 48 grep $(MYKERNEL_RELEASE_KEYWORD) $(LINUXDIR)/Makefile,\ 49 cat $(LINUXDIR)/Makefile) 50 51 LINUXVER:=$(shell ($(MYKERNEL_DEFINITION); echo "show_kernel_version_number$$$$:;@echo \$$(KERNELRELEASE)") 2> /dev/null | $(MAKE) --no-print-directory -k -C $(LINUXDIR) MYUNAME="" -f - show_kernel_version_number$$$$ 2> /dev/null) 52 53 ifeq ($(LINUXVER),) 54 $(error LINUXVER=$(LINUXVER) is empty) 55 endif # LINUXVER 56 57 $(warning Found LINUXVER=$(LINUXVER)) 58 $(warning Found LINUXDIR=$(LINUXDIR)) 59 60 # check if 2.4 kernel or 2.5+ kernel 61 BCM_KVER:=$(shell echo $(LINUXVER) | cut -c1-3 | sed 's/2\.[56]/2\.6/') 62 63 # Allow CROSS_COMPILE to specify compiler base 64 CC := $(CROSS_COMPILE)gcc 65 LD := $(CROSS_COMPILE)ld 66 NM := $(CROSS_COMPILE)nm 67 OBJCOPY := $(CROSS_COMPILE)objcopy 68 69 # driver source base and C file path 70 ifeq ($(SRCBASE),) 71 SRCBASE := $(shell /bin/pwd)/../.. 72 endif 73 vpath %.c $(SRCBASE)/dhd/sys $(SRCBASE)/shared $(SRCBASE)/bcmsdio/sys $(SRCBASE)/wl/sys $(SRCBASE)/crypto 74 75 ## Initialize DFLAGS 76 DFLAGS := 77 78 79 # basic options (defines in DFLAGS, includes in IFLAGS) 80 DFLAGS += -DLINUX -DSRCBASE=\"$(SRCBASE)\" -DBCMDRIVER -DBCMDONGLEHOST -DDHDTHREAD -DBCMWPA2 -DBCMWAPI_WPI 81 DFLAGS += -DUNRELEASEDCHIP 82 ifeq ($(BCMQT),1) 83 DFLAGS += -DBCMSLTGT -DBCMQT 84 endif 85 ifeq ($(WLTEST),1) 86 DFLAGS += -DWLTEST -DIOCTL_RESP_TIMEOUT=20000 87 DFLAGS += -DDHD_SPROM 88 endif 89 90 91 # Past 2.6.29 kernels, arch specific bits are re-organized in linux kernel. So 92 # append new include paths to existing ones to get 2.6.29+ kernels compile 93 94 # Default DHDARCH is x86 95 ifdef ARCH 96 DHDARCH ?= $(ARCH) 97 else 98 DHDARCH ?= x86 99 endif 100 101 ifneq ($(findstring native,$(TARGET)),) 102 DHDARCH = x86 103 endif 104 ifneq ($(findstring mips,$(TARGET)),) 105 DHDARCH = mips 106 endif 107 ifneq ($(findstring arm,$(TARGET)),) 108 DHDARCH = arm 109 endif 110 111 # First include from linux kernel dirs 112 IFLAGS := -I$(LINUXDIR)/include 113 IFLAGS += -I$(LINUXDIR)/include/asm/mach-default 114 # Followed by 2.6.29+ specific paths 115 IFLAGS += -I$(LINUXDIR)/arch/$(DHDARCH)/include 116 IFLAGS += -I$(LINUXDIR)/arch/$(DHDARCH)/include/asm/mach-default 117 118 # From current workspace 119 IFLAGS += -I. 120 IFLAGS += -I$(SRCBASE)/include 121 IFLAGS += -I$(SRCBASE)/shared 122 IFLAGS += -I$(SRCBASE)/dhd/sys 123 IFLAGS += -I$(SRCBASE)/dongle 124 IFLAGS += -I$(SRCBASE)/wl/sys 125 126 ifneq ($(wildcard $(LINUXDIR)/.config),) 127 include $(LINUXDIR)/.config 128 else 129 # This is dangerous, since we don't know if they are really configured. 130 CONFIG_WIRELESS_EXT=y 131 DFLAGS += -DCONFIG_WIRELESS_EXT 132 endif 133 134 ifeq ($(CONFIG_MMC_MSM7X00A),y) 135 DFLAGS += -Dlinux 136 DFLAGS += -DDHD_SDALIGN=64 -DMAX_HDR_READ=64 -DDHD_FIRSTREAD=64 137 endif 138 139 WFLAGS := -Wall -Wstrict-prototypes 140 ifeq (,$(findstring 2.4.18,$(LINUXVER))) 141 WFLAGS += -Werror 142 endif 143 144 CFILES:= dhd_linux.c linux_osl.c bcmutils.c dhd_common.c dhd_custom_gpio.c 145 CFILES += siutils.c sbutils.c aiutils.c hndpmu.c 146 147 # threading options 148 ifneq ($(findstring -nothread-,-$(TARGET)-),) 149 DFLAGS += -UDHDTHREAD 150 endif 151 152 # Building gpl provides thread prioritization 153 ifneq ($(findstring -gpl-,-$(TARGET)-),) 154 CFILES += dhd_linux_sched.c 155 DFLAGS += -DDHD_GPL -DDHD_SCHED 156 endif 157 158 ifeq ($(WLTEST),1) 159 CFILES += bcmsrom.c bcmotp.c 160 endif 161 162 ifeq ($(CONFIG_NET_RADIO),y) 163 CFILES += bcmwifi.c 164 ifeq ($(findstring -cfg-,-$(TARGET)-),) 165 CFILES += wl_iw.c 166 endif 167 else 168 ifeq ($(CONFIG_WIRELESS_EXT),y) 169 CFILES += bcmwifi.c 170 ifeq ($(findstring -cfg-,-$(TARGET)-),) 171 CFILES += wl_iw.c 172 endif 173 endif 174 endif 175 176 OFILES=$(CFILES:.c=.o) 177 178 # Make debug a separate option 179 ifneq ($(findstring -debug-,-$(TARGET)-),) 180 DFLAGS += -DDHD_DEBUG -DSDTEST 181 endif 182 183 # Make big-endian a separate option 184 ifneq ($(findstring -be-,-$(TARGET)-),) 185 DFLAGS += -DIL_BIGENDIAN 186 endif 187 188 ifneq ($(findstring -dnglimage-,-$(TARGET)-),) 189 ## Embeddable dongle image name 190 DNGL_IMAGE_NAME ?= 4325b0/sdio-g-cdc-reclaim-idsup-wme 191 DFLAGS += -DBCMEMBEDIMAGE -DIMAGE_NAME="$(DNGL_IMAGE_NAME)" 192 IFLAGS += -I$(SRCBASE)/dongle/rte/wl/builds/$(DNGL_IMAGE_NAME) 193 endif 194 195 ifneq ($(findstring -cdc-,-$(TARGET)-),) 196 DFLAGS += -DBDC -DTOE 197 DFLAGS += -DDHD_BCMEVENTS -DSHOW_EVENTS 198 CFILES += dhd_cdc.c 199 ifneq ($(findstring -apsta-,-$(TARGET)-),) 200 DFLAGS += -DAP -DAPSTA_PINGTEST 201 endif 202 endif 203 ifneq ($(findstring -rndis-,-$(TARGET)-),) 204 DFLAGS += -DRNDIS 205 CFILES += dhd_rndis.c 206 endif 207 208 ifneq ($(findstring -usb-,-$(TARGET)-),) 209 DFLAGS += -DBCMDHDUSB 210 CFILES += dhd_usb_linux.c 211 endif 212 ifneq ($(findstring -sdio-,-$(TARGET)-),) 213 DFLAGS += -DBCMSDIO 214 CFILES += dhd_sdio.c 215 endif 216 ifneq ($(findstring -sdstd-,$(TARGET)-),) 217 DFLAGS += -DBCMSDIO -DBCMSDIOH_STD 218 CFILES += dhd_sdio.c bcmsdh.c bcmsdstd.c bcmsdstd_linux.c bcmsdh_linux.c 219 endif 220 ifneq ($(findstring -softap-,-$(TARGET)-),) 221 DFLAGS += -DSOFTAP 222 CFILES += sha1.c md5.c 223 endif 224 ifneq ($(findstring -cfg-,-$(TARGET)-),) 225 DFLAGS += -DWL_CFG80211 226 CFILES += wl_cfg80211.c 227 endif 228 ifneq ($(findstring -oob-,-$(TARGET)-),) 229 DFLAGS += -DOOB_INTR_ONLY 230 DFLAGS += -DHW_OOB 231 DFLAGS += -DMMC_SDIO_ABORT 232 else 233 ifneq ($(findstring -sdmmc-,-$(TARGET)-),) 234 DFLAGS += -DSDIO_ISR_THREAD 235 endif 236 endif 237 ifneq ($(findstring -sdmmc-,-$(TARGET)-),) 238 DFLAGS += -DBCMSDIO -DDHD_GPL -DBCMLXSDMMC -DBCMPLATFORM_BUS 239 CFILES += dhd_sdio.c bcmsdh_sdmmc.c bcmsdh.c bcmsdh_linux.c bcmsdh_sdmmc_linux.c 240 endif 241 ifneq ($(findstring -sdspi-,$(TARGET)-),) 242 DFLAGS += -DBCMSDIO -DBCMSDIOH_SPI -DTESTDONGLE # -DBCMSDYIELD 243 CFILES += dhd_sdio.c bcmsdh.c bcmsdspi.c bcmsdspi_linux.c bcmsdh_linux.c 244 endif 245 ifneq ($(findstring -pci,$(TARGET)-),) 246 CFILES += bcmpcispi.c 247 endif 248 ifneq ($(findstring -sdext-,$(TARGET)-),) 249 DFLAGS += -DBCMSDIO -DTESTDONGLE 250 CFILES += dhd_sdio.c 251 endif 252 ifneq ($(findstring -intc1,$(shell echo $(LINUXVER))),) 253 DFLAGS += -DSANDGATE2G 254 endif 255 256 CFLAGS += -fshort-wchar $(DFLAGS) $(WFLAGS) $(IFLAGS) $(CUSTOM_FLAGS) 257 258 259 260 LDFLAGS := -r 261 MODULES := dhd.o 262 ifeq ($(BCM_KVER), 2.6) 263 ##Kernel module names in 2.6 kernel have .ko suffix 264 KMODULES:=dhd.ko 265 ifneq ($(findstring -nexus-,$(TARGET)-),) 266 KMODULES:=bcm4329.ko 267 endif 268 else 269 KMODULES:=$(MODULES) 270 endif 271 272 273 # host options 274 HOSTCC := $(CC) 275 ifneq ($(BCM_KVER), 2.6) 276 HOSTCFLAGS := $(CFLAGS) $(shell $(MAKE) --no-print-directory -s -C $(LINUXDIR) script 'SCRIPT=@echo $$(CFLAGS) $$(MODFLAGS)') 277 else 278 HOSTCFLAGS := $(CFLAGS) -D__KERNEL__ 279 DHDCFLAGS = $(HOSTCFLAGS) -I$(shell pwd) 280 export DHDCFLAGS 281 DHDOFILES = $(OFILES) 282 export DHDOFILES 283 endif 284 285 TARGETS := \ 286 dhd-cdc-usb dhd-cdc-sdstd \ 287 dhd-cdc-sdspi-pci dhd-cdc-sdmmc-gpl dhd-cdc-sdmmc-oob-gpl \ 288 dhd-cdc-usb-apsta dhd-cdc-usb-gpl \ 289 dhd-cdc-sdstd-apsta \ 290 dhd-cdc-sdmmc-softap-gpl \ 291 dhd-cdc-sdmmc-cfg-gpl 292 293 294 TARGETS += \ 295 dhd-cdc-sdio-dnglimage dhd-cdc-sdspi-pci-dnglimage \ 296 dhd-cdc-gspi-pci 297 #ifdef RNDIS 298 TARGETS += dhd-rndis-usb 299 #endif 300 TARGETS += dhd-cdc-sdext-be 301 TARGETS += dhd-cdc-sdext-be-dnglimage 302 ifneq ($(findstring -intc1,$(shell echo $(LINUXVER))),) 303 TARGETS += dhd-cdc-sdio dhd-cdc-sdiofd # dhd-cdc-sdmmc 304 endif 305 TARGETS += $(foreach tgt, $(TARGETS), $(tgt)-debug) 306 307 OBJDIR=$(TARGET)-$(LINUXVER)$(if $(BCMQT),-bcmqt) 308 309 all: $(filter %-sdio %-sdbcm %-sdstd %-usb %sdspi-pci %-sdiofd %-sdmmc, $(TARGETS)) 310 sdio: $(filter %-sdio %-sdbcm %-sdstd, $(TARGETS)) 311 usb: $(filter %-usb, $(TARGETS)) 312 sdspi: $(filter %-sdspi-pci %-sdspi-cheetah, %-sdspi-u2c $(TARGETS)) 313 314 # Allow making target with the LINUXVER suffix already on it. 315 # (Typical of command line tab completion; trailing slash still not allowed) 316 %-$(LINUXVER): force 317 $(MAKE) $(@:%-$(LINUXVER)=%) 318 319 $(TARGETS): 320 @echo "MAKING $@" 321 $(MAKE) TARGET=$@ objdir 322 323 # Show compiler version, for the current target build 324 showenv: 325 @echo "CC = $(CC) (ver=`$(CC) -dumpversion`; host=`hostname`; processor=`uname -m`)" 326 327 objdir: showenv 328 @echo "Making objdir $(OBJDIR)" 329 @echo "TARGET is $(TARGET)" 330 mkdir -p $(OBJDIR) 331 ifneq ($(BCM_KVER), 2.6) 332 $(MAKE) -C $(OBJDIR) -f $(SRCBASE)/dhd/linux/Makefile SRCBASE=$(SRCBASE) dep 333 endif 334 $(MAKE) -C $(OBJDIR) -f $(SRCBASE)/dhd/linux/Makefile SRCBASE=$(SRCBASE) modules 335 ifeq ($(BCM_KVER), 2.6) 336 $(OBJCOPY) --strip-unneeded $(OBJDIR)/$(KMODULES) $(OBJDIR)/$(KMODULES).stripped 337 else 338 $(OBJCOPY) --strip-unneeded $(OBJDIR)/$(MODULES) $(OBJDIR)/$(MODULES).stripped 339 endif 340 341 dep: $(foreach file,$(CFILES),.$(file).depend) 342 .%.c.depend: %.c 343 $(HOSTCC) $(HOSTCFLAGS) -M $< > $@ || (rm -f $@; exit 1) 344 .%.c.depend:: 345 touch $@ 346 347 ifeq ($(BCM_KVER), 2.6) 348 modules: $(OFILES) 349 test -r ./Makefile || ln -s $(SRCBASE)/dhd/linux/makefile.26 ./Makefile 350 $(MAKE) -C $(LINUXDIR) M=$(shell pwd) $(if $(VERBOSE),V=1) modules 351 else 352 modules: $(MODULES) 353 endif 354 355 $(MODULES): $(OFILES) 356 $(LD) $(LDFLAGS) -o $@ $^ 357 358 ifeq ($(BCM_KVER), 2.6) 359 %.o: %.c 360 # when make is called from 2.6, vpath doesn't work so we need to link the files. 361 test -r ./$< || ln -s $< . 362 else 363 %.o: %.c 364 $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $< 365 @( \ 366 echo 'ifneq ($$(HOSTCFLAGS),$(HOSTCFLAGS))' ; \ 367 echo '$@: force' ; \ 368 echo 'endif' ; \ 369 ) > .$*.c.flags 370 endif 371 372 force: 373 374 clean: 375 rm -rf dhd-* 376 377 ifneq ($(wildcard .*.depend),) 378 include $(wildcard .*.depend) 379 endif 380 ifneq ($(wildcard .*.flags),) 381 include $(wildcard .*.flags) 382 endif 383