blob: e699a700b59fb43425266def4c3aec138fcf6c21 [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
Jason Huang09b73ea2020-01-08 17:52:05 +080031BAL_REV_A_VER = 3
Jason Huangc6362792020-03-04 16:33:19 +080032BAL_REV_B_VER = 3
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
Jason Huangc6362792020-03-04 16:33:19 +080036DEV_VER ?= 202002100101
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
Burak Gurdageb4ca2e2020-06-15 07:48:26 +000045OPENOLT_PROTO_VER ?= v3.3.9
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
55# Protobuf installation
Girish Gowdra489425a2020-02-22 13:07:42 +053056PROTOBUF_VER ?= 3.5.0
Girish Gowdraddf9a162020-01-27 12:56:27 +053057PROTOBUF_ADDR = https://github.com/protocolbuffers/protobuf/releases/download/v$(PROTOBUF_VER)/protobuf-cpp-$(PROTOBUF_VER).tar.gz
58PROTOBUF_DST = /tmp/protobuf-$(PROTOBUF_VER)
Girish Gowdra489425a2020-02-22 13:07:42 +053059protoc-bin = $(shell which protoc)
Girish Gowdraddf9a162020-01-27 12:56:27 +053060
Luca Pretee75aaa52018-04-13 12:19:12 -070061#
62# GRPC installation
63GRPC_ADDR = https://github.com/grpc/grpc
64GRPC_DST = /tmp/grpc
65GRPC_VER = v1.10.x
Girish Gowdra489425a2020-02-22 13:07:42 +053066grpc-cpp-plugin-bin = $(shell which grpc_cpp_plugin)
Shad Ansari2cddc552018-06-26 20:34:27 +000067
68USER := $(shell echo $(USER))
Luca Pretee75aaa52018-04-13 12:19:12 -070069#
Shad Ansari01b0e652018-04-05 21:02:53 +000070########################################################################
71##
72##
Luca Prete08e6f802018-04-17 11:49:45 -070073## Install prerequisites
Shad Ansari01b0e652018-04-05 21:02:53 +000074##
75##
76HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
77SYSTEM ?= $(HOST_SYSTEM)
Luca Pretee75aaa52018-04-13 12:19:12 -070078
Humera Kouser5ac56612019-07-25 20:23:01 -040079VERSION ?= $(shell cat ../VERSION)
80
81#set ref and commit date only if committed
82LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote))
83LABEL_VCS_REF = $(shell git rev-parse HEAD)
84LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ")
85LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD)
86
Craig Lutgenf040dba2018-09-27 11:21:43 -050087LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g)
88LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g)
89
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +000090CXX = @CXX@-4.9
Craig Lutgenf040dba2018-09-27 11:21:43 -050091CXXFLAGS += @CXXFLAGS@
92CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++)
Humera Kouser5ac56612019-07-25 20:23:01 -040093CPPFLAGS += @CPPFLAGS@
Shad Ansari01b0e652018-04-05 21:02:53 +000094CPPFLAGS += `pkg-config --cflags protobuf grpc`
Humera Kouser5ac56612019-07-25 20:23:01 -040095CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBAL_VER=\"$(BAL_VER)\" -DLABEL_VCS_URL=\"$(LABEL_VCS_URL)\" \
96 -DLABEL_VCS_REF=\"$(LABEL_VCS_REF)\" -DLABEL_BUILD_DATE=\"$(LABEL_BUILD_DATE)\" \
Girish Gowdraddf9a162020-01-27 12:56:27 +053097 -DLABEL_COMMIT_DATE=\"$(LABEL_COMMIT_DATE)\" -DFLOW_CHECKER
Humera Kouser6143c9e2020-06-17 22:37:31 +053098CPPFLAGS += -I./
Craig Lutgen7ebee132018-11-16 15:31:11 -060099CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix
Craig Lutgenf040dba2018-09-27 11:21:43 -0500100LDFLAGS += @LDFLAGS@
101LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr
Shad Ansari9acc9732018-10-30 18:01:44 +0000102CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic
Craig Lutgenf040dba2018-09-27 11:21:43 -0500103
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000104export CXX CXXFLAGS OPENOLT_PROTO_VER
Luca Pretee75aaa52018-04-13 12:19:12 -0700105
Girish Gowdraddf9a162020-01-27 12:56:27 +0530106prereqs-system:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000107 sudo apt-get -q -y install git pkg-config build-essential autoconf libtool libgflags-dev libgtest-dev clang libc++-dev unzip docker.io
108 sudo apt-get install -y build-essential autoconf libssl-dev gawk debhelper dh-systemd init-system-helpers curl cmake ccache g++-4.9
Luca Pretee75aaa52018-04-13 12:19:12 -0700109
Girish Gowdraddf9a162020-01-27 12:56:27 +0530110prereqs-local: $(protoc-bin) $(grpc-cpp-plugin-bin)
111
112$(protoc-bin):
113 # Install protobuf
114 rm -rf $(PROTOBUF_DST)
115 cd /tmp && wget $(PROTOBUF_ADDR)
116 cd /tmp && tar -zxvf protobuf-cpp-$(PROTOBUF_VER).tar.gz
117 cd $(PROTOBUF_DST) && ./autogen.sh
Girish Gowdra489425a2020-02-22 13:07:42 +0530118 cd $(PROTOBUF_DST) && ./configure
Girish Gowdraddf9a162020-01-27 12:56:27 +0530119 make -C $(PROTOBUF_DST)
Girish Gowdra489425a2020-02-22 13:07:42 +0530120 sudo make -C $(PROTOBUF_DST) install
Girish Gowdraddf9a162020-01-27 12:56:27 +0530121
122$(grpc-cpp-plugin-bin):
123 # Install GRPC, protoc
Luca Pretee75aaa52018-04-13 12:19:12 -0700124 rm -rf $(GRPC_DST)
Girish Gowdraddf9a162020-01-27 12:56:27 +0530125 cd /tmp && git clone -b $(GRPC_VER) $(GRPC_ADDR) $(GRPC_DST)
Luca Pretee75aaa52018-04-13 12:19:12 -0700126 cd $(GRPC_DST) && git submodule update --init
Shad Ansari563ea822018-06-28 14:56:27 +0000127 make -C $(GRPC_DST)
Girish Gowdra489425a2020-02-22 13:07:42 +0530128 sudo make -C $(GRPC_DST) install
Shad Ansaricb004c52018-05-30 18:07:23 +0000129
Shad Ansari2cddc552018-06-26 20:34:27 +0000130docker:
131 echo $(USER)
132 sudo groupadd -f docker
133ifneq "$(USER)" ""
134 sudo usermod -aG docker $(USER)
135endif
136
Shad Ansari01b0e652018-04-05 21:02:53 +0000137########################################################################
138##
139##
Luca Pretee75aaa52018-04-13 12:19:12 -0700140## ONL
Shad Ansari01b0e652018-04-05 21:02:53 +0000141##
142##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000143ONL_REPO = onl
Shad Ansari01b0e652018-04-05 21:02:53 +0000144ONL_DIR = $(BUILD_DIR)/$(ONL_REPO)
Shad Ansari01b0e652018-04-05 21:02:53 +0000145onl:
146 if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \
147 mkdir -p $(ONL_DIR); \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000148 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \
149 cp download/Makefile.onl $(ONL_DIR)/Makefile; \
150 install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530151 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \
152 else \
153 if [ "$(INBAND)" = n -a "$$(grep "inband" $(ONL_DIR)/onl_build.mode | cut -d= -f 2)" = y ]; then \
154 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \
155 fi; \
Shad Ansari01b0e652018-04-05 21:02:53 +0000156 fi;
157onl-force:
Shad Ansari9acc9732018-10-30 18:01:44 +0000158 make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR)
Shad Ansari01b0e652018-04-05 21:02:53 +0000159distclean-onl:
160 sudo rm -rf $(ONL_DIR)
161
162########################################################################
163##
164##
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000165## Broadcom LIBRARY APIs
166##
167##
168BAL_API_DIR = $(BUILD_DIR)/bal-api-$(BAL_API_VER)
169
170bal-api-$(BAL_API_VER):
171 if [ ! -d "$(BAL_API_DIR)" ]; then \
172 mkdir -p $(BAL_API_DIR); \
173 git clone https://github.com/balapi/bal-api-$(BAL_API_VER).git $(BAL_API_DIR); \
174 fi;
175bal-api-clean:
176 rm $(BAL_API_DIR)
177
178########################################################################
179##
180##
Luca Pretee75aaa52018-04-13 12:19:12 -0700181## BAL
Shad Ansari01b0e652018-04-05 21:02:53 +0000182##
183##
Jason Huang09b73ea2020-01-08 17:52:05 +0800184BAL_ZIP = SW-BCM686OLT_$(subst .,_,$(BAL_VER)).tgz
Shad Ansari01b0e652018-04-05 21:02:53 +0000185SDK_ZIP = sdk-all-$(SDK_VER).tar.gz
Craig Lutgenf040dba2018-09-27 11:21:43 -0500186ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch
Shad Ansari9acc9732018-10-30 18:01:44 +0000187BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000188BCM_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER)
189BALLIBDIR = $(BAL_DIR)/build/host_reference/host_api
190BALLIBNAME = bal_host_api
191BAL_INC = -I$(BAL_DIR)/host_driver/bal/bal_include \
192 -I$(BAL_DIR)/host_driver/topology \
193 -I$(BAL_DIR)/host_driver/utils \
194 -I$(BAL_DIR)/host_driver/api \
Jason Huangc6362792020-03-04 16:33:19 +0800195 -I$(BAL_DIR)/host_driver/metadata \
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000196 -I$(BAL_DIR)/host_customized/os_abstraction \
197 -I$(BAL_DIR)/host_customized/os_abstraction/posix \
198 -I$(BAL_DIR)/host_customized/config \
199 -I$(BAL_DIR)/host_driver/api_conn_mgr \
200 -I$(BAL_DIR)/host_driver/conn_mgr \
201 -I$(BAL_DIR)/host_driver/api/host/topology \
202 -I$(BAL_DIR)/host_reference/cli \
203 -I$(BAL_DIR)/host_reference/api_cli \
204 -I$(BAL_API_DIR)/include \
205 -I$(BAL_API_DIR)/include/object_model
Shad Ansari01b0e652018-04-05 21:02:53 +0000206CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000207CXXFLAGS += -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 +0000208
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000209sdk: onl bal-api-$(BAL_API_VER)
Shad Ansari01b0e652018-04-05 21:02:53 +0000210ifeq ("$(wildcard $(BAL_DIR))","")
211 mkdir $(BAL_DIR)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000212 tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR)
Shad Ansari01b0e652018-04-05 21:02:53 +0000213 cp download/$(SDK_ZIP) $(BCM_SDK)
214 chmod -R 744 $(BAL_DIR)
215 cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR)
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000216 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux OPEN_SOURCE=y
217 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
Shad Ansari01b0e652018-04-05 21:02:53 +0000218endif
Shad Ansaricb004c52018-05-30 18:07:23 +0000219
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000220bal-release: sdk
221 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board
Shad Ansaricb004c52018-05-30 18:07:23 +0000222
223bal-clean:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000224 make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all
Shad Ansari01b0e652018-04-05 21:02:53 +0000225
226########################################################################
227##
228##
Luca Pretee75aaa52018-04-13 12:19:12 -0700229## OpenOLT API
Shad Ansari01b0e652018-04-05 21:02:53 +0000230##
231##
Shad Ansari56c8ea42018-10-30 19:34:35 +0000232OPENOLT_PROTOS_DIR = ../protos
Shad Ansari19249582018-04-30 04:31:00 +0000233OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a
Shad Ansari627b5782018-08-13 22:49:32 +0000234CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens
Shad Ansari19249582018-04-30 04:31:00 +0000235protos:
236 make -C $(OPENOLT_PROTOS_DIR) all
Shad Ansaricc01de12018-05-21 22:54:45 +0000237protos-clean:
Shad Ansari19249582018-04-30 04:31:00 +0000238 -make -C $(OPENOLT_PROTOS_DIR) clean
Shad Ansari01b0e652018-04-05 21:02:53 +0000239
240########################################################################
241##
242##
Shad Ansari627b5782018-08-13 22:49:32 +0000243## common
Shad Ansari7193ae22018-08-08 22:23:18 +0000244##
245##
Girish Gowdrafe649702019-10-30 12:49:58 +0530246
247# A hack to force a re-build of common/main.cc everytime.
248# This is needed to bake in the git VCS information in the openolt binary
249# at the time of building the openolt package.
250common/main.o: .FORCE
251.FORCE:
252 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c common/main.cc -o common/main.o
253
Shad Ansari627b5782018-08-13 22:49:32 +0000254common/%.o: common/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400255 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari7193ae22018-08-08 22:23:18 +0000256
257########################################################################
258##
259##
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500260## device
261##
262##
Shad Ansari9acc9732018-10-30 18:01:44 +0000263device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc
Craig Lutgen88a22ad2018-10-04 12:30:46 -0500264 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
265
266device/generic/%.o: device/generic/%.cc
267 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@
268
269########################################################################
270##
271##
Shad Ansari627b5782018-08-13 22:49:32 +0000272## sim
Shad Ansari01b0e652018-04-05 21:02:53 +0000273##
274##
Shad Ansari627b5782018-08-13 22:49:32 +0000275SIM_SRCS = $(wildcard sim/*.cc) $(wildcard common/*.cc)
276SIM_OBJS = $(SIM_SRCS:.cc=.o)
277SIM_DEPS = $(SIM_SRCS:.cc=.d)
278sim: sim/openoltsim
279sim/openoltsim: protos $(SIM_OBJS)
280 $(CXX) -pthread -L/usr/local/lib $(SIM_OBJS) $(OPENOLT_API_LIB) /usr/local/lib/libprotobuf.a -o $@ -lgrpc++ -lgrpc -lpthread -ldl
281sim/%.o: sim/%.cc
282 $(CXX) -std=c++11 -fpermissive -Wno-literal-suffix -I./common -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens -c $< -o $@
283clean-sim:
284 rm -f sim/openoltsim $(SIM_OBJS) $(SIM_DEPS)
285
286########################################################################
287##
288##
289## openolt
290##
291##
Shad Ansari9acc9732018-10-30 18:01:44 +0000292SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc)
Shad Ansari01b0e652018-04-05 21:02:53 +0000293OBJS = $(SRCS:.cc=.o)
294DEPS = $(SRCS:.cc=.d)
295.DEFAULT_GOAL := all
Shad Ansari2ae27672019-05-09 00:26:34 +0000296all: $(BUILD_DIR)/openolt
Shad Ansaricb004c52018-05-30 18:07:23 +0000297$(BUILD_DIR)/openolt: sdk protos $(OBJS)
Shad Ansari06a13322018-09-29 01:55:33 +0000298 $(CXX) $(LDFLAGS) -L$(BALLIBDIR) $(OBJS) $(OPENOLT_API_LIB) $(LIBPROTOBUF_PATH)/libprotobuf.a -o $@ -l$(BALLIBNAME) $(shell pkg-config --libs protobuf grpc++ grpc)
Jason Huang09b73ea2020-01-08 17:52:05 +0800299 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 +0000300 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_reference/host_api/strip/libbal_host_api.so $(BUILD_DIR)/.
301 ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_driver/dev_mgmt_daemon/dev_mgmt_daemon $(BUILD_DIR)/.
Craig Lutgenf040dba2018-09-27 11:21:43 -0500302 ln -sf $(LIBGRPC_PATH)/libgrpc.so.6 $(BUILD_DIR)/libgrpc.so.6
303 ln -sf $(LIBGRPC_PATH)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++.so.1
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000304 ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6
305 strip $(BUILD_DIR)/openolt
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530306 echo "inband=n" > $(ONL_DIR)/onl_build.mode
307 if [ $(INBAND) = y ]; then \
308 echo "Building ONL+BAL+OpenoltAgent allinone image"; \
309 make deb; \
310 make inband-onl; \
311 fi;
312
Shad Ansari627b5782018-08-13 22:49:32 +0000313src/%.o: src/%.cc
Humera Kouser5ac56612019-07-25 20:23:01 -0400314 $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@
Shad Ansari01b0e652018-04-05 21:02:53 +0000315
Shad Ansari6cd46a62018-05-13 23:20:51 +0000316deb:
Jason Huang09b73ea2020-01-08 17:52:05 +0800317 cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz device/$(OPENOLTDEVICE)/mkdebian/debian
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000318 cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian
319 cp $(BUILD_DIR)/libgrpc.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
320 cp $(BUILD_DIR)/libgrpc++.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian
321 cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian
322 cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian
323 cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian
324 cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
Girish Gowdrabc6e0852020-03-26 11:36:12 -0700325 mv device/$(OPENOLTDEVICE)/*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansaricb004c52018-05-30 18:07:23 +0000326 make deb-cleanup
Shad Ansari6cd46a62018-05-13 23:20:51 +0000327
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530328inband-onl:
329 # Clean previous ONL build and build freshly
330 sudo rm -rf $(ONL_DIR)
331 mkdir -p $(ONL_DIR)
332 git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux
333 cp download/Makefile.onl $(ONL_DIR)/Makefile
334 install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux
335
336 # Check ONL commit equals to Inband patch commit
337 ONL_COMMIT_ID=$(awk \'/COMMIT_ID = /{print $0}\' $(ONL_DIR)/Makefile | awk -F \"=\" \'{print $2}\')
338 INBAND_PATCH_COMMIT_ID=$(echo cp $(TOP_DIR)/inband/patch/*.patch | cut -d- -f 2 | cut -d. -f 1)
339 if [ "$(ONL_COMMIT_ID)" = "$(INBAND_PATCH_COMMIT_ID)" ]; then \
340 echo "ONL commit and inband patch commit matched."; \
341 cp $(TOP_DIR)/inband/patch/*.patch $(ONL_DIR)/OpenNetworkLinux; \
342 else \
343 echo "ONL commit and inband patch commit does not match. Exiting."; \
344 exit 1; \
345 fi;
346
347 # Update vlan.config file with VLAN ID argument passed
348 sed -i 's/asfvolt16_vlan_id_eth2=.*/asfvolt16_vlan_id_eth2=$(VLAN_ID)/' $(TOP_DIR)/inband/config/vlan.config
349 sed -i 's/asgvolt64_vlan_id_eth1=.*/asgvolt64_vlan_id_eth1=$(VLAN_ID)/' $(TOP_DIR)/inband/config/vlan.config
350
351 # Copy Inband config files and olt startup scripts to ONL source code and build
352 cd $(TOP_DIR) && mkdir -p $(ONL_DIR)/OpenNetworkLinux/bal_packages
353 cp $(TOP_DIR)/inband/scripts/* $(ONL_DIR)/OpenNetworkLinux/bal_packages
354 cp $(TOP_DIR)/inband/config/vlan.config $(ONL_DIR)/OpenNetworkLinux/bal_packages
355 cp $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb $(ONL_DIR)/OpenNetworkLinux/bal_packages/openolt_$(OPENOLTDEVICE).deb
356
357 # Rebuild ONL packed with already built BAL+Openolt debian package
358 make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=y
359 echo "inband=y" > $(ONL_DIR)/onl_build.mode
360 make inband-onl-cleanup
361
Shad Ansari01b0e652018-04-05 21:02:53 +0000362src/%.o: %.cpp
363 $(CXX) -MMD -c $< -o $@
364
Shad Ansaricb004c52018-05-30 18:07:23 +0000365deb-cleanup:
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000366 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log
367 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper
368 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper
369 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars
370 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/
371 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp
372 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libgrpc++.so.1
373 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libgrpc.so.6
374 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6
375 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api.so
376 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/
377 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt
Jason Huang09b73ea2020-01-08 17:52:05 +0800378 @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000379 @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/
380 @rm -f device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes
Shad Ansaricc01de12018-05-21 22:54:45 +0000381
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530382inband-onl-cleanup:
383 @rm -f $(ONL_DIR)/OpenNetworkLinux/*.patch
384 @rm -rf $(ONL_DIR)/OpenNetworkLinux/bal_packages
385
Shad Ansaricb004c52018-05-30 18:07:23 +0000386clean: protos-clean deb-cleanup
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000387 @rm -f $(OBJS) $(DEPS)
388 @rm -rf $(OPENOLT_PROTOS_DIR)/googleapis
389 @rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1
Girish Gowdraab7ea552020-01-07 13:25:15 +0530390 @rm -f $(BUILD_DIR)/libbal_host_api.so
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000391 @rm -f $(BUILD_DIR)/openolt
Girish Gowdraab7ea552020-01-07 13:25:15 +0530392 @rm -f $(BUILD_DIR)/dev_mgmt_daemon
Jason Huang09b73ea2020-01-08 17:52:05 +0800393 @rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz
Girish Gowdrabc6e0852020-03-26 11:36:12 -0700394 @rm -f $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb
Shad Ansari19249582018-04-30 04:31:00 +0000395
Thiyagarajan Subramani89fffc02019-05-13 21:33:20 +0000396clean-src: protos-clean
397 @rm -f $(OBJS) $(DEPS)
398
399distclean: clean-src clean
400 @rm -rf $(BUILD_DIR)
Shad Ansaricb004c52018-05-30 18:07:23 +0000401
Thiyagarajan Subramanie84935d2020-04-23 17:45:44 +0530402.PHONY: onl sdk bal protos prereqs-system prereqs-local sim inband-onl .FORCE