blob: 1813112d6467aff8e6e742ec8cb7d205411a78e8 [file] [log] [blame]
#Copyright 2018-present Open Networking Foundation
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
#http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
########################################################################
##
##
## Config
##
##
TOP_DIR=`pwd`
OPENOLTDEVICE ?= generic
#
# Three vendor proprietary source files are required to build BAL.
# SW-BCM68620_<VER>.zip - Broadcom BAL source and Maple SDK.
# sdk-all-<SDK_VER>.tar.gz - Broadcom Qumran SDK.
# ACCTON_BAL_<BAL_VER>-<DEV_VER>.patch - Accton/Edgecore's patch.
BAL_MAJOR_VER = 3
BAL_MINOR_VER = 4
BAL_REV_A_VER = 9
BAL_REV_B_VER != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then echo "8"; else echo "6"; fi
BAL_API_REV_B_VER = 6
BAL_API_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_API_REV_B_VER)
BAL_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER)
SDK_VER = 6.5.13
DEV_VER != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then echo "20210420"; else echo "202012040101"; fi
#
# Version of Open Network Linux (ONL).
ONL_KERN_VER_MAJOR != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then echo "4.19"; else echo "4.14"; fi
# OpenOLT Proto version.
# This specifies the GIT tag in https://github.com/opencord/voltha-protos
# repo that we need to refer to, to pick the right version of
# openolt.proto and tech_profile.proto
OPENOLT_PROTO_VER ?= v4.0.15
# Variables used for Inband build
INBAND = "n"
VLAN_ID = 4093
# NNI ports speed setting
PORT_100G_SPEED ?= 100000
PORT_25G_SPEED ?= 25000
PORT_40G_SPEED ?= 40g
PORT_10G_SPEED ?= 10g
# Build directory
BUILD_DIR = build
# initialiaze path of protoc binary
protoc-bin = $(shell which protoc)
# initialiaze path of grpc_cpp_plugin binary
grpc-cpp-plugin-bin = $(shell which grpc_cpp_plugin)
USER := $(shell echo $(USER))
#
########################################################################
##
##
## Initialize various build flags
##
##
HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
SYSTEM ?= $(HOST_SYSTEM)
VERSION ?= $(shell cat ../VERSION)
#set ref and commit date only if committed
LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
LABEL_VCS_REF = $(shell git rev-parse HEAD)
LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD)
LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g)
LIBZ_PATH=$(shell pkg-config --libs-only-L zlib | sed s/-L// | sed s/\ //g)
LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g)
PCAPPLUSPLUS_INCLUDE_PATH=-I/usr/local/include/pcapplusplus/
PCAPPLUSPLUS_LIB_PATH=-lPcap++ -lPacket++ -lCommon++
CXX != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then echo "@CXX@-6"; else echo "@CXX@-4.9"; fi
CXXFLAGS += @CXXFLAGS@
CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++)
CXXFLAGS += $(PCAPPLUSPLUS_INCLUDE_PATH)
CPPFLAGS += @CPPFLAGS@
CPPFLAGS += `pkg-config --cflags protobuf grpc`
# Enabling SCALE_AND_PERF for higher performance and scaling to 512 subscribers. Enabling the flag will
# disable the handling in FLOW_CHECKER and also disable flow statistics
# Setting SW_UTIL_SHELL=y will enable QAX debug shell when compiling for Broadcom chip based OLT
CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBAL_VER=\"$(BAL_VER)\" -DLABEL_VCS_URL=\"$(LABEL_VCS_URL)\" \
-DLABEL_VCS_REF=\"$(LABEL_VCS_REF)\" -DLABEL_BUILD_DATE=\"$(LABEL_BUILD_DATE)\" \
-DLABEL_COMMIT_DATE=\"$(LABEL_COMMIT_DATE)\" -DFLOW_CHECKER -USCALE_AND_PERF -DSW_UTIL_SHELL=n
CPPFLAGS += -I./
CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix
LDFLAGS += @LDFLAGS@
LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr
CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic
export CXX CXXFLAGS OPENOLT_PROTO_VER
########################################################################
##
##
## ONL
##
##
ONL_REPO = onl
ONL_DIR = $(BUILD_DIR)/$(ONL_REPO)
onl:
if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \
mkdir -p $(ONL_DIR); \
git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \
cp download/Makefile.onl $(ONL_DIR)/Makefile; \
install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \
if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then \
cp $(TOP_DIR)/device/$(OPENOLTDEVICE)/update_kernel_options.sh $(ONL_DIR)/OpenNetworkLinux/.; \
chmod 0755 $(ONL_DIR)/OpenNetworkLinux/update_kernel_options.sh; \
fi; \
make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n BOARD=$(OPENOLTDEVICE); \
else \
if [ "$(INBAND)" = n -a "$$(grep "inband" $(ONL_DIR)/onl_build.mode | cut -d= -f 2)" = y ]; then \
make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \
fi; \
fi;
onl-force:
make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR)
distclean-onl:
sudo rm -rf $(ONL_DIR)
########################################################################
##
##
## Broadcom LIBRARY APIs
##
##
BAL_API_DIR = $(BUILD_DIR)/bal-api-$(BAL_API_VER)
bal-api-$(BAL_API_VER):
if [ ! -d "$(BAL_API_DIR)" ]; then \
mkdir -p $(BAL_API_DIR); \
git clone https://github.com/balapi/bal-api-$(BAL_API_VER).git $(BAL_API_DIR); \
fi;
bal-api-clean:
rm -rf $(BAL_API_DIR)
########################################################################
##
##
## BAL
##
##
BAL_ZIP = SW-BCM686OLT_$(subst .,_,$(BAL_VER)).tgz
SDK_ZIP = sdk-all-$(SDK_VER).tar.gz
PATCH_FILE != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then \
echo "PHOENIX_BAL_$(BAL_VER)_V$(DEV_VER).patch"; else \
echo "ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch"; fi
BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal
BCM_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER)
BALLIBDIR = $(BAL_DIR)/build/host_reference/host_api
BALLIBNAME = bal_host_api
BAL_INC = -I$(BAL_DIR)/host_driver/bal/bal_include \
-I$(BAL_DIR)/host_driver/topology \
-I$(BAL_DIR)/host_driver/utils \
-I$(BAL_DIR)/host_driver/api \
-I$(BAL_DIR)/host_driver/metadata \
-I$(BAL_DIR)/host_customized/os_abstraction \
-I$(BAL_DIR)/host_customized/os_abstraction/posix \
-I$(BAL_DIR)/host_customized/config \
-I$(BAL_DIR)/host_driver/api_conn_mgr \
-I$(BAL_DIR)/host_driver/conn_mgr \
-I$(BAL_DIR)/host_driver/api/host/topology \
-I$(BAL_DIR)/host_reference/cli \
-I$(BAL_DIR)/host_reference/api_cli \
-I$(BAL_API_DIR)/include \
-I$(BAL_API_DIR)/include/object_model
CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline
CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST -DENABLE_LOG -DENABLE_CLI
PORT_SPEED_FILE = $(BAL_DIR)/switch_sdk/$(SDK_VER)/rc/$(OPENOLTDEVICE)/board_files/broadcom/port_speed.soc
sdk: onl bal-api-$(BAL_API_VER)
ifeq ("$(wildcard $(BAL_DIR))","")
mkdir $(BAL_DIR)
tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR)
cp download/$(SDK_ZIP) $(BCM_SDK)
chmod -R 744 $(BAL_DIR)
cat download/$(PATCH_FILE) | patch -p1 -d $(BAL_DIR)
ifeq ("$(strip $(OPENOLTDEVICE))","asfvolt16")
echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
else ifeq ("$(strip $(OPENOLTDEVICE))","asgvolt64")
echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
echo "setenv port_speed_for_25 $(PORT_25G_SPEED)" >> $(PORT_SPEED_FILE)
endif
ifeq ("$(strip $(OPENOLTDEVICE))","phoenix")
chmod 0755 $(BAL_DIR)/onu_mgmt/libomcistack/me_codegen/omci_stack_codegen
make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux ONL_DEBIAN_SUITE=$(shell lsb_release -c -s) OPEN_SOURCE=y
else
make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux OPEN_SOURCE=y
endif
make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
endif
bal-release: sdk
make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
bal-clean:
make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all
########################################################################
##
##
## OpenOLT API
##
##
OPENOLT_PROTOS_DIR = ../protos
OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a
CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I./device -I./device/$(OPENOLTDEVICE) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens
protos:
make -C $(OPENOLT_PROTOS_DIR) all
protos-clean:
-make -C $(OPENOLT_PROTOS_DIR) clean
########################################################################
##
##
## common
##
##
# A hack to force a re-build of common/main.cc everytime.
# This is needed to bake in the git VCS information in the openolt binary
# at the time of building the openolt package.
common/main.o: .FORCE
.FORCE:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c common/main.cc -o common/main.o
common/%.o: common/%.cc
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c $< -o $@
########################################################################
##
##
## device
##
##
device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc
$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
device/generic/%.o: device/generic/%.cc
$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
########################################################################
##
##
## openolt
##
##
OLT_SW_UPGRADE_DIR = ../olt-sw-upgrade
SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc)
ANSIBLE_DIR = /etc/ansible
OBJS = $(SRCS:.cc=.o)
DEPS = $(SRCS:.cc=.d)
.DEFAULT_GOAL := all
all: $(BUILD_DIR)/openolt
$(BUILD_DIR)/openolt: sdk protos $(OBJS)
$(CXX) $(LDFLAGS) -L$(BALLIBDIR) $(OBJS) $(OPENOLT_API_LIB) $(LIBPROTOBUF_PATH)/libprotobuf.a -o $@ -l$(BALLIBNAME) $(shell pkg-config --libs protobuf grpc++ grpc) $(PCAPPLUSPLUS_LIB_PATH)
ifeq ("$(strip $(OPENOLTDEVICE))","phoenix")
ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_v$(BAL_VER).tar.gz $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
else
ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/.
endif
ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_reference/host_api/strip/libbal_host_api.so $(BUILD_DIR)/.
ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_driver/dev_mgmt_daemon/dev_mgmt_daemon $(BUILD_DIR)/.
ln -sf $(LIBGRPC_PATH)/libz.so.1 $(BUILD_DIR)/libz.so.1
ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6
strip $(BUILD_DIR)/openolt
echo "inband=n" > $(ONL_DIR)/onl_build.mode
if [ $(INBAND) = y ]; then \
echo "Building ONL+BAL+OpenoltAgent allinone image"; \
make deb; \
make inband-onl; \
fi;
src/%.o: src/%.cc
$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@
deb:
cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz device/$(OPENOLTDEVICE)/mkdebian/debian
cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian
cp $(BUILD_DIR)/libz.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian
cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian
cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian
ifeq ("$(strip $(OPENOLTDEVICE))","phoenix")
sed -i '/\/opt\/bcm68650\/svk_init.sh/c\ \/opt\/bcm68650\/svk_init.sh -qsfp_speed=$(PORT_40G_SPEED) -sfp_speed=$(PORT_10G_SPEED)' device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/dev_mgmt_daemon
endif
cp -a scripts/watchdog device/$(OPENOLTDEVICE)/mkdebian/debian
cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
mv device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
make deb-cleanup
inband-onl:
# Clean previous ONL build and build freshly
sudo rm -rf $(ONL_DIR)
mkdir -p $(ONL_DIR)
git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux
cp download/Makefile.onl $(ONL_DIR)/Makefile
install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux
# Check ONL commit equals to Inband patch commit
ONL_COMMIT_ID=$(awk \'/COMMIT_ID = /{print $0}\' $(ONL_DIR)/Makefile | awk -F \"=\" \'{print $2}\')
INBAND_PATCH_COMMIT_ID=$(echo cp $(TOP_DIR)/inband/patch/*.patch | cut -d- -f 2 | cut -d. -f 1)
if [ "$(ONL_COMMIT_ID)" = "$(INBAND_PATCH_COMMIT_ID)" ]; then \
echo "ONL commit and inband patch commit matched."; \
cp $(TOP_DIR)/inband/patch/*.patch $(ONL_DIR)/OpenNetworkLinux; \
else \
echo "ONL commit and inband patch commit does not match. Exiting."; \
exit 1; \
fi;
# Update inband.config file with VLAN ID argument passed
sed -i 's/asfvolt16_vlan_id_eth2=.*/asfvolt16_vlan_id_eth2=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config
sed -i 's/asgvolt64_vlan_id_eth1=.*/asgvolt64_vlan_id_eth1=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config
# Copy Inband config files and olt startup scripts to ONL source code and build
cd $(TOP_DIR) && mkdir -p $(ONL_DIR)/OpenNetworkLinux/bal_packages
cp $(TOP_DIR)/inband/scripts/* $(ONL_DIR)/OpenNetworkLinux/bal_packages
cp $(TOP_DIR)/inband/config/inband.config $(ONL_DIR)/OpenNetworkLinux/bal_packages
cp $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb $(ONL_DIR)/OpenNetworkLinux/bal_packages/openolt_$(OPENOLTDEVICE).deb
cp $(OLT_SW_UPGRADE_DIR)/change_labels.sh $(ONL_DIR)/OpenNetworkLinux/bal_packages
# Rebuild ONL packed with already built BAL+Openolt debian package
make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=y
echo "inband=y" > $(ONL_DIR)/onl_build.mode
make inband-onl-cleanup
# requires 'sudo' privileges
ansible:
(ONL_INSTALLED_INSTALLER="$(shell find "$$(cd ./build/onl/OpenNetworkLinux/RELEASE/jessie/amd64; pwd)" -name "ONL-onl-*_AMD64_INSTALLED_INSTALLER")"; \
rm -rf $(ANSIBLE_DIR)/roles/upgrade/files; \
mkdir -p $(ANSIBLE_DIR)/roles/upgrade/files; \
cp ../olt-sw-upgrade/install_onl.sh $(ANSIBLE_DIR)/roles/upgrade/files; \
chmod +x $(ANSIBLE_DIR)/roles/upgrade/files/*.sh; \
ln -s $$ONL_INSTALLED_INSTALLER $(ANSIBLE_DIR)/roles/upgrade/files/ONL_INSTALLED_INSTALLER)
src/%.o: %.cpp
$(CXX) -MMD -c $< -o $@
deb-cleanup:
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars
@rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libz.so.1
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api.so
@rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt
@rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
@rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/
@rm -f device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes
inband-onl-cleanup:
@rm -f $(ONL_DIR)/OpenNetworkLinux/*.patch
@rm -rf $(ONL_DIR)/OpenNetworkLinux/bal_packages
clean: protos-clean deb-cleanup
@rm -f $(OBJS) $(DEPS)
@rm -rf $(OPENOLT_PROTOS_DIR)/googleapis
@rm -f $(BUILD_DIR)/libz.so.1
@rm -f $(BUILD_DIR)/libbal_host_api.so
@rm -f $(BUILD_DIR)/openolt
@rm -f $(BUILD_DIR)/dev_mgmt_daemon
@rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
@rm -f $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
clean-src: protos-clean
@rm -f $(OBJS) $(DEPS)
distclean: clean-src clean
@rm -rf $(BUILD_DIR)
.PHONY: onl sdk bal protos inband-onl ansible .FORCE