blob: dba313178fb95145e137ea0b72ffd0cb8f6764de [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 Subramani3e8bfd92021-04-26 15:07:14 +053032BAL_REV_B_VER != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then echo "8"; else echo "6"; fi
33BAL_API_REV_B_VER = 6
34BAL_API_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_API_REV_B_VER)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000035BAL_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER)
36SDK_VER = 6.5.13
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053037DEV_VER != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then echo "20210420"; else echo "202012040101"; fi
Shad Ansari01b0e652018-04-05 21:02:53 +000038#
39# Version of Open Network Linux (ONL).
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053040ONL_KERN_VER_MAJOR != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then echo "4.19"; else echo "4.14"; fi
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000041
42# OpenOLT Proto version.
43# This specifies the GIT tag in https://github.com/opencord/voltha-protos
44# repo that we need to refer to, to pick the right version of
45# openolt.proto and tech_profile.proto
Orhan Kupusogluec57af02021-05-12 12:38:17 +000046OPENOLT_PROTO_VER ?= v4.1.5
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000047
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +053048# Variables used for Inband build
49INBAND = "n"
50VLAN_ID = 4093
51
Jason Huangdc83ba72020-11-16 22:08:43 +080052# NNI ports speed setting
53PORT_100G_SPEED ?= 100000
54PORT_25G_SPEED ?= 25000
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053055PORT_40G_SPEED ?= 40g
56PORT_10G_SPEED ?= 10g
Jason Huangdc83ba72020-11-16 22:08:43 +080057
Shad Ansari01b0e652018-04-05 21:02:53 +000058# Build directory
59BUILD_DIR = build
Girish Gowdraddf9a162020-01-27 12:56:27 +053060
Orhan Kupusogluec57af02021-05-12 12:38:17 +000061# Rx optical power test app
62RXTX_POWER_EXE = read_rxtx_power
63
Girish Gowdra252f4972020-09-07 21:24:01 -070064# initialiaze path of protoc binary
Girish Gowdra489425a2020-02-22 13:07:42 +053065protoc-bin = $(shell which protoc)
Girish Gowdraddf9a162020-01-27 12:56:27 +053066
Girish Gowdra252f4972020-09-07 21:24:01 -070067# initialiaze path of grpc_cpp_plugin binary
Girish Gowdra489425a2020-02-22 13:07:42 +053068grpc-cpp-plugin-bin = $(shell which grpc_cpp_plugin)
Shad Ansari2cddc552018-06-26 20:34:27 +000069
70USER := $(shell echo $(USER))
Luca Pretee75aaa52018-04-13 12:19:12 -070071#
Shad Ansari01b0e652018-04-05 21:02:53 +000072########################################################################
73##
74##
Girish Gowdra252f4972020-09-07 21:24:01 -070075## Initialize various build flags
Shad Ansari01b0e652018-04-05 21:02:53 +000076##
77##
78HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
79SYSTEM ?= $(HOST_SYSTEM)
Luca Pretee75aaa52018-04-13 12:19:12 -070080
Humera Kouser5ac56612019-07-25 20:23:01 -040081VERSION ?= $(shell cat ../VERSION)
82
83#set ref and commit date only if committed
84LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
85LABEL_VCS_REF = $(shell git rev-parse HEAD)
86LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
87LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD)
88
Craig Lutgenf040dba2018-09-27 11:21:43 -050089LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g)
Girish Gowdra252f4972020-09-07 21:24:01 -070090LIBZ_PATH=$(shell pkg-config --libs-only-L zlib | sed s/-L// | sed s/\ //g)
Craig Lutgenf040dba2018-09-27 11:21:43 -050091LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g)
92
Girish Gowdra1935e6a2020-10-31 21:48:22 -070093PCAPPLUSPLUS_INCLUDE_PATH=-I/usr/local/include/pcapplusplus/
94PCAPPLUSPLUS_LIB_PATH=-lPcap++ -lPacket++ -lCommon++
95
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +053096CXX != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then echo "@CXX@-6"; else echo "@CXX@-4.9"; fi
Craig Lutgenf040dba2018-09-27 11:21:43 -050097CXXFLAGS += @CXXFLAGS@
98CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++)
Girish Gowdra1935e6a2020-10-31 21:48:22 -070099CXXFLAGS += $(PCAPPLUSPLUS_INCLUDE_PATH)
Humera Kouser5ac56612019-07-25 20:23:01 -0400100CPPFLAGS += @CPPFLAGS@
Shad Ansari01b0e652018-04-05 21:02:53 +0000101CPPFLAGS += `pkg-config --cflags protobuf grpc`
Girish Gowdra252f4972020-09-07 21:24:01 -0700102
103# Enabling SCALE_AND_PERF for higher performance and scaling to 512 subscribers. Enabling the flag will
104# disable the handling in FLOW_CHECKER and also disable flow statistics
105# Setting SW_UTIL_SHELL=y will enable QAX debug shell when compiling for Broadcom chip based OLT
Humera Kouser5ac56612019-07-25 20:23:01 -0400106CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBAL_VER=\"$(BAL_VER)\" -DLABEL_VCS_URL=\"$(LABEL_VCS_URL)\" \
107 -DLABEL_VCS_REF=\"$(LABEL_VCS_REF)\" -DLABEL_BUILD_DATE=\"$(LABEL_BUILD_DATE)\" \
Girish Gowdra252f4972020-09-07 21:24:01 -0700108 -DLABEL_COMMIT_DATE=\"$(LABEL_COMMIT_DATE)\" -DFLOW_CHECKER -USCALE_AND_PERF -DSW_UTIL_SHELL=n
Humera Kouser6143c9e2020-06-17 22:37:31 +0530109CPPFLAGS += -I./
Craig Lutgen7ebee132018-11-16 15:31:11 -0600110CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix
Craig Lutgenf040dba2018-09-27 11:21:43 -0500111LDFLAGS += @LDFLAGS@
112LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr
Shad Ansari9acc9732018-10-30 18:01:44 +0000113CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic
Craig Lutgenf040dba2018-09-27 11:21:43 -0500114
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000115export CXX CXXFLAGS OPENOLT_PROTO_VER
Luca Pretee75aaa52018-04-13 12:19:12 -0700116
Shad Ansari01b0e652018-04-05 21:02:53 +0000117########################################################################
118##
119##
Luca Pretee75aaa52018-04-13 12:19:12 -0700120## ONL
Shad Ansari01b0e652018-04-05 21:02:53 +0000121##
122##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000123ONL_REPO = onl
Shad Ansari01b0e652018-04-05 21:02:53 +0000124ONL_DIR = $(BUILD_DIR)/$(ONL_REPO)
Shad Ansari01b0e652018-04-05 21:02:53 +0000125onl:
126 if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \
127 mkdir -p $(ONL_DIR); \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000128 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \
129 cp download/Makefile.onl $(ONL_DIR)/Makefile; \
130 install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530131 if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then \
132 cp $(TOP_DIR)/device/$(OPENOLTDEVICE)/update_kernel_options.sh $(ONL_DIR)/OpenNetworkLinux/.; \
133 chmod 0755 $(ONL_DIR)/OpenNetworkLinux/update_kernel_options.sh; \
134 fi; \
135 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n BOARD=$(OPENOLTDEVICE); \
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530136 else \
137 if [ "$(INBAND)" = n -a "$$(grep "inband" $(ONL_DIR)/onl_build.mode | cut -d= -f 2)" = y ]; then \
138 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \
139 fi; \
Shad Ansari01b0e652018-04-05 21:02:53 +0000140 fi;
141onl-force:
Shad Ansari9acc9732018-10-30 18:01:44 +0000142 make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR)
Shad Ansari01b0e652018-04-05 21:02:53 +0000143distclean-onl:
144 sudo rm -rf $(ONL_DIR)
145
146########################################################################
147##
148##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000149## Broadcom LIBRARY APIs
150##
151##
152BAL_API_DIR = $(BUILD_DIR)/bal-api-$(BAL_API_VER)
153
154bal-api-$(BAL_API_VER):
155 if [ ! -d "$(BAL_API_DIR)" ]; then \
156 mkdir -p $(BAL_API_DIR); \
157 git clone https://github.com/balapi/bal-api-$(BAL_API_VER).git $(BAL_API_DIR); \
158 fi;
159bal-api-clean:
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530160 rm -rf $(BAL_API_DIR)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000161
162########################################################################
163##
164##
Luca Pretee75aaa52018-04-13 12:19:12 -0700165## BAL
Shad Ansari01b0e652018-04-05 21:02:53 +0000166##
167##
Jason Huang09b73ea2020-01-08 17:52:05 +0800168BAL_ZIP = SW-BCM686OLT_$(subst .,_,$(BAL_VER)).tgz
Shad Ansari01b0e652018-04-05 21:02:53 +0000169SDK_ZIP = sdk-all-$(SDK_VER).tar.gz
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530170PATCH_FILE != if [ "$(OPENOLTDEVICE)" = "phoenix" ]; then \
171 echo "PHOENIX_BAL_$(BAL_VER)_V$(DEV_VER).patch"; else \
172 echo "ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch"; fi
Shad Ansari9acc9732018-10-30 18:01:44 +0000173BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000174BCM_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER)
175BALLIBDIR = $(BAL_DIR)/build/host_reference/host_api
176BALLIBNAME = bal_host_api
177BAL_INC = -I$(BAL_DIR)/host_driver/bal/bal_include \
178 -I$(BAL_DIR)/host_driver/topology \
179 -I$(BAL_DIR)/host_driver/utils \
180 -I$(BAL_DIR)/host_driver/api \
Jason Huangc6362792020-03-04 16:33:19 +0800181 -I$(BAL_DIR)/host_driver/metadata \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000182 -I$(BAL_DIR)/host_customized/os_abstraction \
183 -I$(BAL_DIR)/host_customized/os_abstraction/posix \
184 -I$(BAL_DIR)/host_customized/config \
185 -I$(BAL_DIR)/host_driver/api_conn_mgr \
186 -I$(BAL_DIR)/host_driver/conn_mgr \
187 -I$(BAL_DIR)/host_driver/api/host/topology \
188 -I$(BAL_DIR)/host_reference/cli \
189 -I$(BAL_DIR)/host_reference/api_cli \
190 -I$(BAL_API_DIR)/include \
191 -I$(BAL_API_DIR)/include/object_model
Shad Ansari01b0e652018-04-05 21:02:53 +0000192CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000193CXXFLAGS += -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 +0800194PORT_SPEED_FILE = $(BAL_DIR)/switch_sdk/$(SDK_VER)/rc/$(OPENOLTDEVICE)/board_files/broadcom/port_speed.soc
Shad Ansaricb004c52018-05-30 18:07:23 +0000195
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000196sdk: onl bal-api-$(BAL_API_VER)
Shad Ansari01b0e652018-04-05 21:02:53 +0000197ifeq ("$(wildcard $(BAL_DIR))","")
198 mkdir $(BAL_DIR)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000199 tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR)
Shad Ansari01b0e652018-04-05 21:02:53 +0000200 cp download/$(SDK_ZIP) $(BCM_SDK)
201 chmod -R 744 $(BAL_DIR)
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530202 cat download/$(PATCH_FILE) | patch -p1 -d $(BAL_DIR)
Jason Huangdc83ba72020-11-16 22:08:43 +0800203ifeq ("$(strip $(OPENOLTDEVICE))","asfvolt16")
204 echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
205else ifeq ("$(strip $(OPENOLTDEVICE))","asgvolt64")
206 echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE)
207 echo "setenv port_speed_for_25 $(PORT_25G_SPEED)" >> $(PORT_SPEED_FILE)
208endif
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530209ifeq ("$(strip $(OPENOLTDEVICE))","phoenix")
210 chmod 0755 $(BAL_DIR)/onu_mgmt/libomcistack/me_codegen/omci_stack_codegen
211 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux ONL_DEBIAN_SUITE=$(shell lsb_release -c -s) OPEN_SOURCE=y
212else
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000213 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux OPEN_SOURCE=y
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530214endif
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000215 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
Shad Ansari01b0e652018-04-05 21:02:53 +0000216endif
Shad Ansaricb004c52018-05-30 18:07:23 +0000217
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000218bal-release: sdk
219 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
Shad Ansaricb004c52018-05-30 18:07:23 +0000220
221bal-clean:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000222 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all
Shad Ansari01b0e652018-04-05 21:02:53 +0000223
224########################################################################
225##
226##
Luca Pretee75aaa52018-04-13 12:19:12 -0700227## OpenOLT API
Shad Ansari01b0e652018-04-05 21:02:53 +0000228##
229##
Shad Ansari56c8ea42018-10-30 19:34:35 +0000230OPENOLT_PROTOS_DIR = ../protos
Shad Ansari19249582018-04-30 04:31:00 +0000231OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a
Girish Gowdra252f4972020-09-07 21:24:01 -0700232CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I./device -I./device/$(OPENOLTDEVICE) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens
Shad Ansari19249582018-04-30 04:31:00 +0000233protos:
234 make -C $(OPENOLT_PROTOS_DIR) all
Shad Ansaricc01de12018-05-21 22:54:45 +0000235protos-clean:
Shad Ansari19249582018-04-30 04:31:00 +0000236 -make -C $(OPENOLT_PROTOS_DIR) clean
Shad Ansari01b0e652018-04-05 21:02:53 +0000237
238########################################################################
239##
240##
Shad Ansari627b5782018-08-13 22:49:32 +0000241## common
Shad Ansari7193ae22018-08-08 22:23:18 +0000242##
243##
Girish Gowdrafe649702019-10-30 12:49:58 +0530244
245# A hack to force a re-build of common/main.cc everytime.
246# This is needed to bake in the git VCS information in the openolt binary
247# at the time of building the openolt package.
248common/main.o: .FORCE
249.FORCE:
250 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c common/main.cc -o common/main.o
251
Shad Ansari627b5782018-08-13 22:49:32 +0000252common/%.o: common/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400253 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari7193ae22018-08-08 22:23:18 +0000254
255########################################################################
256##
257##
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500258## device
259##
260##
Shad Ansari9acc9732018-10-30 18:01:44 +0000261device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500262 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
263
264device/generic/%.o: device/generic/%.cc
265 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
266
267########################################################################
268##
269##
Shad Ansari627b5782018-08-13 22:49:32 +0000270## openolt
271##
272##
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400273OLT_SW_UPGRADE_DIR = ../olt-sw-upgrade
Shad Ansari9acc9732018-10-30 18:01:44 +0000274SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc)
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400275ANSIBLE_DIR = /etc/ansible
Shad Ansari01b0e652018-04-05 21:02:53 +0000276OBJS = $(SRCS:.cc=.o)
277DEPS = $(SRCS:.cc=.d)
278.DEFAULT_GOAL := all
Shad Ansari2ae27672019-05-09 00:26:34 +0000279all: $(BUILD_DIR)/openolt
Shad Ansaricb004c52018-05-30 18:07:23 +0000280$(BUILD_DIR)/openolt: sdk protos $(OBJS)
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700281 $(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 Subramani3e8bfd92021-04-26 15:07:14 +0530282ifeq ("$(strip $(OPENOLTDEVICE))","phoenix")
283 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
284else
Jason Huang09b73ea2020-01-08 17:52:05 +0800285 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 +0530286endif
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000287 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_reference/host_api/strip/libbal_host_api.so $(BUILD_DIR)/.
288 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_driver/dev_mgmt_daemon/dev_mgmt_daemon $(BUILD_DIR)/.
Girish Gowdra252f4972020-09-07 21:24:01 -0700289 ln -sf $(LIBGRPC_PATH)/libz.so.1 $(BUILD_DIR)/libz.so.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000290 ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6
291 strip $(BUILD_DIR)/openolt
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530292 echo "inband=n" > $(ONL_DIR)/onl_build.mode
293 if [ $(INBAND) = y ]; then \
294 echo "Building ONL+BAL+OpenoltAgent allinone image"; \
295 make deb; \
296 make inband-onl; \
297 fi;
298
Shad Ansari627b5782018-08-13 22:49:32 +0000299src/%.o: src/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400300 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari01b0e652018-04-05 21:02:53 +0000301
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000302deb: rxtx-power
Jason Huang09b73ea2020-01-08 17:52:05 +0800303 cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000304 cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian
Girish Gowdra252f4972020-09-07 21:24:01 -0700305 cp $(BUILD_DIR)/libz.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000306 cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
307 cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian
308 cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000309 cp -a $(RXTX_POWER_EXE) device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530310ifeq ("$(strip $(OPENOLTDEVICE))","phoenix")
311 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
312endif
Girish Gowdra6e745522020-07-15 15:52:13 -0700313 cp -a scripts/watchdog device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000314 cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
Thiyagarajan Subramani3e8bfd92021-04-26 15:07:14 +0530315 mv device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansaricb004c52018-05-30 18:07:23 +0000316 make deb-cleanup
Shad Ansari6cd46a62018-05-13 23:20:51 +0000317
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530318inband-onl:
319 # Clean previous ONL build and build freshly
320 sudo rm -rf $(ONL_DIR)
321 mkdir -p $(ONL_DIR)
322 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux
323 cp download/Makefile.onl $(ONL_DIR)/Makefile
324 install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux
325
326 # Check ONL commit equals to Inband patch commit
327 ONL_COMMIT_ID=$(awk \'/COMMIT_ID = /{print $0}\' $(ONL_DIR)/Makefile | awk -F \"=\" \'{print $2}\')
328 INBAND_PATCH_COMMIT_ID=$(echo cp $(TOP_DIR)/inband/patch/*.patch | cut -d- -f 2 | cut -d. -f 1)
329 if [ "$(ONL_COMMIT_ID)" = "$(INBAND_PATCH_COMMIT_ID)" ]; then \
330 echo "ONL commit and inband patch commit matched."; \
331 cp $(TOP_DIR)/inband/patch/*.patch $(ONL_DIR)/OpenNetworkLinux; \
332 else \
333 echo "ONL commit and inband patch commit does not match. Exiting."; \
334 exit 1; \
335 fi;
336
Girish Gowdra6e745522020-07-15 15:52:13 -0700337 # Update inband.config file with VLAN ID argument passed
338 sed -i 's/asfvolt16_vlan_id_eth2=.*/asfvolt16_vlan_id_eth2=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config
339 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 +0530340
341 # Copy Inband config files and olt startup scripts to ONL source code and build
342 cd $(TOP_DIR) && mkdir -p $(ONL_DIR)/OpenNetworkLinux/bal_packages
343 cp $(TOP_DIR)/inband/scripts/* $(ONL_DIR)/OpenNetworkLinux/bal_packages
Girish Gowdra6e745522020-07-15 15:52:13 -0700344 cp $(TOP_DIR)/inband/config/inband.config $(ONL_DIR)/OpenNetworkLinux/bal_packages
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530345 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 -0400346 cp $(OLT_SW_UPGRADE_DIR)/change_labels.sh $(ONL_DIR)/OpenNetworkLinux/bal_packages
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530347
348 # Rebuild ONL packed with already built BAL+Openolt debian package
349 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=y
350 echo "inband=y" > $(ONL_DIR)/onl_build.mode
351 make inband-onl-cleanup
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400352# requires 'sudo' privileges
353
354ansible:
355 (ONL_INSTALLED_INSTALLER="$(shell find "$$(cd ./build/onl/OpenNetworkLinux/RELEASE/jessie/amd64; pwd)" -name "ONL-onl-*_AMD64_INSTALLED_INSTALLER")"; \
356 rm -rf $(ANSIBLE_DIR)/roles/upgrade/files; \
357 mkdir -p $(ANSIBLE_DIR)/roles/upgrade/files; \
358 cp ../olt-sw-upgrade/install_onl.sh $(ANSIBLE_DIR)/roles/upgrade/files; \
359 chmod +x $(ANSIBLE_DIR)/roles/upgrade/files/*.sh; \
360 ln -s $$ONL_INSTALLED_INSTALLER $(ANSIBLE_DIR)/roles/upgrade/files/ONL_INSTALLED_INSTALLER)
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530361
Shad Ansari01b0e652018-04-05 21:02:53 +0000362src/%.o: %.cpp
363 $(CXX) -MMD -c $< -o $@
364
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000365rxtx-power: clean-rxtx-power
366 $(CXX) -std=c++11 -DRXTX_POWER_EXE_MODE src/trx_eeprom_reader.cc -o $(RXTX_POWER_EXE) && ls -l $(RXTX_POWER_EXE)
367
368deb-cleanup: clean-rxtx-power
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000369 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log
370 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper
371 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper
372 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars
373 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/
374 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp
Girish Gowdra252f4972020-09-07 21:24:01 -0700375 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libz.so.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000376 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6
377 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api.so
378 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/
379 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt
Jason Huang09b73ea2020-01-08 17:52:05 +0800380 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000381 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/
382 @rm -f device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000383 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(RXTX_POWER_EXE)
Shad Ansaricc01de12018-05-21 22:54:45 +0000384
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530385inband-onl-cleanup:
386 @rm -f $(ONL_DIR)/OpenNetworkLinux/*.patch
387 @rm -rf $(ONL_DIR)/OpenNetworkLinux/bal_packages
388
Shad Ansaricb004c52018-05-30 18:07:23 +0000389clean: protos-clean deb-cleanup
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000390 @rm -f $(OBJS) $(DEPS)
391 @rm -rf $(OPENOLT_PROTOS_DIR)/googleapis
Girish Gowdra252f4972020-09-07 21:24:01 -0700392 @rm -f $(BUILD_DIR)/libz.so.1
Girish Gowdraab7ea552020-01-07 13:25:15 +0530393 @rm -f $(BUILD_DIR)/libbal_host_api.so
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000394 @rm -f $(BUILD_DIR)/openolt
Girish Gowdraab7ea552020-01-07 13:25:15 +0530395 @rm -f $(BUILD_DIR)/dev_mgmt_daemon
Jason Huang09b73ea2020-01-08 17:52:05 +0800396 @rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Girish Gowdrabc6e0852020-03-26 11:36:12 -0700397 @rm -f $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansari19249582018-04-30 04:31:00 +0000398
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000399clean-src: protos-clean
400 @rm -f $(OBJS) $(DEPS)
401
Orhan Kupusogluec57af02021-05-12 12:38:17 +0000402clean-rxtx-power:
403 @rm -f src/$(RXTX_POWER_EXE)
404 @rm -f $(RXTX_POWER_EXE)
405
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000406distclean: clean-src clean
407 @rm -rf $(BUILD_DIR)
Shad Ansaricb004c52018-05-30 18:07:23 +0000408
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400409.PHONY: onl sdk bal protos inband-onl ansible .FORCE