blob: b46758997cc25953bbd11f9328d0a21a0b4abc2e [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##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000021TOP_DIR=`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
Jason Huangc6362792020-03-04 16:33:19 +080030BAL_MINOR_VER = 4
Girish Gowdrafc10f0d2020-11-30 13:06:35 -080031BAL_REV_A_VER = 9
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +053032ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
Naresh Kumar Palanisamy0bfd4d22021-08-02 18:52:05 +053033BAL_REV_B_VER = 9
34DEV_VER = 20210727
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +053035# Version of Open Network Linux (ONL).
36ONL_KERN_VER_MAJOR = 4.19
37else
38BAL_REV_B_VER = 6
39DEV_VER = 202012040101
40ONL_KERN_VER_MAJOR = 4.14
41endif
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053042BAL_API_REV_B_VER = 6
43BAL_API_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_API_REV_B_VER)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000044BAL_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER)
45SDK_VER = 6.5.13
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
Girish Gowdraeec0fc92021-05-12 15:37:55 -070051OPENOLT_PROTO_VER ?= v4.2.0
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
119# Setting SW_UTIL_SHELL=y will enable QAX debug shell when compiling for Broadcom chip based OLT
Humera Kouser5ac56612019-07-25 20:23:01 -0400120CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBAL_VER=\"$(BAL_VER)\" -DLABEL_VCS_URL=\"$(LABEL_VCS_URL)\" \
121 -DLABEL_VCS_REF=\"$(LABEL_VCS_REF)\" -DLABEL_BUILD_DATE=\"$(LABEL_BUILD_DATE)\" \
Girish Gowdra252f4972020-09-07 21:24:01 -0700122 -DLABEL_COMMIT_DATE=\"$(LABEL_COMMIT_DATE)\" -DFLOW_CHECKER -USCALE_AND_PERF -DSW_UTIL_SHELL=n
Humera Kouser6143c9e2020-06-17 22:37:31 +0530123CPPFLAGS += -I./
Craig Lutgen7ebee132018-11-16 15:31:11 -0600124CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix
Craig Lutgenf040dba2018-09-27 11:21:43 -0500125LDFLAGS += @LDFLAGS@
126LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr
Shad Ansari9acc9732018-10-30 18:01:44 +0000127CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic
Craig Lutgenf040dba2018-09-27 11:21:43 -0500128
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000129export CXX CXXFLAGS OPENOLT_PROTO_VER
Luca Pretee75aaa52018-04-13 12:19:12 -0700130
Shad Ansari01b0e652018-04-05 21:02:53 +0000131########################################################################
132##
133##
Luca Pretee75aaa52018-04-13 12:19:12 -0700134## ONL
Shad Ansari01b0e652018-04-05 21:02:53 +0000135##
136##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000137ONL_REPO = onl
Shad Ansari01b0e652018-04-05 21:02:53 +0000138ONL_DIR = $(BUILD_DIR)/$(ONL_REPO)
Shad Ansari01b0e652018-04-05 21:02:53 +0000139onl:
140 if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \
141 mkdir -p $(ONL_DIR); \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000142 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \
143 cp download/Makefile.onl $(ONL_DIR)/Makefile; \
144 install -m 755 download/build-onl.sh $(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
161########################################################################
162##
163##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000164## Broadcom LIBRARY APIs
165##
166##
167BAL_API_DIR = $(BUILD_DIR)/bal-api-$(BAL_API_VER)
168
169bal-api-$(BAL_API_VER):
170 if [ ! -d "$(BAL_API_DIR)" ]; then \
171 mkdir -p $(BAL_API_DIR); \
172 git clone https://github.com/balapi/bal-api-$(BAL_API_VER).git $(BAL_API_DIR); \
173 fi;
174bal-api-clean:
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530175 rm -rf $(BAL_API_DIR)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000176
177########################################################################
178##
179##
Luca Pretee75aaa52018-04-13 12:19:12 -0700180## BAL
Shad Ansari01b0e652018-04-05 21:02:53 +0000181##
182##
Jason Huang09b73ea2020-01-08 17:52:05 +0800183BAL_ZIP = SW-BCM686OLT_$(subst .,_,$(BAL_VER)).tgz
Shad Ansari01b0e652018-04-05 21:02:53 +0000184SDK_ZIP = sdk-all-$(SDK_VER).tar.gz
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530185ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
186PATCH_FILE = PHOENIX_BAL_$(BAL_VER)_V$(DEV_VER).patch
187else
188PATCH_FILE = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch
189endif
Shad Ansari9acc9732018-10-30 18:01:44 +0000190BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000191BCM_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER)
192BALLIBDIR = $(BAL_DIR)/build/host_reference/host_api
193BALLIBNAME = bal_host_api
194BAL_INC = -I$(BAL_DIR)/host_driver/bal/bal_include \
195 -I$(BAL_DIR)/host_driver/topology \
196 -I$(BAL_DIR)/host_driver/utils \
197 -I$(BAL_DIR)/host_driver/api \
Jason Huangc6362792020-03-04 16:33:19 +0800198 -I$(BAL_DIR)/host_driver/metadata \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000199 -I$(BAL_DIR)/host_customized/os_abstraction \
200 -I$(BAL_DIR)/host_customized/os_abstraction/posix \
201 -I$(BAL_DIR)/host_customized/config \
202 -I$(BAL_DIR)/host_driver/api_conn_mgr \
203 -I$(BAL_DIR)/host_driver/conn_mgr \
204 -I$(BAL_DIR)/host_driver/api/host/topology \
205 -I$(BAL_DIR)/host_reference/cli \
206 -I$(BAL_DIR)/host_reference/api_cli \
207 -I$(BAL_API_DIR)/include \
208 -I$(BAL_API_DIR)/include/object_model
Shad Ansari01b0e652018-04-05 21:02:53 +0000209CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000210CXXFLAGS += -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 +0800211PORT_SPEED_FILE = $(BAL_DIR)/switch_sdk/$(SDK_VER)/rc/$(OPENOLTDEVICE)/board_files/broadcom/port_speed.soc
Shad Ansaricb004c52018-05-30 18:07:23 +0000212
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000213sdk: onl bal-api-$(BAL_API_VER)
Shad Ansari01b0e652018-04-05 21:02:53 +0000214ifeq ("$(wildcard $(BAL_DIR))","")
215 mkdir $(BAL_DIR)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000216 tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR)
Shad Ansari01b0e652018-04-05 21:02:53 +0000217 cp download/$(SDK_ZIP) $(BCM_SDK)
218 chmod -R 744 $(BAL_DIR)
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530219 cat download/$(PATCH_FILE) | patch -p1 -d $(BAL_DIR)
Jason Huangdc83ba72020-11-16 22:08:43 +0800220ifeq ("$(strip $(OPENOLTDEVICE))","asfvolt16")
221 echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
222else ifeq ("$(strip $(OPENOLTDEVICE))","asgvolt64")
223 echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
224 echo "setenv port_speed_for_25 $(PORT_25G_SPEED)" >> $(PORT_SPEED_FILE)
225endif
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530226ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530227 chmod 0755 $(BAL_DIR)/onu_mgmt/libomcistack/me_codegen/omci_stack_codegen
Thiyagarajan Subramania2c2c5a2021-05-18 14:47:52 +0530228 make -C $(BAL_DIR) BOARD=phoenix ONL=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux ONL_DEBIAN_SUITE=$(shell lsb_release -c -s) OPEN_SOURCE=y
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530229 make -C $(BAL_DIR) BOARD=phoenix release_board
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530230else
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000231 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux OPEN_SOURCE=y
232 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
Shad Ansari01b0e652018-04-05 21:02:53 +0000233endif
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530234endif
Shad Ansaricb004c52018-05-30 18:07:23 +0000235
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000236bal-release: sdk
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530237ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
238 make -C $(BAL_DIR) BOARD=phoenix release_board
239else
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000240 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530241endif
Shad Ansaricb004c52018-05-30 18:07:23 +0000242
243bal-clean:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000244 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all
Shad Ansari01b0e652018-04-05 21:02:53 +0000245
246########################################################################
247##
248##
Luca Pretee75aaa52018-04-13 12:19:12 -0700249## OpenOLT API
Shad Ansari01b0e652018-04-05 21:02:53 +0000250##
251##
Shad Ansari56c8ea42018-10-30 19:34:35 +0000252OPENOLT_PROTOS_DIR = ../protos
Shad Ansari19249582018-04-30 04:31:00 +0000253OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a
Girish Gowdra252f4972020-09-07 21:24:01 -0700254CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I./device -I./device/$(OPENOLTDEVICE) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens
Shad Ansari19249582018-04-30 04:31:00 +0000255protos:
256 make -C $(OPENOLT_PROTOS_DIR) all
Shad Ansaricc01de12018-05-21 22:54:45 +0000257protos-clean:
Shad Ansari19249582018-04-30 04:31:00 +0000258 -make -C $(OPENOLT_PROTOS_DIR) clean
Shad Ansari01b0e652018-04-05 21:02:53 +0000259
260########################################################################
261##
262##
Shad Ansari627b5782018-08-13 22:49:32 +0000263## common
Shad Ansari7193ae22018-08-08 22:23:18 +0000264##
265##
Girish Gowdrafe649702019-10-30 12:49:58 +0530266
267# A hack to force a re-build of common/main.cc everytime.
268# This is needed to bake in the git VCS information in the openolt binary
269# at the time of building the openolt package.
270common/main.o: .FORCE
271.FORCE:
272 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c common/main.cc -o common/main.o
273
Shad Ansari627b5782018-08-13 22:49:32 +0000274common/%.o: common/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400275 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari7193ae22018-08-08 22:23:18 +0000276
277########################################################################
278##
279##
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500280## device
281##
282##
Shad Ansari9acc9732018-10-30 18:01:44 +0000283device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500284 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
285
286device/generic/%.o: device/generic/%.cc
287 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
288
289########################################################################
290##
291##
Shad Ansari627b5782018-08-13 22:49:32 +0000292## openolt
293##
294##
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400295OLT_SW_UPGRADE_DIR = ../olt-sw-upgrade
Shad Ansari9acc9732018-10-30 18:01:44 +0000296SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc)
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400297ANSIBLE_DIR = /etc/ansible
Shad Ansari01b0e652018-04-05 21:02:53 +0000298OBJS = $(SRCS:.cc=.o)
299DEPS = $(SRCS:.cc=.d)
300.DEFAULT_GOAL := all
Shad Ansari2ae27672019-05-09 00:26:34 +0000301all: $(BUILD_DIR)/openolt
Shad Ansaricb004c52018-05-30 18:07:23 +0000302$(BUILD_DIR)/openolt: sdk protos $(OBJS)
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700303 $(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 Subramani4e62e172021-06-25 17:31:30 +0530304ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
Thiyagarajan Subramania2c2c5a2021-05-18 14:47:52 +0530305 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/phoenix/release/release_phoenix_v$(BAL_VER).tar.gz $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530306else
Jason Huang09b73ea2020-01-08 17:52:05 +0800307 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/.
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530308endif
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000309 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_reference/host_api/strip/libbal_host_api.so $(BUILD_DIR)/.
310 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_driver/dev_mgmt_daemon/dev_mgmt_daemon $(BUILD_DIR)/.
Girish Gowdra252f4972020-09-07 21:24:01 -0700311 ln -sf $(LIBGRPC_PATH)/libz.so.1 $(BUILD_DIR)/libz.so.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000312 ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6
313 strip $(BUILD_DIR)/openolt
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530314 echo "inband=n" > $(ONL_DIR)/onl_build.mode
315 if [ $(INBAND) = y ]; then \
316 echo "Building ONL+BAL+OpenoltAgent allinone image"; \
317 make deb; \
318 make inband-onl; \
319 fi;
320
Shad Ansari627b5782018-08-13 22:49:32 +0000321src/%.o: src/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400322 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari01b0e652018-04-05 21:02:53 +0000323
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000324deb: rxtx-power
Jason Huang09b73ea2020-01-08 17:52:05 +0800325 cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000326 cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian
Girish Gowdra252f4972020-09-07 21:24:01 -0700327 cp $(BUILD_DIR)/libz.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000328 cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
329 cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian
330 cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000331 cp -a $(RXTX_POWER_EXE) device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani4e62e172021-06-25 17:31:30 +0530332ifeq ("$(strip $(OPENOLTDEVICE))",$(findstring "$(strip $(OPENOLTDEVICE))", "rlt-3200g-w" "rlt-1600g-w" "rlt-1600x-w"))
333 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 +0530334endif
Girish Gowdra6e745522020-07-15 15:52:13 -0700335 cp -a scripts/watchdog device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000336 cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530337 mv device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansaricb004c52018-05-30 18:07:23 +0000338 make deb-cleanup
Shad Ansari6cd46a62018-05-13 23:20:51 +0000339
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530340inband-onl:
341 # Clean previous ONL build and build freshly
342 sudo rm -rf $(ONL_DIR)
343 mkdir -p $(ONL_DIR)
344 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux
345 cp download/Makefile.onl $(ONL_DIR)/Makefile
346 install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux
347
348 # Check ONL commit equals to Inband patch commit
349 ONL_COMMIT_ID=$(awk \'/COMMIT_ID = /{print $0}\' $(ONL_DIR)/Makefile | awk -F \"=\" \'{print $2}\')
350 INBAND_PATCH_COMMIT_ID=$(echo cp $(TOP_DIR)/inband/patch/*.patch | cut -d- -f 2 | cut -d. -f 1)
351 if [ "$(ONL_COMMIT_ID)" = "$(INBAND_PATCH_COMMIT_ID)" ]; then \
352 echo "ONL commit and inband patch commit matched."; \
353 cp $(TOP_DIR)/inband/patch/*.patch $(ONL_DIR)/OpenNetworkLinux; \
354 else \
355 echo "ONL commit and inband patch commit does not match. Exiting."; \
356 exit 1; \
357 fi;
358
Girish Gowdra6e745522020-07-15 15:52:13 -0700359 # Update inband.config file with VLAN ID argument passed
360 sed -i 's/asfvolt16_vlan_id_eth2=.*/asfvolt16_vlan_id_eth2=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config
361 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 +0530362
363 # Copy Inband config files and olt startup scripts to ONL source code and build
364 cd $(TOP_DIR) && mkdir -p $(ONL_DIR)/OpenNetworkLinux/bal_packages
365 cp $(TOP_DIR)/inband/scripts/* $(ONL_DIR)/OpenNetworkLinux/bal_packages
Girish Gowdra6e745522020-07-15 15:52:13 -0700366 cp $(TOP_DIR)/inband/config/inband.config $(ONL_DIR)/OpenNetworkLinux/bal_packages
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530367 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 -0400368 cp $(OLT_SW_UPGRADE_DIR)/change_labels.sh $(ONL_DIR)/OpenNetworkLinux/bal_packages
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530369
370 # Rebuild ONL packed with already built BAL+Openolt debian package
371 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=y
372 echo "inband=y" > $(ONL_DIR)/onl_build.mode
373 make inband-onl-cleanup
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400374# requires 'sudo' privileges
375
376ansible:
377 (ONL_INSTALLED_INSTALLER="$(shell find "$$(cd ./build/onl/OpenNetworkLinux/RELEASE/jessie/amd64; pwd)" -name "ONL-onl-*_AMD64_INSTALLED_INSTALLER")"; \
378 rm -rf $(ANSIBLE_DIR)/roles/upgrade/files; \
379 mkdir -p $(ANSIBLE_DIR)/roles/upgrade/files; \
380 cp ../olt-sw-upgrade/install_onl.sh $(ANSIBLE_DIR)/roles/upgrade/files; \
381 chmod +x $(ANSIBLE_DIR)/roles/upgrade/files/*.sh; \
382 ln -s $$ONL_INSTALLED_INSTALLER $(ANSIBLE_DIR)/roles/upgrade/files/ONL_INSTALLED_INSTALLER)
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530383
Shad Ansari01b0e652018-04-05 21:02:53 +0000384src/%.o: %.cpp
385 $(CXX) -MMD -c $< -o $@
386
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000387rxtx-power: clean-rxtx-power
388 $(CXX) -std=c++11 -DRXTX_POWER_EXE_MODE src/trx_eeprom_reader.cc -o $(RXTX_POWER_EXE) && ls -l $(RXTX_POWER_EXE)
389
390deb-cleanup: clean-rxtx-power
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000391 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log
392 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper
393 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper
394 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars
395 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/
396 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp
Girish Gowdra252f4972020-09-07 21:24:01 -0700397 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libz.so.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000398 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6
399 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api.so
400 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/
401 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt
Jason Huang09b73ea2020-01-08 17:52:05 +0800402 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000403 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/
404 @rm -f device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000405 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(RXTX_POWER_EXE)
Shad Ansaricc01de12018-05-21 22:54:45 +0000406
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530407inband-onl-cleanup:
408 @rm -f $(ONL_DIR)/OpenNetworkLinux/*.patch
409 @rm -rf $(ONL_DIR)/OpenNetworkLinux/bal_packages
410
Shad Ansaricb004c52018-05-30 18:07:23 +0000411clean: protos-clean deb-cleanup
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000412 @rm -f $(OBJS) $(DEPS)
413 @rm -rf $(OPENOLT_PROTOS_DIR)/googleapis
Girish Gowdra252f4972020-09-07 21:24:01 -0700414 @rm -f $(BUILD_DIR)/libz.so.1
Girish Gowdraab7ea552020-01-07 13:25:15 +0530415 @rm -f $(BUILD_DIR)/libbal_host_api.so
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000416 @rm -f $(BUILD_DIR)/openolt
Girish Gowdraab7ea552020-01-07 13:25:15 +0530417 @rm -f $(BUILD_DIR)/dev_mgmt_daemon
Jason Huang09b73ea2020-01-08 17:52:05 +0800418 @rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Girish Gowdrabc6e0852020-03-26 11:36:12 -0700419 @rm -f $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansari19249582018-04-30 04:31:00 +0000420
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000421clean-src: protos-clean
422 @rm -f $(OBJS) $(DEPS)
423
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000424clean-rxtx-power:
425 @rm -f src/$(RXTX_POWER_EXE)
426 @rm -f $(RXTX_POWER_EXE)
427
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000428distclean: clean-src clean
429 @rm -rf $(BUILD_DIR)
Shad Ansaricb004c52018-05-30 18:07:23 +0000430
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400431.PHONY: onl sdk bal protos inband-onl ansible .FORCE