PageRenderTime 26ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/open-src/src/dhd/linux/Makefile

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