blob: 7512d1e0102edaf45636ee4d40b220116a240d7f [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 Gowdra3b0ae452020-09-28 10:53:18 -070031BAL_REV_A_VER = 7
32BAL_REV_B_VER = 5
Jason Huang09b73ea2020-01-08 17:52:05 +080033BAL_API_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000034BAL_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER)
35SDK_VER = 6.5.13
Girish Gowdra3b0ae452020-09-28 10:53:18 -070036DEV_VER ?= 202008030101
Shad Ansari01b0e652018-04-05 21:02:53 +000037#
38# Version of Open Network Linux (ONL).
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000039ONL_KERN_VER_MAJOR = 4.14
40
41# OpenOLT Proto version.
42# This specifies the GIT tag in https://github.com/opencord/voltha-protos
43# repo that we need to refer to, to pick the right version of
44# openolt.proto and tech_profile.proto
Girish Gowdra252f4972020-09-07 21:24:01 -070045OPENOLT_PROTO_VER ?= v4.0.2
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000046
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +053047# Variables used for Inband build
48INBAND = "n"
49VLAN_ID = 4093
50
Shad Ansari01b0e652018-04-05 21:02:53 +000051#
52# Build directory
53BUILD_DIR = build
Girish Gowdraddf9a162020-01-27 12:56:27 +053054
Girish Gowdra252f4972020-09-07 21:24:01 -070055# initialiaze path of protoc binary
Girish Gowdra489425a2020-02-22 13:07:42 +053056protoc-bin = $(shell which protoc)
Girish Gowdraddf9a162020-01-27 12:56:27 +053057
Girish Gowdra252f4972020-09-07 21:24:01 -070058# initialiaze path of grpc_cpp_plugin binary
Girish Gowdra489425a2020-02-22 13:07:42 +053059grpc-cpp-plugin-bin = $(shell which grpc_cpp_plugin)
Shad Ansari2cddc552018-06-26 20:34:27 +000060
61USER := $(shell echo $(USER))
Luca Pretee75aaa52018-04-13 12:19:12 -070062#
Shad Ansari01b0e652018-04-05 21:02:53 +000063########################################################################
64##
65##
Girish Gowdra252f4972020-09-07 21:24:01 -070066## Initialize various build flags
Shad Ansari01b0e652018-04-05 21:02:53 +000067##
68##
69HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
70SYSTEM ?= $(HOST_SYSTEM)
Luca Pretee75aaa52018-04-13 12:19:12 -070071
Humera Kouser5ac56612019-07-25 20:23:01 -040072VERSION ?= $(shell cat ../VERSION)
73
74#set ref and commit date only if committed
75LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
76LABEL_VCS_REF = $(shell git rev-parse HEAD)
77LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
78LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD)
79
Craig Lutgenf040dba2018-09-27 11:21:43 -050080LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g)
Girish Gowdra252f4972020-09-07 21:24:01 -070081LIBZ_PATH=$(shell pkg-config --libs-only-L zlib | sed s/-L// | sed s/\ //g)
Craig Lutgenf040dba2018-09-27 11:21:43 -050082LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g)
83
Girish Gowdra1935e6a2020-10-31 21:48:22 -070084PCAPPLUSPLUS_INCLUDE_PATH=-I/usr/local/include/pcapplusplus/
85PCAPPLUSPLUS_LIB_PATH=-lPcap++ -lPacket++ -lCommon++
86
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000087CXX = @CXX@-4.9
Craig Lutgenf040dba2018-09-27 11:21:43 -050088CXXFLAGS += @CXXFLAGS@
89CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++)
Girish Gowdra1935e6a2020-10-31 21:48:22 -070090CXXFLAGS += $(PCAPPLUSPLUS_INCLUDE_PATH)
Humera Kouser5ac56612019-07-25 20:23:01 -040091CPPFLAGS += @CPPFLAGS@
Shad Ansari01b0e652018-04-05 21:02:53 +000092CPPFLAGS += `pkg-config --cflags protobuf grpc`
Girish Gowdra252f4972020-09-07 21:24:01 -070093
94# Enabling SCALE_AND_PERF for higher performance and scaling to 512 subscribers. Enabling the flag will
95# disable the handling in FLOW_CHECKER and also disable flow statistics
96# Setting SW_UTIL_SHELL=y will enable QAX debug shell when compiling for Broadcom chip based OLT
Humera Kouser5ac56612019-07-25 20:23:01 -040097CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBAL_VER=\"$(BAL_VER)\" -DLABEL_VCS_URL=\"$(LABEL_VCS_URL)\" \
98 -DLABEL_VCS_REF=\"$(LABEL_VCS_REF)\" -DLABEL_BUILD_DATE=\"$(LABEL_BUILD_DATE)\" \
Girish Gowdra252f4972020-09-07 21:24:01 -070099 -DLABEL_COMMIT_DATE=\"$(LABEL_COMMIT_DATE)\" -DFLOW_CHECKER -USCALE_AND_PERF -DSW_UTIL_SHELL=n
Humera Kouser6143c9e2020-06-17 22:37:31 +0530100CPPFLAGS += -I./
Craig Lutgen7ebee132018-11-16 15:31:11 -0600101CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix
Craig Lutgenf040dba2018-09-27 11:21:43 -0500102LDFLAGS += @LDFLAGS@
103LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr
Shad Ansari9acc9732018-10-30 18:01:44 +0000104CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic
Craig Lutgenf040dba2018-09-27 11:21:43 -0500105
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000106export CXX CXXFLAGS OPENOLT_PROTO_VER
Luca Pretee75aaa52018-04-13 12:19:12 -0700107
Shad Ansari01b0e652018-04-05 21:02:53 +0000108########################################################################
109##
110##
Luca Pretee75aaa52018-04-13 12:19:12 -0700111## ONL
Shad Ansari01b0e652018-04-05 21:02:53 +0000112##
113##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000114ONL_REPO = onl
Shad Ansari01b0e652018-04-05 21:02:53 +0000115ONL_DIR = $(BUILD_DIR)/$(ONL_REPO)
Shad Ansari01b0e652018-04-05 21:02:53 +0000116onl:
117 if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \
118 mkdir -p $(ONL_DIR); \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000119 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \
120 cp download/Makefile.onl $(ONL_DIR)/Makefile; \
121 install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530122 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \
123 else \
124 if [ "$(INBAND)" = n -a "$$(grep "inband" $(ONL_DIR)/onl_build.mode | cut -d= -f 2)" = y ]; then \
125 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \
126 fi; \
Shad Ansari01b0e652018-04-05 21:02:53 +0000127 fi;
128onl-force:
Shad Ansari9acc9732018-10-30 18:01:44 +0000129 make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR)
Shad Ansari01b0e652018-04-05 21:02:53 +0000130distclean-onl:
131 sudo rm -rf $(ONL_DIR)
132
133########################################################################
134##
135##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000136## Broadcom LIBRARY APIs
137##
138##
139BAL_API_DIR = $(BUILD_DIR)/bal-api-$(BAL_API_VER)
140
141bal-api-$(BAL_API_VER):
142 if [ ! -d "$(BAL_API_DIR)" ]; then \
143 mkdir -p $(BAL_API_DIR); \
144 git clone https://github.com/balapi/bal-api-$(BAL_API_VER).git $(BAL_API_DIR); \
145 fi;
146bal-api-clean:
147 rm $(BAL_API_DIR)
148
149########################################################################
150##
151##
Luca Pretee75aaa52018-04-13 12:19:12 -0700152## BAL
Shad Ansari01b0e652018-04-05 21:02:53 +0000153##
154##
Jason Huang09b73ea2020-01-08 17:52:05 +0800155BAL_ZIP = SW-BCM686OLT_$(subst .,_,$(BAL_VER)).tgz
Shad Ansari01b0e652018-04-05 21:02:53 +0000156SDK_ZIP = sdk-all-$(SDK_VER).tar.gz
Craig Lutgenf040dba2018-09-27 11:21:43 -0500157ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch
Shad Ansari9acc9732018-10-30 18:01:44 +0000158BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000159BCM_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER)
160BALLIBDIR = $(BAL_DIR)/build/host_reference/host_api
161BALLIBNAME = bal_host_api
162BAL_INC = -I$(BAL_DIR)/host_driver/bal/bal_include \
163 -I$(BAL_DIR)/host_driver/topology \
164 -I$(BAL_DIR)/host_driver/utils \
165 -I$(BAL_DIR)/host_driver/api \
Jason Huangc6362792020-03-04 16:33:19 +0800166 -I$(BAL_DIR)/host_driver/metadata \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000167 -I$(BAL_DIR)/host_customized/os_abstraction \
168 -I$(BAL_DIR)/host_customized/os_abstraction/posix \
169 -I$(BAL_DIR)/host_customized/config \
170 -I$(BAL_DIR)/host_driver/api_conn_mgr \
171 -I$(BAL_DIR)/host_driver/conn_mgr \
172 -I$(BAL_DIR)/host_driver/api/host/topology \
173 -I$(BAL_DIR)/host_reference/cli \
174 -I$(BAL_DIR)/host_reference/api_cli \
175 -I$(BAL_API_DIR)/include \
176 -I$(BAL_API_DIR)/include/object_model
Shad Ansari01b0e652018-04-05 21:02:53 +0000177CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000178CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST -DENABLE_LOG -DENABLE_CLI
Shad Ansaricb004c52018-05-30 18:07:23 +0000179
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000180sdk: onl bal-api-$(BAL_API_VER)
Shad Ansari01b0e652018-04-05 21:02:53 +0000181ifeq ("$(wildcard $(BAL_DIR))","")
182 mkdir $(BAL_DIR)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000183 tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR)
Shad Ansari01b0e652018-04-05 21:02:53 +0000184 cp download/$(SDK_ZIP) $(BCM_SDK)
185 chmod -R 744 $(BAL_DIR)
186 cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000187 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux OPEN_SOURCE=y
188 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
Shad Ansari01b0e652018-04-05 21:02:53 +0000189endif
Shad Ansaricb004c52018-05-30 18:07:23 +0000190
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000191bal-release: sdk
192 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
Shad Ansaricb004c52018-05-30 18:07:23 +0000193
194bal-clean:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000195 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all
Shad Ansari01b0e652018-04-05 21:02:53 +0000196
197########################################################################
198##
199##
Luca Pretee75aaa52018-04-13 12:19:12 -0700200## OpenOLT API
Shad Ansari01b0e652018-04-05 21:02:53 +0000201##
202##
Shad Ansari56c8ea42018-10-30 19:34:35 +0000203OPENOLT_PROTOS_DIR = ../protos
Shad Ansari19249582018-04-30 04:31:00 +0000204OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a
Girish Gowdra252f4972020-09-07 21:24:01 -0700205CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I./device -I./device/$(OPENOLTDEVICE) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens
Shad Ansari19249582018-04-30 04:31:00 +0000206protos:
207 make -C $(OPENOLT_PROTOS_DIR) all
Shad Ansaricc01de12018-05-21 22:54:45 +0000208protos-clean:
Shad Ansari19249582018-04-30 04:31:00 +0000209 -make -C $(OPENOLT_PROTOS_DIR) clean
Shad Ansari01b0e652018-04-05 21:02:53 +0000210
211########################################################################
212##
213##
Shad Ansari627b5782018-08-13 22:49:32 +0000214## common
Shad Ansari7193ae22018-08-08 22:23:18 +0000215##
216##
Girish Gowdrafe649702019-10-30 12:49:58 +0530217
218# A hack to force a re-build of common/main.cc everytime.
219# This is needed to bake in the git VCS information in the openolt binary
220# at the time of building the openolt package.
221common/main.o: .FORCE
222.FORCE:
223 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c common/main.cc -o common/main.o
224
Shad Ansari627b5782018-08-13 22:49:32 +0000225common/%.o: common/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400226 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari7193ae22018-08-08 22:23:18 +0000227
228########################################################################
229##
230##
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500231## device
232##
233##
Shad Ansari9acc9732018-10-30 18:01:44 +0000234device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500235 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
236
237device/generic/%.o: device/generic/%.cc
238 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
239
240########################################################################
241##
242##
Shad Ansari627b5782018-08-13 22:49:32 +0000243## openolt
244##
245##
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400246OLT_SW_UPGRADE_DIR = ../olt-sw-upgrade
Shad Ansari9acc9732018-10-30 18:01:44 +0000247SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc)
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400248ANSIBLE_DIR = /etc/ansible
Shad Ansari01b0e652018-04-05 21:02:53 +0000249OBJS = $(SRCS:.cc=.o)
250DEPS = $(SRCS:.cc=.d)
251.DEFAULT_GOAL := all
Shad Ansari2ae27672019-05-09 00:26:34 +0000252all: $(BUILD_DIR)/openolt
Shad Ansaricb004c52018-05-30 18:07:23 +0000253$(BUILD_DIR)/openolt: sdk protos $(OBJS)
Girish Gowdra1935e6a2020-10-31 21:48:22 -0700254 $(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)
Jason Huang09b73ea2020-01-08 17:52:05 +0800255 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/.
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000256 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_reference/host_api/strip/libbal_host_api.so $(BUILD_DIR)/.
257 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_driver/dev_mgmt_daemon/dev_mgmt_daemon $(BUILD_DIR)/.
Girish Gowdra252f4972020-09-07 21:24:01 -0700258 ln -sf $(LIBGRPC_PATH)/libz.so.1 $(BUILD_DIR)/libz.so.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000259 ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6
260 strip $(BUILD_DIR)/openolt
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530261 echo "inband=n" > $(ONL_DIR)/onl_build.mode
262 if [ $(INBAND) = y ]; then \
263 echo "Building ONL+BAL+OpenoltAgent allinone image"; \
264 make deb; \
265 make inband-onl; \
266 fi;
267
Shad Ansari627b5782018-08-13 22:49:32 +0000268src/%.o: src/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400269 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari01b0e652018-04-05 21:02:53 +0000270
Shad Ansari6cd46a62018-05-13 23:20:51 +0000271deb:
Jason Huang09b73ea2020-01-08 17:52:05 +0800272 cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000273 cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian
Girish Gowdra252f4972020-09-07 21:24:01 -0700274 cp $(BUILD_DIR)/libz.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000275 cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
276 cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian
277 cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian
Girish Gowdra6e745522020-07-15 15:52:13 -0700278 cp -a scripts/watchdog device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000279 cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
Girish Gowdrabc6e0852020-03-26 11:36:12 -0700280 mv device/$(OPENOLTDEVICE)/*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansaricb004c52018-05-30 18:07:23 +0000281 make deb-cleanup
Shad Ansari6cd46a62018-05-13 23:20:51 +0000282
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530283inband-onl:
284 # Clean previous ONL build and build freshly
285 sudo rm -rf $(ONL_DIR)
286 mkdir -p $(ONL_DIR)
287 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux
288 cp download/Makefile.onl $(ONL_DIR)/Makefile
289 install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux
290
291 # Check ONL commit equals to Inband patch commit
292 ONL_COMMIT_ID=$(awk \'/COMMIT_ID = /{print $0}\' $(ONL_DIR)/Makefile | awk -F \"=\" \'{print $2}\')
293 INBAND_PATCH_COMMIT_ID=$(echo cp $(TOP_DIR)/inband/patch/*.patch | cut -d- -f 2 | cut -d. -f 1)
294 if [ "$(ONL_COMMIT_ID)" = "$(INBAND_PATCH_COMMIT_ID)" ]; then \
295 echo "ONL commit and inband patch commit matched."; \
296 cp $(TOP_DIR)/inband/patch/*.patch $(ONL_DIR)/OpenNetworkLinux; \
297 else \
298 echo "ONL commit and inband patch commit does not match. Exiting."; \
299 exit 1; \
300 fi;
301
Girish Gowdra6e745522020-07-15 15:52:13 -0700302 # Update inband.config file with VLAN ID argument passed
303 sed -i 's/asfvolt16_vlan_id_eth2=.*/asfvolt16_vlan_id_eth2=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config
304 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 +0530305
306 # Copy Inband config files and olt startup scripts to ONL source code and build
307 cd $(TOP_DIR) && mkdir -p $(ONL_DIR)/OpenNetworkLinux/bal_packages
308 cp $(TOP_DIR)/inband/scripts/* $(ONL_DIR)/OpenNetworkLinux/bal_packages
Girish Gowdra6e745522020-07-15 15:52:13 -0700309 cp $(TOP_DIR)/inband/config/inband.config $(ONL_DIR)/OpenNetworkLinux/bal_packages
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530310 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 -0400311 cp $(OLT_SW_UPGRADE_DIR)/change_labels.sh $(ONL_DIR)/OpenNetworkLinux/bal_packages
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530312
313 # Rebuild ONL packed with already built BAL+Openolt debian package
314 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=y
315 echo "inband=y" > $(ONL_DIR)/onl_build.mode
316 make inband-onl-cleanup
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400317# requires 'sudo' privileges
318
319ansible:
320 (ONL_INSTALLED_INSTALLER="$(shell find "$$(cd ./build/onl/OpenNetworkLinux/RELEASE/jessie/amd64; pwd)" -name "ONL-onl-*_AMD64_INSTALLED_INSTALLER")"; \
321 rm -rf $(ANSIBLE_DIR)/roles/upgrade/files; \
322 mkdir -p $(ANSIBLE_DIR)/roles/upgrade/files; \
323 cp ../olt-sw-upgrade/install_onl.sh $(ANSIBLE_DIR)/roles/upgrade/files; \
324 chmod +x $(ANSIBLE_DIR)/roles/upgrade/files/*.sh; \
325 ln -s $$ONL_INSTALLED_INSTALLER $(ANSIBLE_DIR)/roles/upgrade/files/ONL_INSTALLED_INSTALLER)
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530326
Shad Ansari01b0e652018-04-05 21:02:53 +0000327src/%.o: %.cpp
328 $(CXX) -MMD -c $< -o $@
329
Shad Ansaricb004c52018-05-30 18:07:23 +0000330deb-cleanup:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000331 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log
332 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper
333 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper
334 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars
335 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/
336 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp
Girish Gowdra252f4972020-09-07 21:24:01 -0700337 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libz.so.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000338 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6
339 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api.so
340 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/
341 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt
Jason Huang09b73ea2020-01-08 17:52:05 +0800342 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000343 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/
344 @rm -f device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes
Shad Ansaricc01de12018-05-21 22:54:45 +0000345
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530346inband-onl-cleanup:
347 @rm -f $(ONL_DIR)/OpenNetworkLinux/*.patch
348 @rm -rf $(ONL_DIR)/OpenNetworkLinux/bal_packages
349
Shad Ansaricb004c52018-05-30 18:07:23 +0000350clean: protos-clean deb-cleanup
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000351 @rm -f $(OBJS) $(DEPS)
352 @rm -rf $(OPENOLT_PROTOS_DIR)/googleapis
Girish Gowdra252f4972020-09-07 21:24:01 -0700353 @rm -f $(BUILD_DIR)/libz.so.1
Girish Gowdraab7ea552020-01-07 13:25:15 +0530354 @rm -f $(BUILD_DIR)/libbal_host_api.so
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000355 @rm -f $(BUILD_DIR)/openolt
Girish Gowdraab7ea552020-01-07 13:25:15 +0530356 @rm -f $(BUILD_DIR)/dev_mgmt_daemon
Jason Huang09b73ea2020-01-08 17:52:05 +0800357 @rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Girish Gowdrabc6e0852020-03-26 11:36:12 -0700358 @rm -f $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansari19249582018-04-30 04:31:00 +0000359
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000360clean-src: protos-clean
361 @rm -f $(OBJS) $(DEPS)
362
363distclean: clean-src clean
364 @rm -rf $(BUILD_DIR)
Shad Ansaricb004c52018-05-30 18:07:23 +0000365
Humera Kouser9c2bd9f2020-09-25 02:41:29 -0400366.PHONY: onl sdk bal protos inband-onl ansible .FORCE