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