1# 2# Broadcom Linux Router WPS Makefile 3# 4# Copyright (C) 2012, Broadcom Corporation 5# All Rights Reserved. 6# 7# This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation; 8# the contents of this file may not be disclosed to third parties, copied 9# or duplicated in any form, in whole or in part, without the prior 10# written permission of Broadcom Corporation. 11# 12# $Id: Makefile 372004 2012-11-30 03:46:58Z $ 13# 14 15REBUILD = $(shell if [ -f "prebuilt/wps_monitor" ]; then echo 0; else echo 1; fi) 16 17ifneq (true,$(parallel)) 18 .NOTPARALLEL: 19endif 20 21# Build type 22export BLDTYPE = release 23#export BLDTYPE = debug 24 25 26include $(TOP)/.config 27 28# linux kernel config 29include $(LINUXDIR)/.config 30 31export WPSSRC = $(SRCBASE)/wps 32 33# Get wireless driver support mode 34ifneq ($(CONFIG_WL_USE_STA)$(CONFIG_WL_USE_STA_ONCHIP_G)$(CONFIG_WL_USE_APSTA)$(CONFIG_WL_USE_APSTA_ONCHIP_G),) 35 ifneq ($(CONFIG_WL_USE_STA)$(CONFIG_WL_USE_STA_ONCHIP_G),) 36 export WL_MODE = sta 37 export WPS_CONF_FILE = wpsconfig_router_sta 38 WPS_LIB_FILE = wps_sta 39 else 40 export WL_MODE = apsta 41 export WPS_CONF_FILE = wpsconfig_router_apsta 42 WPS_LIB_FILE = wps_apsta 43 endif 44else 45 export WL_MODE = ap 46 export WPS_CONF_FILE = wpsconfig_router_ap 47 WPS_LIB_FILE = wps_ap 48endif 49 50# Include wps common make file 51include $(WPSSRC)/common/config/$(WPS_CONF_FILE) 52ifneq ($(CONFIG_WFI),y) 53WPS_WFI = 0 54endif 55ifneq ($(CONFIG_LIBUPNP),y) 56WPS_UPNP_DEVICE = 0 57endif 58ifeq ($(CONFIG_PLC),y) 59CFLAGS += -DWPS_PLC 60endif 61include $(WPSSRC)/common/config/wps.mk 62EXTRA_CFLAGS = $(WPS_FLAGS) 63 64# Generate list of supported variants 65VLIST = AP STA APSTA 66 67# Set suffix and config based on the selected variant 68WPS_SUFFIX := $(strip $(foreach v,$(VLIST),$(if $(CONFIG_WL_USE_$(v)),$(v)))) 69 70# Module file names use lowercase of the suffix 71wps_suffix := $(shell echo "$(WPS_SUFFIX)" | tr A-Z a-z) 72 73# Always do variants build 74wpssubdirs := $(addprefix wps_,$(shell echo "$(VLIST)" | tr A-Z a-z)) 75 76# 77# Set CFLAGS 78# 79CFLAGS += -DWPS_AP_M2D 80 81# Enable WWTP option cause the security hole described in WSC 2.0 specification section 4.3.1 82# But WPS 2 Test plan 4.1.13 still need this feature support. 83CFLAGS += -DWPS_ADDCLIENT_WWTP 84 85CFLAGS += -Wall -Wnested-externs -D_REENTRANT -D__linux__ 86#CFLAGS += -Werror 87 88ifeq ($(BLDTYPE), debug) 89CFLAGS += -g 90endif 91 92 93CFLAGS += -I$(SRCBASE)/include -I$(SRCBASE)/wps/common/include \ 94 -I$(SRCBASE)/router/libbcm -I$(SRCBASE)/router/eapd \ 95 -I$(SRCBASE)/router/shared -I$(SRCBASE)/wps/brcm_apps/include \ 96 -I$(SRCBASE)/include/bcmcrypto #${WLAN_ComponentIncPath} 97 98LDFLAGS += $(EXTRA_LDFLAGS) 99 100ifeq ($(RTCONFIG_HTTPS),y) 101CFLAGS += -I$(TOP)/openssl/include/openssl 102LDFLAGS += -L$(TOP)/openssl -lcrypto -lssl 103endif 104 105WPSM_LIBS = -lnvram -lbcm -lshared -lbcmcrypto -lm -lc 106# Set link libraries search path 107export LIBPATH = -L$(TOP)/libbcmcrypto -L$(INSTALLDIR)/libbcmcrypto/usr/lib 108export LIBPATH += -L$(TOP)/libbcm -L$(INSTALLDIR)/libbcm/usr/lib 109export LIBPATH += -L$(TOP)/shared -L$(INSTALLDIR)/shared/usr/lib 110export LIBPATH += -L$(TOP)/nvram -L$(INSTALLDIR)/nvram/usr/lib 111export LIBPATH += -L$(SRCBASE)/router/wps/lib 112export LIBPATH += -L$(SRCBASE)/router/wps/prebuilt 113ifeq ($(WPS_UPNP_DEVICE),1) 114# Always use LIBUPNP 115export LIBPATH += -L$(TOP)/libupnp -L$(INSTALLDIR)/libupnp/usr/lib 116WPSM_LIBS += -lupnp 117CFLAGS += -I$(SRCBASE)/router/libupnp/include -I$(SRCBASE)/wps/brcm_apps/upnp/WFADevice 118endif 119 120WPS_OSL := $(WPS_ROUTERHALFILES) 121WPS_OSL += src/wps/brcm_apps/linux/wps_linux_main.c 122 123WPS_OSL += src/wps/brcm_apps/linux/wps_linux_osl.c 124ifneq ($(WL_MODE), ap) 125WPS_OSL += src/wps/brcm_apps/linux/wps_enr_linux_osl.c 126endif 127 128WPS_OSLOBJS := $(foreach file, $(WPS_OSL), \ 129 $(patsubst src/%.c,obj/%.o,$(file))) 130 131WPS_DIRS := $(foreach file, $(WPS_OSLOBJS), \ 132 $(dir $(file))) 133 134WPS_DIRLIST = $(sort $(WPS_DIRS)) 135 136 137ifneq ($(wildcard ./prebuilt),) 138all: osl wps_monitor 139else 140all: mkversion sta_build_check dirs variants_build osl wps_monitor 141endif 142 143osl: 144 mkdir -p $(WPS_DIRLIST) 145 @echo "==>$(WPS_CONF_FILE)" 146 147ifneq ($(wildcard ./prebuilt),) 148objs: 149else 150objs: variants_build 151endif 152 +$(MAKE) parallel=true $(WPS_OSLOBJS) 153 154$(WPS_OSLOBJS) : obj%.o: $(addprefix $(SRCBASE)/../,src%.c) 155 $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $< 156 157# Variants build rules 158variants_build: $(patsubst %, _dir_%, $(wpssubdirs)) 159$(patsubst %, _dir_%, $(wpssubdirs)): 160 $(if $(wildcard $(patsubst _dir_%, %, $@)),+$(MAKE) -C $(patsubst _dir_%, %, $@)) 161 162# Set link libraries search path 163export LIBPATH += -L. -L./prebuilt 164 165 166sta_build_check: 167ifeq ($(WL_MODE),sta) 168ifeq ($(WPS_UPNP_DEVICE),1) 169 @echo "ERROR: UPNP_WFA_DEVICE is not supported on STA mode" 170 @exit 1 171endif 172endif 173 @true 174 175 176dirs : 177 mkdir -p lib 178 179mkversion : 180 $(SRCBASE)/router/wps/mkversion.sh $(WPSSRC)/common/include/version.h.in $(WPSSRC)/common/include/wps_version.h "$(PROD_TAG)" 181 182# target 183# force compile wps_monitor in case the library changed. 184ifeq ($(wildcard ./prebuilt),) 185wps_monitor : objs FORCE 186 $(CC) $(LIBPATH) $(WPS_OSLOBJS) $(WPSM_LIBS) -l$(WPS_LIB_FILE) $(LDFLAGS) -o $@ 187else 188wps_monitor : 189endif 190 191FORCE: 192 193 194clean: 195 find . \( -name '*.[od]' -o -name '*.tmp' \) -type f -print | xargs rm -f 196 find -name obj | xargs rm -rf 197 rm -rf lib 198 find -name wps_monitor | xargs rm -f 199 200# install 201install: all 202 install -d $(INSTALLDIR)/wps/bin 203ifeq ($(REBUILD),0) 204 install prebuilt/wps_monitor $(INSTALLDIR)/wps/bin 205else 206 install wps_monitor $(INSTALLDIR)/wps/bin 207endif 208 $(STRIP) $(INSTALLDIR)/wps/bin/wps_monitor 209 210.PHONY: all clean install libs dirs osl 211