blob: ab9de52956b3cca41ddfedea1f31df50758fc28f [file] [log] [blame]
Girish Gowdraa707e7c2019-11-07 11:36:13 +05301#Copyright 2018-present Open Networking Foundation
Shad Ansari01b0e652018-04-05 21:02:53 +00002#
Girish Gowdraa707e7c2019-11-07 11:36:13 +05303#Licensed under the Apache License, Version 2.0 (the "License");
4#you may not use this file except in compliance with the License.
5#You may obtain a copy of the License at
Shad Ansari01b0e652018-04-05 21:02:53 +00006#
Girish Gowdraa707e7c2019-11-07 11:36:13 +05307#http://www.apache.org/licenses/LICENSE-2.0
Shad Ansari01b0e652018-04-05 21:02:53 +00008#
Girish Gowdraa707e7c2019-11-07 11:36:13 +05309#Unless required by applicable law or agreed to in writing, software
10#distributed under the License is distributed on an "AS IS" BASIS,
11#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12#See the License for the specific language governing permissions and
13#limitations under the License.
Shad Ansari01b0e652018-04-05 21:02:53 +000014
15########################################################################
16##
17##
Luca Pretee75aaa52018-04-13 12:19:12 -070018## Config
Shad Ansari01b0e652018-04-05 21:02:53 +000019##
20##
Girish Gowdra5287fde2021-07-31 00:41:45 +000021TOP_DIR=$(shell pwd)
Shad Ansari9acc9732018-10-30 18:01:44 +000022OPENOLTDEVICE ?= generic
Craig Lutgen88a22ad2018-10-04 12:30:46 -050023
Shad Ansari01b0e652018-04-05 21:02:53 +000024#
25# Three vendor proprietary source files are required to build BAL.
26# SW-BCM68620_<VER>.zip - Broadcom BAL source and Maple SDK.
27# sdk-all-<SDK_VER>.tar.gz - Broadcom Qumran SDK.
Craig Lutgenf040dba2018-09-27 11:21:43 -050028# ACCTON_BAL_<BAL_VER>-<DEV_VER>.patch - Accton/Edgecore's patch.
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000029BAL_MAJOR_VER = 3
Girish Gowdra5287fde2021-07-31 00:41:45 +000030BAL_MINOR_VER = 10
31BAL_REV_HOST_VER = 2
32BAL_REV_EMBEDDED_VER = 2
33BAL_API_SO_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_HOST_VER)
34BAL_VER = $(BAL_API_SO_VER).$(BAL_REV_EMBEDDED_VER)
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +053035ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
Thiyagarajan Subramaniaf1a5fb2022-02-24 18:32:05 +053036DEV_VER = 20211129
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +053037# Version of Open Network Linux (ONL).
38ONL_KERN_VER_MAJOR = 4.19
39else
Girish Gowdra5287fde2021-07-31 00:41:45 +000040DEV_VER = 202111040101
41API_VER = 202111090101
42# Version of Open Network Linux (ONL).
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +053043ONL_KERN_VER_MAJOR = 4.14
44endif
Girish Gowdra5287fde2021-07-31 00:41:45 +000045SDK_VER = 6.5.21
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000046
47# OpenOLT Proto version.
48# This specifies the GIT tag in https://github.com/opencord/voltha-protos
49# repo that we need to refer to, to pick the right version of
50# openolt.proto and tech_profile.proto
Elia Battiston869a5de2022-02-08 11:40:58 +010051OPENOLT_PROTO_VER ?= v5.2.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000052
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +053053# Variables used for Inband build
54INBAND = "n"
55VLAN_ID = 4093
56
Jason Huangdc83ba72020-11-16 22:08:43 +080057# NNI ports speed setting
58PORT_100G_SPEED ?= 100000
59PORT_25G_SPEED ?= 25000
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +053060ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w"))
61PORT_QSFP_SPEED ?= 40g
62PORT_SFP_SPEED ?= 10g
63else ifeq ("$(strip $(OPENOLTDEVICE))","rlt-1600x-w")
64PORT_QSFP_SPEED ?= 100g
65PORT_SFP_SPEED ?= 25g
66endif
Jason Huangdc83ba72020-11-16 22:08:43 +080067
Shad Ansari01b0e652018-04-05 21:02:53 +000068# Build directory
69BUILD_DIR = build
Girish Gowdraddf9a162020-01-27 12:56:27 +053070
Orhan Kupusogluec57af02021-05-12 12:38:17 +000071# Rx optical power test app
72RXTX_POWER_EXE = read_rxtx_power
73
Girish Gowdra252f4972020-09-07 21:24:01 -070074# initialiaze path of protoc binary
Girish Gowdra489425a2020-02-22 13:07:42 +053075protoc-bin = $(shell which protoc)
Girish Gowdraddf9a162020-01-27 12:56:27 +053076
Girish Gowdra252f4972020-09-07 21:24:01 -070077# initialiaze path of grpc_cpp_plugin binary
Girish Gowdra489425a2020-02-22 13:07:42 +053078grpc-cpp-plugin-bin = $(shell which grpc_cpp_plugin)
Shad Ansari2cddc552018-06-26 20:34:27 +000079
80USER := $(shell echo $(USER))
Luca Pretee75aaa52018-04-13 12:19:12 -070081#
Shad Ansari01b0e652018-04-05 21:02:53 +000082########################################################################
83##
84##
Girish Gowdra252f4972020-09-07 21:24:01 -070085## Initialize various build flags
Shad Ansari01b0e652018-04-05 21:02:53 +000086##
87##
88HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
89SYSTEM ?= $(HOST_SYSTEM)
Luca Pretee75aaa52018-04-13 12:19:12 -070090
Humera Kouser5ac56612019-07-25 20:23:01 -040091VERSION ?= $(shell cat ../VERSION)
92
93#set ref and commit date only if committed
94LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
95LABEL_VCS_REF = $(shell git rev-parse HEAD)
96LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
97LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD)
98
Craig Lutgenf040dba2018-09-27 11:21:43 -050099LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g)
Girish Gowdra252f4972020-09-07 21:24:01 -0700100LIBZ_PATH=$(shell pkg-config --libs-only-L zlib | sed s/-L// | sed s/\ //g)
Craig Lutgenf040dba2018-09-27 11:21:43 -0500101LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g)
102
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700103PCAPPLUSPLUS_INCLUDE_PATH=-I/usr/local/include/pcapplusplus/
104PCAPPLUSPLUS_LIB_PATH=-lPcap++ -lPacket++ -lCommon++
105
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530106ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
107CXX = @CXX@-6
108else
109CXX = @CXX@-4.9
110endif
Craig Lutgenf040dba2018-09-27 11:21:43 -0500111CXXFLAGS += @CXXFLAGS@
112CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++)
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700113CXXFLAGS += $(PCAPPLUSPLUS_INCLUDE_PATH)
Humera Kouser5ac56612019-07-25 20:23:01 -0400114CPPFLAGS += @CPPFLAGS@
Shad Ansari01b0e652018-04-05 21:02:53 +0000115CPPFLAGS += `pkg-config --cflags protobuf grpc`
Girish Gowdra252f4972020-09-07 21:24:01 -0700116
117# Enabling SCALE_AND_PERF for higher performance and scaling to 512 subscribers. Enabling the flag will
118# disable the handling in FLOW_CHECKER and also disable flow statistics
Humera Kouser5ac56612019-07-25 20:23:01 -0400119CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBAL_VER=\"$(BAL_VER)\" -DLABEL_VCS_URL=\"$(LABEL_VCS_URL)\" \
120 -DLABEL_VCS_REF=\"$(LABEL_VCS_REF)\" -DLABEL_BUILD_DATE=\"$(LABEL_BUILD_DATE)\" \
Girish Gowdra5287fde2021-07-31 00:41:45 +0000121 -DLABEL_COMMIT_DATE=\"$(LABEL_COMMIT_DATE)\" -DFLOW_CHECKER -USCALE_AND_PERF
Humera Kouser6143c9e2020-06-17 22:37:31 +0530122CPPFLAGS += -I./
Craig Lutgen7ebee132018-11-16 15:31:11 -0600123CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix
Craig Lutgenf040dba2018-09-27 11:21:43 -0500124LDFLAGS += @LDFLAGS@
125LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr
Shad Ansari9acc9732018-10-30 18:01:44 +0000126CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic
Craig Lutgenf040dba2018-09-27 11:21:43 -0500127
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000128export CXX CXXFLAGS OPENOLT_PROTO_VER
Luca Pretee75aaa52018-04-13 12:19:12 -0700129
Shad Ansari01b0e652018-04-05 21:02:53 +0000130########################################################################
131##
132##
Luca Pretee75aaa52018-04-13 12:19:12 -0700133## ONL
Shad Ansari01b0e652018-04-05 21:02:53 +0000134##
135##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000136ONL_REPO = onl
Shad Ansari01b0e652018-04-05 21:02:53 +0000137ONL_DIR = $(BUILD_DIR)/$(ONL_REPO)
Shad Ansari01b0e652018-04-05 21:02:53 +0000138onl:
139 if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \
140 mkdir -p $(ONL_DIR); \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000141 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \
142 cp download/Makefile.onl $(ONL_DIR)/Makefile; \
143 install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \
Girish Gowdra5287fde2021-07-31 00:41:45 +0000144 cp download/disable-certificate-validation*.patch $(ONL_DIR)/OpenNetworkLinux; \
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530145 if [ "$(OPENOLTDEVICE)" = "rlt-3200g-w" ] || [ "$(OPENOLTDEVICE)" = "rlt-1600g-w" ] || [ "$(OPENOLTDEVICE)" = "rlt-1600x-w" ]; \
146 then \
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530147 cp $(TOP_DIR)/device/$(OPENOLTDEVICE)/update_kernel_options.sh $(ONL_DIR)/OpenNetworkLinux/.; \
148 chmod 0755 $(ONL_DIR)/OpenNetworkLinux/update_kernel_options.sh; \
149 fi; \
150 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n BOARD=$(OPENOLTDEVICE); \
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530151 else \
152 if [ "$(INBAND)" = n -a "$$(grep "inband" $(ONL_DIR)/onl_build.mode | cut -d= -f 2)" = y ]; then \
153 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \
154 fi; \
Shad Ansari01b0e652018-04-05 21:02:53 +0000155 fi;
156onl-force:
Shad Ansari9acc9732018-10-30 18:01:44 +0000157 make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR)
Shad Ansari01b0e652018-04-05 21:02:53 +0000158distclean-onl:
159 sudo rm -rf $(ONL_DIR)
160
Girish Gowdra5287fde2021-07-31 00:41:45 +0000161
Shad Ansari01b0e652018-04-05 21:02:53 +0000162########################################################################
163##
164##
Girish Gowdra5287fde2021-07-31 00:41:45 +0000165## Broadcom LIBRARY OSS API
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000166##
167##
Girish Gowdra5287fde2021-07-31 00:41:45 +0000168BAL_API_DIR = $(TOP_DIR)/$(BUILD_DIR)/bal-oss-api-$(BAL_VER)
169BAL_API_PATCH = ACCTON_BAL_API_$(BAL_VER)-V$(API_VER).patch
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000170
Girish Gowdra5287fde2021-07-31 00:41:45 +0000171$(BUILD_DIR)/libbal_host_api-oss.so:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000172 if [ ! -d "$(BAL_API_DIR)" ]; then \
173 mkdir -p $(BAL_API_DIR); \
Girish Gowdra5287fde2021-07-31 00:41:45 +0000174 cd $(BAL_API_DIR); \
175 git clone https://github.com/balapi/bal-sdk.git -b $(BAL_VER); \
176 mv bal-sdk bal-sdk-$(BAL_VER); \
Thiyagarajan Subramaniaf1a5fb2022-02-24 18:32:05 +0530177 if [ "$(OPENOLTDEVICE)" = "rlt-3200g-w" ] || [ "$(OPENOLTDEVICE)" = "rlt-1600g-w" ] || [ "$(OPENOLTDEVICE)" = "rlt-1600x-w" ]; \
178 then \
179 cd $(BAL_API_DIR)/bal-sdk-$(BAL_VER); \
180 make; \
181 cp build/fs/libbal_host_api-oss.$(BAL_API_SO_VER).so ../../../$(BUILD_DIR)/libbal_host_api-oss.so; \
182 cd .. && ln -s bal-sdk-$(BAL_VER)/build/fs/include include; \
183 cd; \
184 else \
185 cat $(TOP_DIR)/download/$(BAL_API_PATCH) | patch -p1 -d $(BAL_API_DIR)/bal-sdk-$(BAL_VER); \
186 cd $(BAL_API_DIR)/bal-sdk-$(BAL_VER); \
187 make BOARD=$(OPENOLTDEVICE); \
188 cp build/fs/libbal_host_api-oss.$(BAL_API_SO_VER).so ../../../$(BUILD_DIR)/libbal_host_api-oss.so; \
189 cp config/$(OPENOLTDEVICE)/bcm_config.h build/fs/include; \
190 cd .. && ln -s bal-sdk-$(BAL_VER)/build/fs/include include; \
191 cd; \
192 fi; \
Girish Gowdrafc6c0bf2022-01-28 18:31:30 -0800193 else \
194 cd $(BAL_API_DIR)/bal-sdk-$(BAL_VER); \
195 cp build/fs/libbal_host_api-oss.$(BAL_API_SO_VER).so ../../../$(BUILD_DIR)/libbal_host_api-oss.so; \
Thiyagarajan Subramaniaf1a5fb2022-02-24 18:32:05 +0530196 if [ "$(OPENOLTDEVICE)" != "rlt-3200g-w" ] && [ "$(OPENOLTDEVICE)" != "rlt-1600g-w" ] && [ "$(OPENOLTDEVICE)" != "rlt-1600x-w" ]; \
197 then \
198 cp config/$(OPENOLTDEVICE)/bcm_config.h build/fs/include; \
199 fi; \
Girish Gowdrafc6c0bf2022-01-28 18:31:30 -0800200 cd .. && ln -s bal-sdk-$(BAL_VER)/build/fs/include include; \
201 cd; \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000202 fi;
Girish Gowdra5287fde2021-07-31 00:41:45 +0000203
204
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000205bal-api-clean:
Girish Gowdra5287fde2021-07-31 00:41:45 +0000206 if [ -d "$(BAL_API_DIR)" ]; then \
207 rm -rf $(BAL_API_DIR); \
208 fi;
209 rm -rf $(BUILD_DIR)/libbal_host_api-oss.so
210
211########################################################################
212#
213# Choose api type: open api (api-oss) or proprietary api (api-nda-req)
214BAL_API_TYPE = api-oss
215#BAL_API_TYPE = api-nda-req
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000216
217########################################################################
218##
219##
Girish Gowdra5287fde2021-07-31 00:41:45 +0000220## BAL OSS API
Shad Ansari01b0e652018-04-05 21:02:53 +0000221##
222##
Shad Ansari9acc9732018-10-30 18:01:44 +0000223BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal
Girish Gowdra5287fde2021-07-31 00:41:45 +0000224BALLIBDIR = $(BUILD_DIR)
225BALLIBNAME = bal_host_$(BAL_API_TYPE)
226BAL_INC = -I$(BAL_API_DIR)/include
227CXXFLAGS += $(BAL_INC)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000228CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST -DENABLE_LOG -DENABLE_CLI
Jason Huangdc83ba72020-11-16 22:08:43 +0800229PORT_SPEED_FILE = $(BAL_DIR)/switch_sdk/$(SDK_VER)/rc/$(OPENOLTDEVICE)/board_files/broadcom/port_speed.soc
Shad Ansaricb004c52018-05-30 18:07:23 +0000230
Girish Gowdra5287fde2021-07-31 00:41:45 +0000231########################################################################
232##
233## BAL proprietary elements - NDA is required with Broadcom
234##
235## For Accton patch - contact Accton corporation
236##
237## Not required when building the OpenOLT agent from github source
238##
239## !!!NOTE: libbal_host_api-nda_req.so is proprietary and must not be
240## published in any open debian package or otherwise made
241## available to third parties that do not have an SLA and
242## NDA with Broadcom
243##
244BAL_SDK_ZIP = SW-BCM686OLT_$(subst .,_,$(BAL_VER)).tgz
245CSG_SDK_ZIP = sdk-all-$(SDK_VER).tar.gz
246ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch
Thiyagarajan Subramaniaf1a5fb2022-02-24 18:32:05 +0530247RADISYS_PATCH = RADISYS_BAL_$(BAL_VER)_V$(DEV_VER).patch
Girish Gowdra5287fde2021-07-31 00:41:45 +0000248BROADCOM_IP_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER)-BROADCOM-IP.patch
249BCM_SWITCH_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER)
250
251sdk: onl
Shad Ansari01b0e652018-04-05 21:02:53 +0000252ifeq ("$(wildcard $(BAL_DIR))","")
253 mkdir $(BAL_DIR)
Girish Gowdra5287fde2021-07-31 00:41:45 +0000254 tar zxvf download/$(BAL_SDK_ZIP) --strip 1 -C $(BAL_DIR)
255 cp download/$(CSG_SDK_ZIP) $(BCM_SWITCH_SDK)
Shad Ansari01b0e652018-04-05 21:02:53 +0000256 chmod -R 744 $(BAL_DIR)
Thiyagarajan Subramaniaf1a5fb2022-02-24 18:32:05 +0530257ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
258 cat download/$(RADISYS_PATCH) | patch -p1 -d $(BAL_DIR)
259else
Girish Gowdra5287fde2021-07-31 00:41:45 +0000260 cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR)
261 cat download/$(BROADCOM_IP_PATCH) | patch -p1 -d $(BAL_DIR)
Thiyagarajan Subramaniaf1a5fb2022-02-24 18:32:05 +0530262endif
Girish Gowdra5287fde2021-07-31 00:41:45 +0000263
Jason Huangdc83ba72020-11-16 22:08:43 +0800264ifeq ("$(strip $(OPENOLTDEVICE))","asfvolt16")
265 echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
266else ifeq ("$(strip $(OPENOLTDEVICE))","asgvolt64")
267 echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
268 echo "setenv port_speed_for_25 $(PORT_25G_SPEED)" >> $(PORT_SPEED_FILE)
269endif
Girish Gowdra5287fde2021-07-31 00:41:45 +0000270
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530271ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530272 chmod 0755 $(BAL_DIR)/onu_mgmt/libomcistack/me_codegen/omci_stack_codegen
Thiyagarajan Subramaniaf1a5fb2022-02-24 18:32:05 +0530273 chmod 0755 $(BCM_SWITCH_SDK)/sdk_patches_apply.sh
274 make -C $(BAL_DIR) BOARD=radisys ONL=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux ONL_DEBIAN_SUITE=$(shell lsb_release -c -s)
275 make -C $(BAL_DIR) BOARD=radisys release_board
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530276else
Girish Gowdra5287fde2021-07-31 00:41:45 +0000277 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000278 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
Shad Ansari01b0e652018-04-05 21:02:53 +0000279endif
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530280endif
Shad Ansaricb004c52018-05-30 18:07:23 +0000281
Shad Ansaricb004c52018-05-30 18:07:23 +0000282bal-clean:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000283 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all
Shad Ansari01b0e652018-04-05 21:02:53 +0000284
285########################################################################
286##
287##
Luca Pretee75aaa52018-04-13 12:19:12 -0700288## OpenOLT API
Shad Ansari01b0e652018-04-05 21:02:53 +0000289##
290##
Shad Ansari56c8ea42018-10-30 19:34:35 +0000291OPENOLT_PROTOS_DIR = ../protos
Shad Ansari19249582018-04-30 04:31:00 +0000292OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a
Girish Gowdra252f4972020-09-07 21:24:01 -0700293CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I./device -I./device/$(OPENOLTDEVICE) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens
Shad Ansari19249582018-04-30 04:31:00 +0000294protos:
Girish Gowdrafc6c0bf2022-01-28 18:31:30 -0800295 if [ ! -f "$(OPENOLT_API_LIB)" ]; then \
296 make -C $(OPENOLT_PROTOS_DIR) all; \
297 fi;
Shad Ansaricc01de12018-05-21 22:54:45 +0000298protos-clean:
Shad Ansari19249582018-04-30 04:31:00 +0000299 -make -C $(OPENOLT_PROTOS_DIR) clean
Shad Ansari01b0e652018-04-05 21:02:53 +0000300
301########################################################################
302##
303##
Shad Ansari627b5782018-08-13 22:49:32 +0000304## common
Shad Ansari7193ae22018-08-08 22:23:18 +0000305##
306##
Girish Gowdrafe649702019-10-30 12:49:58 +0530307
308# A hack to force a re-build of common/main.cc everytime.
309# This is needed to bake in the git VCS information in the openolt binary
310# at the time of building the openolt package.
311common/main.o: .FORCE
312.FORCE:
313 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c common/main.cc -o common/main.o
314
Shad Ansari627b5782018-08-13 22:49:32 +0000315common/%.o: common/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400316 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari7193ae22018-08-08 22:23:18 +0000317
318########################################################################
319##
320##
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500321## device
322##
323##
Shad Ansari9acc9732018-10-30 18:01:44 +0000324device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500325 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
326
327device/generic/%.o: device/generic/%.cc
328 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
329
330########################################################################
331##
332##
Shad Ansari627b5782018-08-13 22:49:32 +0000333## openolt
334##
335##
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400336OLT_SW_UPGRADE_DIR = ../olt-sw-upgrade
Shad Ansari9acc9732018-10-30 18:01:44 +0000337SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc)
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400338ANSIBLE_DIR = /etc/ansible
Shad Ansari01b0e652018-04-05 21:02:53 +0000339OBJS = $(SRCS:.cc=.o)
340DEPS = $(SRCS:.cc=.d)
341.DEFAULT_GOAL := all
Shad Ansari2ae27672019-05-09 00:26:34 +0000342all: $(BUILD_DIR)/openolt
Girish Gowdra5287fde2021-07-31 00:41:45 +0000343$(BUILD_DIR)/openolt: $(BUILD_DIR)/lib$(BALLIBNAME).so sdk protos $(OBJS)
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700344 $(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)
Thiyagarajan Subramaniaf1a5fb2022-02-24 18:32:05 +0530345ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
346 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/radisys/release/release_radisys_v$(BAL_VER).tar.gz $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
347else
Jason Huang09b73ea2020-01-08 17:52:05 +0800348 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/.
Thiyagarajan Subramaniaf1a5fb2022-02-24 18:32:05 +0530349endif
Girish Gowdra252f4972020-09-07 21:24:01 -0700350 ln -sf $(LIBGRPC_PATH)/libz.so.1 $(BUILD_DIR)/libz.so.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000351 ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6
352 strip $(BUILD_DIR)/openolt
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530353 echo "inband=n" > $(ONL_DIR)/onl_build.mode
354 if [ $(INBAND) = y ]; then \
355 echo "Building ONL+BAL+OpenoltAgent allinone image"; \
356 make deb; \
357 make inband-onl; \
358 fi;
359
Shad Ansari627b5782018-08-13 22:49:32 +0000360src/%.o: src/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400361 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari01b0e652018-04-05 21:02:53 +0000362
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000363deb: rxtx-power
Jason Huang09b73ea2020-01-08 17:52:05 +0800364 cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000365 cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian
Girish Gowdra252f4972020-09-07 21:24:01 -0700366 cp $(BUILD_DIR)/libz.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000367 cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
Girish Gowdra5287fde2021-07-31 00:41:45 +0000368 cp $(BUILD_DIR)/libbal_host_api-oss.so device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000369 cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000370 cp -a $(RXTX_POWER_EXE) device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530371ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
372 sed -i '/\/opt\/bcm68650\/svk_init.sh/c\ \/opt\/bcm68650\/svk_init.sh -qsfp_speed=$(PORT_QSFP_SPEED) -sfp_speed=$(PORT_SFP_SPEED)' device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/dev_mgmt_daemon
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530373endif
Girish Gowdra6e745522020-07-15 15:52:13 -0700374 cp -a scripts/watchdog device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000375 cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530376 mv device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansaricb004c52018-05-30 18:07:23 +0000377 make deb-cleanup
Shad Ansari6cd46a62018-05-13 23:20:51 +0000378
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530379inband-onl:
380 # Clean previous ONL build and build freshly
381 sudo rm -rf $(ONL_DIR)
382 mkdir -p $(ONL_DIR)
383 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux
384 cp download/Makefile.onl $(ONL_DIR)/Makefile
385 install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux
386
387 # Check ONL commit equals to Inband patch commit
388 ONL_COMMIT_ID=$(awk \'/COMMIT_ID = /{print $0}\' $(ONL_DIR)/Makefile | awk -F \"=\" \'{print $2}\')
389 INBAND_PATCH_COMMIT_ID=$(echo cp $(TOP_DIR)/inband/patch/*.patch | cut -d- -f 2 | cut -d. -f 1)
390 if [ "$(ONL_COMMIT_ID)" = "$(INBAND_PATCH_COMMIT_ID)" ]; then \
391 echo "ONL commit and inband patch commit matched."; \
392 cp $(TOP_DIR)/inband/patch/*.patch $(ONL_DIR)/OpenNetworkLinux; \
Girish Gowdraa1640802021-11-24 20:24:38 -0800393 cp $(TOP_DIR)/download/disable-certificate-validation-v*.patch $(ONL_DIR)/OpenNetworkLinux; \
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530394 else \
395 echo "ONL commit and inband patch commit does not match. Exiting."; \
396 exit 1; \
397 fi;
398
Girish Gowdra6e745522020-07-15 15:52:13 -0700399 # Update inband.config file with VLAN ID argument passed
400 sed -i 's/asfvolt16_vlan_id_eth2=.*/asfvolt16_vlan_id_eth2=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config
401 sed -i 's/asgvolt64_vlan_id_eth1=.*/asgvolt64_vlan_id_eth1=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530402
403 # Copy Inband config files and olt startup scripts to ONL source code and build
404 cd $(TOP_DIR) && mkdir -p $(ONL_DIR)/OpenNetworkLinux/bal_packages
405 cp $(TOP_DIR)/inband/scripts/* $(ONL_DIR)/OpenNetworkLinux/bal_packages
Girish Gowdra6e745522020-07-15 15:52:13 -0700406 cp $(TOP_DIR)/inband/config/inband.config $(ONL_DIR)/OpenNetworkLinux/bal_packages
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530407 cp $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb $(ONL_DIR)/OpenNetworkLinux/bal_packages/openolt_$(OPENOLTDEVICE).deb
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400408 cp $(OLT_SW_UPGRADE_DIR)/change_labels.sh $(ONL_DIR)/OpenNetworkLinux/bal_packages
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530409
410 # Rebuild ONL packed with already built BAL+Openolt debian package
411 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=y
412 echo "inband=y" > $(ONL_DIR)/onl_build.mode
413 make inband-onl-cleanup
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400414# requires 'sudo' privileges
415
416ansible:
417 (ONL_INSTALLED_INSTALLER="$(shell find "$$(cd ./build/onl/OpenNetworkLinux/RELEASE/jessie/amd64; pwd)" -name "ONL-onl-*_AMD64_INSTALLED_INSTALLER")"; \
418 rm -rf $(ANSIBLE_DIR)/roles/upgrade/files; \
419 mkdir -p $(ANSIBLE_DIR)/roles/upgrade/files; \
420 cp ../olt-sw-upgrade/install_onl.sh $(ANSIBLE_DIR)/roles/upgrade/files; \
421 chmod +x $(ANSIBLE_DIR)/roles/upgrade/files/*.sh; \
422 ln -s $$ONL_INSTALLED_INSTALLER $(ANSIBLE_DIR)/roles/upgrade/files/ONL_INSTALLED_INSTALLER)
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530423
Shad Ansari01b0e652018-04-05 21:02:53 +0000424src/%.o: %.cpp
425 $(CXX) -MMD -c $< -o $@
426
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000427rxtx-power: clean-rxtx-power
428 $(CXX) -std=c++11 -DRXTX_POWER_EXE_MODE src/trx_eeprom_reader.cc -o $(RXTX_POWER_EXE) && ls -l $(RXTX_POWER_EXE)
429
430deb-cleanup: clean-rxtx-power
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000431 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log
432 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper
433 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper
434 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars
435 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/
436 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp
Girish Gowdra252f4972020-09-07 21:24:01 -0700437 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libz.so.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000438 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6
Girish Gowdra5287fde2021-07-31 00:41:45 +0000439 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api-oss.so
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000440 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/
441 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt
Jason Huang09b73ea2020-01-08 17:52:05 +0800442 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000443 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/
444 @rm -f device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000445 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(RXTX_POWER_EXE)
Girish Gowdrab8c09fa2021-08-02 10:22:59 -0700446 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/watchdog/
Shad Ansaricc01de12018-05-21 22:54:45 +0000447
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530448inband-onl-cleanup:
449 @rm -f $(ONL_DIR)/OpenNetworkLinux/*.patch
450 @rm -rf $(ONL_DIR)/OpenNetworkLinux/bal_packages
451
Shad Ansaricb004c52018-05-30 18:07:23 +0000452clean: protos-clean deb-cleanup
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000453 @rm -f $(OBJS) $(DEPS)
454 @rm -rf $(OPENOLT_PROTOS_DIR)/googleapis
Girish Gowdra252f4972020-09-07 21:24:01 -0700455 @rm -f $(BUILD_DIR)/libz.so.1
Girish Gowdra5287fde2021-07-31 00:41:45 +0000456 @rm -f $(BUILD_DIR)/libbal_host_api-oss.so
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000457 @rm -f $(BUILD_DIR)/openolt
Girish Gowdraab7ea552020-01-07 13:25:15 +0530458 @rm -f $(BUILD_DIR)/dev_mgmt_daemon
Jason Huang09b73ea2020-01-08 17:52:05 +0800459 @rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Girish Gowdrabc6e0852020-03-26 11:36:12 -0700460 @rm -f $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansari19249582018-04-30 04:31:00 +0000461
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000462clean-src: protos-clean
463 @rm -f $(OBJS) $(DEPS)
464
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000465clean-rxtx-power:
466 @rm -f src/$(RXTX_POWER_EXE)
467 @rm -f $(RXTX_POWER_EXE)
468
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000469distclean: clean-src clean
470 @rm -rf $(BUILD_DIR)
Shad Ansaricb004c52018-05-30 18:07:23 +0000471
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400472.PHONY: onl sdk bal protos inband-onl ansible .FORCE