blob: 5fa648881b4b1483ec6226e0e990bf8fbb2a6009 [file] [log] [blame]
###############################################################################
#
# <:copyright-BRCM:2016:proprietary:standard
#
# Broadcom Ltd. Proprietary and Confidential.(c) 2016 Broadcom Ltd.
# All Rights Reserved
#
# This program is the proprietary software of Broadcom Ltd. and/or its
# licensors, and may only be used, duplicated, modified or distributed pursuant
# to the terms and conditions of a separate, written license agreement executed
# between you and Broadcom Ltd. (an "Authorized License"). Except as set forth in
# an Authorized License, Broadcom Ltd. grants no license (express or implied), right
# to use, or waiver of any kind with respect to the Software, and Broadcom Ltd.
# expressly reserves all rights in and to the Software and all intellectual
# property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE
# NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY
# BROADCOM LTD AND DISCONTINUE ALL USE OF THE SOFTWARE.
#
# Except as expressly set forth in the Authorized License,
#
# 1. This program, including its structure, sequence and organization,
# constitutes the valuable trade secrets of Broadcom Ltd., and you shall use
# all reasonable efforts to protect the confidentiality thereof, and to
# use this information only in connection with your use of Broadcom Ltd.
# integrated circuit products.
#
# 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
# AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
# WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
# RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND
# ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT,
# FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
# COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE
# TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF USE OR
# PERFORMANCE OF THE SOFTWARE.
#
# 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
# ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL,
# INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY
# WAY RELATING TO YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN
# IF BROADCOM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES;
# OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
# SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE LIMITATIONS
# SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF ANY
# LIMITED REMEDY.
# :>
#
###############################################################################
# Central Makefile
#
# Identify whether it is customer or development build
ifneq ("$(wildcard .release_build)","")
RELEASE_BUILD=y
export RELEASE_BUILD
endif
DOCS_SUBSYSTEM := core
ifeq ("$(BUILD_OF_AGENT)", "y")
ifneq ("$(findstring core,$(MAKECMDGOALS))", "")
$(error Setting BUILD_OF_AGENT=$(BUILD_OF_AGENT) in incompatible with one of make targets "$(MAKECMDGOALS)"")
endif
# Backward compatibility
ifeq ("$(MAKECMDGOALS)", "clean")
OVEERIDE_GOAL = clean_agent
endif
ifeq ("$(MAKECMDGOALS)", "")
OVEERIDE_GOAL = sdn_agent
endif
DOCS_SUBSYSTEM := agent
endif
ifeq ("$(BUILD_OF_AGENT)", "n")
ifneq ("$(findstring agent,$(MAKECMDGOALS))", "")
$(error Setting BUILD_OF_AGENT=$(BUILD_OF_AGENT) in incompatible with one of make targets "$(MAKECMDGOALS)"")
endif
# Backward compatibility
ifeq ("$(MAKECMDGOALS)", "clean")
OVEERIDE_GOAL = clean_core
endif
ifeq ("$(MAKECMDGOALS)", "")
OVEERIDE_GOAL = core
endif
endif
ifneq ("$(findstring agent,$(MAKECMDGOALS))", "")
BUILD_OF_AGENT = y
endif
BUILD_NC_AGENT ?= y
export BUILD_OF_AGENT
export BUILD_NC_AGENT
PLATFORM ?= maple
TOP_DIR=$(shell pwd)
export PLATFORM
export TOP_DIR
MAKE_DIR=$(TOP_DIR)/mk
MAKE_DEVICE_DIR=$(MAKE_DIR)/$(DEVICE)
export MAKE_DIR
export MAKE_DEVICE_DIR
TOP_SRC_DIR=$(TOP_DIR)/src
export TOP_SRC_DIR
include $(MAKE_DIR)/Makefile.initial_config
include $(TOP_DIR)/branch.info
OUT_DIR ?= $(TOP_DIR)/build
OUT_DOCS_DIR ?= $(OUT_DIR)/doc
export OUT_DIR
export OUT_DOCS_DIR
# List of all modules, all library modules and all application modules
export ALL_MODULES
export ALL_LIB_MODULES
export ALL_APP_MODULES
# Current board
export BOARD
ifneq ("$(BOARD)", "")
BOARD_DIR ?= $(TOP_DIR)/3rdparty/maple/boards/cur/$(BOARD)
export BOARD_DIR
endif
# Location of Maple SDK dir
MAPLE_SDK_DIR ?= $(TOP_DIR)/3rdparty/maple/cur
LOCAL_MAPLE_SDK_DIR = 3rdparty/maple/sdk
export MAPLE_SDK_DIR
export LOCAL_MAPLE_SDK_DIR
MAPLE_BOARD ?= $(BOARD)
ifneq ("$(MAPLE_BOARD)", "")
MAPLE_BOARD_DIR ?= $(MAPLE_SDK_DIR)/../boards/cur/$(MAPLE_BOARD)
else
MAPLE_BOARD_DIR = $(shell cat $(TOP_DIR)/$(LOCAL_MAPLE_SDK_DIR)/build/.maple_board_dir 2> /dev/null)
tmp = $(shell ; rm -f $(OUT_DIR)/.maple_board_dir)
endif
ING_SDK_VER ?= 6.5.7
ING_SDK ?= sdk-all-$(ING_SDK_VER)
ING_SDK_PATCH ?=sdk-bal-$(ING_SDK_VER).patch
ING_SDK_TOP_DIR ?= $(TOP_DIR)/3rdparty/bcm-sdk
ifeq ("$(BOARD)", "")
ING_SDK_DEFAULT_DIR := $(ING_SDK_TOP_DIR)/build/$(ING_SDK)
else
ING_SDK_DEFAULT_DIR := $(ING_SDK_TOP_DIR)/build-$(BOARD)/$(ING_SDK)
endif
ING_SDK_DIR ?= $(ING_SDK_DEFAULT_DIR)
export ING_SDK_VER
export ING_SDK
export ING_SDK_PATCH
export ING_SDK_TOP_DIR
export ING_SDK_DIR
SWITCH ?= qax
export SWITCH
TMP_BAL_VERSION_H=${MAKE_DIR}/bal_version.tmp
BAL_VERSION_H:=${TOP_DIR}/src/common/include/bal_version.h
# NOTE: BUILD_INFO is set and exported by Jenkins when built by that tool
export JENKINS_BUILD
ifeq ("$(JENKINS_BUILD)", "y")
PERFORCE_REVISION:=$(P4_CHANGELIST)
else ifneq ("$(RELEASE_BUILD), "y")
PERFORCE_REVISION:=$(shell p4 changes -m 1 //$(DEPOT)/$(BRANCH)/...\#have | cut -d " " -f 2)
BUILD_INFO="Developer build \("${USER}"@"${PWD}"\)"
export BUILD_INFO
else
BUILD_INFO="Customer Release Build \("${USER}"@"${PWD}"\)"
export BUILD_INFO
endif
RELEASE_TYPE:=${RELEASE_TYPE}
BUILD_USER:=${USER}
BUILD_TOPDIR:=${TOP_DIR}
BUILD_PERFORCE_REVISION:=$(PERFORCE_REVISION)
BUILD_VERSION_PREFIX:=$(RELEASE_TYPE)$(MAJOR).$(MINOR).$(PATCH)
BUILD_VERSION:=$(BUILD_VERSION_PREFIX).${BUILD_PERFORCE_REVISION}
BUILD_DATE:=`date +%m-%d-%Y-%H%M%S`
export BUILD_VERSION
export BUILD_PERFORCE_REVISION
export SRC_RELEASE_FILE_PREFIX ?= release.src.$(BUILD_VERSION_PREFIX)
export INCLUDE_MAPLE_SDK_RELEASE ?= y
V ?= 0
ifeq (x"$(V)", x"0")
SILENT = -s
export SILENT
SILENT_BUILD=@
endif
# Include board support file
# It exports variables such as CROSS_COMPILE
ifneq ("$(BOARD)", "")
-include mk/boards/$(BOARD)/board.config
endif
ifneq ("$(OVEERIDE_GOAL)", "")
all: $(OVEERIDE_GOAL)
else
all: print_maple_dir core sdn_agent
endif
clean: clean_core clean_agent clean_ocs_omci
$(SILENT_BUILD)rm -fr $(OUT_DIR)
help_general:
@echo "make parameters:"
@echo " BOARD - board to build for"
@echo " BOARD_DIR - board directory"
@echo " V=<output_level> - =1-verbose command output, =2-makefile debug output"
@echo " EXTRA_TYPES - Low-level option. Space-delimited list of extra types without bcmolt_ prefix"
@echo " ENABLE_CLI - =n-exclude CLI support. Included by default"
@echo "make targets:"
@echo " all - build all subsystems. This is the default target"
@echo " core - build core subsystem (BAL standalone)"
@echo " sdn_agent - build agent subsystem (BAL SDN agent)"
@echo " maple_sdk_dir - create 3rdparty/maple/sdk"
@echo " maple_sdk - build maple sdk. Please set BOARD=<board> parameter"
@echo " maple_sdk_clean - clean maple sdk"
@echo " ing_sdk_dir - create 3rdparty/bcm-sdk/build"
@echo " ing_sdk - build 3rdparty/bcm-sdk/build"
@echo " ing_sdk_clean - clean 3rdparty/bcm-sdk/build"
@echo " ing_bcm_user - build the bcm_user binary (toolchains paths must be set correctly first)"
@echo " clean - clean everything"
@echo " clean_core - clean core subsystem"
@echo " clean_sdn_agent - clean SDN agent"
@echo " clean_ocs_omci - clean OCS OMCI stack"
@echo " clean_bcm_omci - clean Broadcom OMCI stack"
@echo " docs - generate reference document in html format"
@echo " docs_pdf - generate reference document in pdf format"
@echo " docs_clean - clean documents"
@echo " version_file - builds BAL version file"
@echo " bin_release_core - create BAL core binary release archive"
@echo " bin_release_sdn_agent - create BAL SDN agent binary release archive"
@echo " bin_release - create BAL core and SDN agent binary release archives"
@echo " src_release - create all BAL source release archives"
@echo ""
@echo "Optional make arguments:"
@echo ""
@echo " BUILD_NC_AGENT=n - do NOT build NETCONF agent into bcm_sdn_agent. Used with make target \"sdn_agent\""
@echo " TEST_SW_UTIL_LOOPBACK=y - stub out the switch utils"
@echo ""
help: help_general help_core
.PHONY: version_file
version_file:
@echo " Generating $@"
@echo "/*************************************************************" > $(TMP_BAL_VERSION_H)
@echo " * DO NOT EDIT! THIS FILE WAS AUTO GENERATED. DO NOT EDIT! *" >> $(TMP_BAL_VERSION_H)
@echo " *************************************************************/" >> $(TMP_BAL_VERSION_H)
@echo " wrote header..."
@$(BUILD_TOPDIR)/tools/copyright_tools/insert_copyright.pl -t c -l $(BUILD_TOPDIR)/COPYRIGHT >> $(TMP_BAL_VERSION_H)
@echo "#if !defined(BAL_VERSION_H)" >> $(TMP_BAL_VERSION_H)
@echo "#define BAL_VERSION_H" >> $(TMP_BAL_VERSION_H)
@echo "" >> $(TMP_BAL_VERSION_H)
@echo "#define BAL_VERSION \"${BUILD_VERSION}\"" >> $(TMP_BAL_VERSION_H)
@echo "#define BAL_VERSION_STR_LEN (`echo ${BUILD_VERSION} | wc -c`)" >> $(TMP_BAL_VERSION_H)
@echo "" >> $(TMP_BAL_VERSION_H)
@echo "#define BAL_BUILD_DATE \"`date`\"" >> $(TMP_BAL_VERSION_H)
@echo "#define BAL_BUILD_INFO \"${BUILD_INFO}\"" >> $(TMP_BAL_VERSION_H)
@echo "" >> $(TMP_BAL_VERSION_H)
@echo "#endif /* BAL_VERSION_H */" >> $(TMP_BAL_VERSION_H)
@diff $(TMP_BAL_VERSION_H) $(BAL_VERSION_H) > /dev/null; \
if [ $$? -ne 0 ]; then \
mv -f $(TMP_BAL_VERSION_H) $(BAL_VERSION_H); \
fi
.PHONY: overlay_bal_maple_scripts
overlay_bal_maple_scripts:
@echo "Creating and Overlaying BAL-specific svk_init.sh and trx_init.sh onto maple fs"
@echo "(in $(LOCAL_MAPLE_SDK_DIR)/build/fs/)"
@cp -f $(LOCAL_MAPLE_SDK_DIR)/host_customized/board/wrx/fs/svk_init.sh ~/svk_init.sh
@cat ~/svk_init.sh | sed s/".\/bcm_user_appl"/'.\/bcm_user_appl < trx_init.sh \&\& .\/bcm_user_appl'/g > ~/svk_init_for_bal.sh
@cat ~/svk_init.sh | sed s/".\/bcm_user_appl"/'.\/bcm_user_appl < trx_init.sh'/g > ~/svk_init_for_bal_startup.sh
@mkdir -p $(LOCAL_MAPLE_SDK_DIR)/build/fs/
@mv -f ~/svk_init_for_bal.sh $(LOCAL_MAPLE_SDK_DIR)/build/fs/svk_init.sh
@mv -f ~/svk_init_for_bal_startup.sh $(LOCAL_MAPLE_SDK_DIR)/build/fs/svk_init_startup.sh
@chmod 755 $(LOCAL_MAPLE_SDK_DIR)/build/fs/svk_init.sh
@chmod 755 $(LOCAL_MAPLE_SDK_DIR)/build/fs/svk_init_startup.sh
@cp -f $(TOP_DIR)/scripts/trx_init.sh $(LOCAL_MAPLE_SDK_DIR)/build/fs/.
@rm ~/svk_init.sh
.PHONY:
.PHONY: sdn_agent
sdn_agent: version_file build_sdn_agent
.PHONY: build_sdn_agent
build_sdn_agent: build_agent
$(SILENT_BUILD)mv $(TOP_DIR)/build/agent/3rdparty/indigo/ofpal_of_agent $(TOP_DIR)/build/agent/bcm_sdn_agent
$(SILENT_BUILD)mk/create_artifacts.sh
.PHONY: ing_bcm_user
ing_bcm_user:
@echo "Building ING bcm.user"
@pushd 3rdparty/bcm-sdk/build/sdk-all-6.4.4/systems/linux/user/gto-2_6 && make && popd
# The following variables are only set if they have not been set
# previously or passed in.
.PHONY: docs
docs: docs_$(DOCS_SUBSYSTEM)
docs_pdf: docs_$(DOCS_SUBSYSTEM)
$(SILENT_BUILD)$(MAKE) -C $(OUT_DOCS_DIR)/latex
docs_clean:
$(SILENT_BUILD)$(BOLD_PRINT) "Cleaning docs"
$(SILENT_BUILD)rm -fr $(OUT_DOCS_DIR)
clobber: clean docs_clean
.PHONY: print_maple_dir
print_maple_dir:
@echo "Using MAPLE from $(MAPLE_SDK_DIR) copied to $(LOCAL_MAPLE_SDK_DIR)"
core: version_file build_core
$(SILENT_BUILD)export BUILD_NC_AGENT=n;\
export BUILD_OF_AGENT=n;\
mk/create_artifacts.sh
%_core:
$(SILENT_BUILD)$(MAKE) $(SILENT) SUBSYSTEM=core -f $(MAKE_DIR)/Makefile.main BUILD_NC_AGENT=n $@
agent: version_file build_agent
%_agent:
$(SILENT_BUILD)$(MAKE) $(SILENT) SUBSYSTEM=agent -f $(MAKE_DIR)/Makefile.main $@
.PHONY: bin_release_sdn_agent
bin_release_sdn_agent: bin_release_agent
.PHONY: bin_release
bin_release: bin_release_core bin_release_agent
.PHONY: maple_sdk_devel_to_release
maple_sdk_devel_to_release:
ifneq ("$(RELEASE_BUILD)", "y")
$(SILENT_BUILD)if [ ! -f $(MAPLE_SDK_DIR)/build/maple/host/fs/bcm68620_boot.bin ]; then \
echo !!! Build maple first;\
echo make -C $(MAPLE_SDK_DIR) BOARD=wrx;\
exit -1;\
fi
$(SILENT_BUILD)cd $(MAPLE_SDK_DIR) && rm -fr release && scripts/rel_delivery.sh $(MAPLE_REL_DELIVERY_PREFIX)
$(SILENT_BUILD)rm -fr $(LOCAL_MAPLE_SDK_DIR)
endif
$(SILENT_BUILD)mkdir -p $(LOCAL_MAPLE_SDK_DIR)
$(SILENT_BUILD)cp -ar $(MAPLE_SDK_DIR)/release/* $(LOCAL_MAPLE_SDK_DIR)/
ifneq ("$(RELEASE_BUILD)", "y")
$(SILENT_BUILD)cp $(MAPLE_SDK_DIR)/make/bcm68620/lint.sh $(LOCAL_MAPLE_SDK_DIR)/make/bcm68620/
endif
.PHONY: maple_sdk_dir
maple_sdk_dir: maple_sdk_devel_to_release
$(SILENT_BUILD)if [ ! -f $(LOCAL_MAPLE_SDK_DIR)/embedded_binaries/bcm68620_boot.bin ]; then \
echo !!! $(LOCAL_MAPLE_SDK_DIR)/embedded_binaries/bcm68620_boot.bin is absent;\
echo !!! Please copy BCM68620 SDK release to $(LOCAL_MAPLE_SDK_DIR);\
exit -1;\
fi
$(SILENT_BUILD)mkdir -p src/common/os_abstraction
$(SILENT_BUILD)rm -fr src/common/os_abstraction/*
$(SILENT_BUILD)cd src/common/os_abstraction && ln -s ../../../$(LOCAL_MAPLE_SDK_DIR)/host_customized/os_abstraction/* .
$(SILENT_BUILD)rm -f src/common/os_abstraction/bcmos_platform.h
src_release:
$(SILENT_BUILD)$(MAKE_DIR)/src_release.sh
.PHONY: maple_sdk
maple_sdk: maple_sdk_build overlay_bal_maple_scripts
maple_sdk_build:
$(SILENT_BUILD)rm -fr $(TOP_DIR)/$(LOCAL_MAPLE_SDK_DIR)/build/output/*
$(SILENT_BUILD)cd $(LOCAL_MAPLE_SDK_DIR) && \
unset OUT_DIR && \
BOARD=$(MAPLE_BOARD) BOARD_DIR=$(MAPLE_BOARD_DIR) $(MAKE) $(SILENT)
ifeq ("$(BOARD)", "")
$(SILENT_BUILD)mkdir -p $(TOP_DIR)/$(LOCAL_MAPLE_SDK_DIR)/build/output/
$(SILENT_BUILD)find $(TOP_DIR)/$(LOCAL_MAPLE_SDK_DIR) -name 'lib*.a' -exec ln -s \{\} $(TOP_DIR)/$(LOCAL_MAPLE_SDK_DIR)/build/output/ 2> /dev/null \;
$(SILENT_BUILD)rm -f $(TOP_DIR)/$(LOCAL_MAPLE_SDK_DIR)/build/.maple_board_dir
else
$(SILENT_BUILD)echo $(MAPLE_BOARD_DIR) > $(TOP_DIR)/$(LOCAL_MAPLE_SDK_DIR)/build/.maple_board_dir
endif
maple_sdk_clean:
$(SILENT_BUILD)OUT_DIR=$(TOP_DIR)/$(LOCAL_MAPLE_SDK_DIR)/build OUT_DIR_BASE=$(TOP_DIR)/$(LOCAL_MAPLE_SDK_DIR)/build \
BOARD_DIR=$(MAPLE_BOARD_DIR) $(MAKE) $(SILENT) -C $(LOCAL_MAPLE_SDK_DIR) TOP_DIR=$(TOP_DIR)/3rdparty/maple/sdk \
BOARD=$(MAPLE_BOARD) clean
ing_sdk_dir:
$(SILENT_BUILD)$(ING_SDK_TOP_DIR)/make_ing_dir.sh
ing_sdk:
$(SILENT_BUILD)$(MAKE) -C $(ING_SDK_TOP_DIR) -f Makefile.sdk sdk
ing_sdk_clean:
ifeq ($(ING_SDK_DEFAULT_DIR), $(ING_SDK_DIR))
$(SILENT_BUILD)rm -fr $(ING_SDK_DIR)
else
$(SILENT_BUILD)$(MAKE) -C $(ING_SDK_DIR) clean
endif
clean_ocs_omci:
$(SILENT_BUILD)$(MAKE) -C $(TOP_DIR)/3rdparty/ocs_omci clean
#clean_bcm_omci:
# $(SILENT_BUILD)$(MAKE) -C $(TOP_DIR)/3rdparty/ocs_omci clean
.PHONY: clean_sdn_agent
clean_sdn_agent: clean_agent
print-% : ; @echo $* = $($*)