1#
2# Generic portion of the Broadcom wl driver makefile
3#
4# input: O_TARGET, CONFIG_WL_CONF and wl_suffix
5# output: obj-m, obj-y
6#
7# $Id: wl_generic.mk,v 1.10 2011-01-21 22:12:09 $
8#
9
10REBUILD_WL_MODULE=$(shell if [ -d "$(src)/$(SRCBASE)/wl/sys" -a "$(REUSE_PREBUILT_WL)" != "1" ]; then echo 1; else echo 0; fi)
11
12# If source directory (src/wl/sys) exists and REUSE_PREBUILT_WL is undefined, 
13# then build inside $(SRCBASE)/wl/sys, otherwise use pre-builts
14ifeq ($(REBUILD_WL_MODULE),1)
15
16    # Get the source files and flags from the specified config file
17    # (Remove config's string quotes before trying to use the file)
18    ifeq ($(CONFIG_WL_CONF),)
19         $(error var_vlist($(VLIST)) var_config_wl_use($(shell env|grep CONFIG_WL_USE)))
20         $(error CONFIG_WL_CONF is undefined)
21    endif
22    
23    WLCONFFILE := $(strip $(subst ",,$(CONFIG_WL_CONF))) 
24    WLCFGDIR   := $(src)/$(SRCBASE)/wl/config
25    
26    # define OS flag to pick up wl osl file from wl.mk
27    WLLX=1
28    ifdef CONFIG_PLC
29        PLC=1
30    endif
31    ifdef CONFIG_DPSTA
32        DPSTA=1
33    endif
34    include $(WLCFGDIR)/$(WLCONFFILE)
35    include $(WLCFGDIR)/wl.mk
36
37    ifeq ($(WLCLMAPI),1)
38        WLAN_ComponentsInUse := bcmwifi clm ppr olpc
39        include $(src)/$(SRCBASE)/makefiles/WLAN_Common.mk
40    endif
41    
42    ifeq ($(WLFILES_SRC),)
43         $(error WLFILES_SRC is undefined in $(WLCFGDIR)/$(WLCONFFILE))
44    endif
45    
46    ifeq ($(WLCLMAPI),1)
47    CLM_TYPE ?= router
48    $(call WLAN_GenClmCompilerRule,$(src)/$(SRCBASE)/wl/clm/src,$(src)/$(SRCBASE))
49    endif
50    
51    # need -I. to pick up wlconf.h in build directory
52   
53    ifeq ($(CONFIG_WL_ALL_PASSIVE_ON),y)
54    EXTRA_CFLAGS    += -DWL_ALL_PASSIVE_ON -DWL_ALL_PASSIVE
55    else
56    ifeq ($(CONFIG_WL_ALL_PASSIVE_RUNTIME),y)
57    EXTRA_CFLAGS    += -DWL_ALL_PASSIVE
58    endif
59    endif
60    EXTRA_CFLAGS += -DDMA $(WLFLAGS) -I$(src) -I$(src)/.. -I$(src)/$(SRCBASE)/wl/linux \
61		    -I$(src)/$(SRCBASE)/wl/sys $(WLAN_ComponentIncPath) -Werror
62
63    ifneq ("$(CONFIG_CC_OPTIMIZE_FOR_SIZE)","y")
64         EXTRA_CFLAGS += -finline-limit=2048
65    endif
66    
67    # include path for dpsta.h
68    EXTRA_CFLAGS += -I$(src)/$(SRCBASE)/router/dpsta
69
70    # Build the phy source files iff -DPHY_HAL is present.
71    ifneq ($(findstring PHY_HAL,$(WLFLAGS)),)
72        EXTRA_CFLAGS += -I$(src)/$(SRCBASE)/wl/phy
73    else
74	WLFILES_SRC := $(filter-out src/wl/phy/%,$(WLFILES_SRC))
75    endif
76
77    # The paths in WLFILES_SRC need a bit of adjustment.
78    WL_OBJS := $(sort $(patsubst %.c,%.o,$(addprefix $(SRCBASE)/,$(patsubst src/%,%,$(WLFILES_SRC)))))
79
80    # wl-objs is for linking to wl.o
81    $(TARGET)-objs := $(WLCONF_O) $(WL_OBJS)
82    obj-$(CONFIG_WL) := $(TARGET).o
83
84else # SRCBASE/wl/sys doesn't exist
85
86    # Otherwise, assume prebuilt object module(s) in src/wl/linux directory
87    prebuilt := wl_$(wl_suffix).o
88    $(TARGET)-objs := $(SRCBASE)/wl/linux/$(prebuilt)
89    obj-$(CONFIG_WL) := $(TARGET).o
90
91    ifeq ("$(CONFIG_WL_USBAP)","y")
92        wl_high-objs := $(SRCBASE)/wl/linux/wl_high.o
93        obj-m += wl_high.o
94    endif
95endif
96
97
98clean-files += $(SRCBASE)/wl/sys/*.o $(SRCBASE)/wl/phy/*.o $(SRCBASE)/wl/ppr/src/*.o $(SRCBASE)/wl/plqmr/src/*.o $(SRCBASE)/wl/sys/.*.*.cmd $(SRCBASE)/wl/phy/.*.*.cmd $(WLCONF_H) $(WLCONF_O)
99