Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 1 | #Copyright 2018-present Open Networking Foundation |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 2 | # |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 3 | #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 Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 6 | # |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 7 | #http://www.apache.org/licenses/LICENSE-2.0 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 8 | # |
Girish Gowdra | a707e7c | 2019-11-07 11:36:13 +0530 | [diff] [blame] | 9 | #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 Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 14 | |
| 15 | ######################################################################## |
| 16 | ## |
| 17 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 18 | ## Config |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 19 | ## |
| 20 | ## |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 21 | TOP_DIR=`pwd` |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 22 | OPENOLTDEVICE ?= generic |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 23 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 24 | # |
| 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 Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 28 | # ACCTON_BAL_<BAL_VER>-<DEV_VER>.patch - Accton/Edgecore's patch. |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 29 | BAL_MAJOR_VER = 3 |
Jason Huang | c636279 | 2020-03-04 16:33:19 +0800 | [diff] [blame] | 30 | BAL_MINOR_VER = 4 |
Girish Gowdra | fc10f0d | 2020-11-30 13:06:35 -0800 | [diff] [blame] | 31 | BAL_REV_A_VER = 9 |
| 32 | BAL_REV_B_VER = 6 |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 33 | BAL_API_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 34 | BAL_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER) |
| 35 | SDK_VER = 6.5.13 |
Girish Gowdra | 315344d | 2020-12-17 08:51:46 -0800 | [diff] [blame] | 36 | DEV_VER ?= 202012040101 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 37 | # |
| 38 | # Version of Open Network Linux (ONL). |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 39 | ONL_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 Gurdag | 30db482 | 2021-03-10 21:30:01 +0000 | [diff] [blame] | 45 | OPENOLT_PROTO_VER ?= v4.0.15 |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 46 | |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 47 | # Variables used for Inband build |
| 48 | INBAND = "n" |
| 49 | VLAN_ID = 4093 |
| 50 | |
Jason Huang | dc83ba7 | 2020-11-16 22:08:43 +0800 | [diff] [blame] | 51 | # NNI ports speed setting |
| 52 | PORT_100G_SPEED ?= 100000 |
| 53 | PORT_25G_SPEED ?= 25000 |
| 54 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 55 | # Build directory |
| 56 | BUILD_DIR = build |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 57 | |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 58 | # initialiaze path of protoc binary |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 59 | protoc-bin = $(shell which protoc) |
Girish Gowdra | ddf9a16 | 2020-01-27 12:56:27 +0530 | [diff] [blame] | 60 | |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 61 | # initialiaze path of grpc_cpp_plugin binary |
Girish Gowdra | 489425a | 2020-02-22 13:07:42 +0530 | [diff] [blame] | 62 | grpc-cpp-plugin-bin = $(shell which grpc_cpp_plugin) |
Shad Ansari | 2cddc55 | 2018-06-26 20:34:27 +0000 | [diff] [blame] | 63 | |
| 64 | USER := $(shell echo $(USER)) |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 65 | # |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 66 | ######################################################################## |
| 67 | ## |
| 68 | ## |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 69 | ## Initialize various build flags |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 70 | ## |
| 71 | ## |
| 72 | HOST_SYSTEM = $(shell uname | cut -f 1 -d_) |
| 73 | SYSTEM ?= $(HOST_SYSTEM) |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 74 | |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 75 | VERSION ?= $(shell cat ../VERSION) |
| 76 | |
| 77 | #set ref and commit date only if committed |
| 78 | LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 79 | LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 80 | LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 81 | LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
| 82 | |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 83 | LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g) |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 84 | LIBZ_PATH=$(shell pkg-config --libs-only-L zlib | sed s/-L// | sed s/\ //g) |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 85 | LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g) |
| 86 | |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 87 | PCAPPLUSPLUS_INCLUDE_PATH=-I/usr/local/include/pcapplusplus/ |
| 88 | PCAPPLUSPLUS_LIB_PATH=-lPcap++ -lPacket++ -lCommon++ |
| 89 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 90 | CXX = @CXX@-4.9 |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 91 | CXXFLAGS += @CXXFLAGS@ |
| 92 | CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++) |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 93 | CXXFLAGS += $(PCAPPLUSPLUS_INCLUDE_PATH) |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 94 | CPPFLAGS += @CPPFLAGS@ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 95 | CPPFLAGS += `pkg-config --cflags protobuf grpc` |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 96 | |
| 97 | # Enabling SCALE_AND_PERF for higher performance and scaling to 512 subscribers. Enabling the flag will |
| 98 | # disable the handling in FLOW_CHECKER and also disable flow statistics |
| 99 | # Setting SW_UTIL_SHELL=y will enable QAX debug shell when compiling for Broadcom chip based OLT |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 100 | CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBAL_VER=\"$(BAL_VER)\" -DLABEL_VCS_URL=\"$(LABEL_VCS_URL)\" \ |
| 101 | -DLABEL_VCS_REF=\"$(LABEL_VCS_REF)\" -DLABEL_BUILD_DATE=\"$(LABEL_BUILD_DATE)\" \ |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 102 | -DLABEL_COMMIT_DATE=\"$(LABEL_COMMIT_DATE)\" -DFLOW_CHECKER -USCALE_AND_PERF -DSW_UTIL_SHELL=n |
Humera Kouser | 6143c9e | 2020-06-17 22:37:31 +0530 | [diff] [blame] | 103 | CPPFLAGS += -I./ |
Craig Lutgen | 7ebee13 | 2018-11-16 15:31:11 -0600 | [diff] [blame] | 104 | CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 105 | LDFLAGS += @LDFLAGS@ |
| 106 | LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 107 | CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 108 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 109 | export CXX CXXFLAGS OPENOLT_PROTO_VER |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 110 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 111 | ######################################################################## |
| 112 | ## |
| 113 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 114 | ## ONL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 115 | ## |
| 116 | ## |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 117 | ONL_REPO = onl |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 118 | ONL_DIR = $(BUILD_DIR)/$(ONL_REPO) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 119 | onl: |
| 120 | if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \ |
| 121 | mkdir -p $(ONL_DIR); \ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 122 | git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \ |
| 123 | cp download/Makefile.onl $(ONL_DIR)/Makefile; \ |
| 124 | install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \ |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 125 | make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \ |
| 126 | else \ |
| 127 | if [ "$(INBAND)" = n -a "$$(grep "inband" $(ONL_DIR)/onl_build.mode | cut -d= -f 2)" = y ]; then \ |
| 128 | make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=n; \ |
| 129 | fi; \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 130 | fi; |
| 131 | onl-force: |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 132 | make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 133 | distclean-onl: |
| 134 | sudo rm -rf $(ONL_DIR) |
| 135 | |
| 136 | ######################################################################## |
| 137 | ## |
| 138 | ## |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 139 | ## Broadcom LIBRARY APIs |
| 140 | ## |
| 141 | ## |
| 142 | BAL_API_DIR = $(BUILD_DIR)/bal-api-$(BAL_API_VER) |
| 143 | |
| 144 | bal-api-$(BAL_API_VER): |
| 145 | if [ ! -d "$(BAL_API_DIR)" ]; then \ |
| 146 | mkdir -p $(BAL_API_DIR); \ |
| 147 | git clone https://github.com/balapi/bal-api-$(BAL_API_VER).git $(BAL_API_DIR); \ |
| 148 | fi; |
| 149 | bal-api-clean: |
| 150 | rm $(BAL_API_DIR) |
| 151 | |
| 152 | ######################################################################## |
| 153 | ## |
| 154 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 155 | ## BAL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 156 | ## |
| 157 | ## |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 158 | BAL_ZIP = SW-BCM686OLT_$(subst .,_,$(BAL_VER)).tgz |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 159 | SDK_ZIP = sdk-all-$(SDK_VER).tar.gz |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 160 | ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 161 | BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 162 | BCM_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER) |
| 163 | BALLIBDIR = $(BAL_DIR)/build/host_reference/host_api |
| 164 | BALLIBNAME = bal_host_api |
| 165 | BAL_INC = -I$(BAL_DIR)/host_driver/bal/bal_include \ |
| 166 | -I$(BAL_DIR)/host_driver/topology \ |
| 167 | -I$(BAL_DIR)/host_driver/utils \ |
| 168 | -I$(BAL_DIR)/host_driver/api \ |
Jason Huang | c636279 | 2020-03-04 16:33:19 +0800 | [diff] [blame] | 169 | -I$(BAL_DIR)/host_driver/metadata \ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 170 | -I$(BAL_DIR)/host_customized/os_abstraction \ |
| 171 | -I$(BAL_DIR)/host_customized/os_abstraction/posix \ |
| 172 | -I$(BAL_DIR)/host_customized/config \ |
| 173 | -I$(BAL_DIR)/host_driver/api_conn_mgr \ |
| 174 | -I$(BAL_DIR)/host_driver/conn_mgr \ |
| 175 | -I$(BAL_DIR)/host_driver/api/host/topology \ |
| 176 | -I$(BAL_DIR)/host_reference/cli \ |
| 177 | -I$(BAL_DIR)/host_reference/api_cli \ |
| 178 | -I$(BAL_API_DIR)/include \ |
| 179 | -I$(BAL_API_DIR)/include/object_model |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 180 | CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 181 | CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST -DENABLE_LOG -DENABLE_CLI |
Jason Huang | dc83ba7 | 2020-11-16 22:08:43 +0800 | [diff] [blame] | 182 | PORT_SPEED_FILE = $(BAL_DIR)/switch_sdk/$(SDK_VER)/rc/$(OPENOLTDEVICE)/board_files/broadcom/port_speed.soc |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 183 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 184 | sdk: onl bal-api-$(BAL_API_VER) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 185 | ifeq ("$(wildcard $(BAL_DIR))","") |
| 186 | mkdir $(BAL_DIR) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 187 | tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 188 | cp download/$(SDK_ZIP) $(BCM_SDK) |
| 189 | chmod -R 744 $(BAL_DIR) |
| 190 | cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR) |
Jason Huang | dc83ba7 | 2020-11-16 22:08:43 +0800 | [diff] [blame] | 191 | ifeq ("$(strip $(OPENOLTDEVICE))","asfvolt16") |
| 192 | echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE) |
| 193 | else ifeq ("$(strip $(OPENOLTDEVICE))","asgvolt64") |
| 194 | echo "setenv port_speed_for_100 $(PORT_100G_SPEED)" > $(PORT_SPEED_FILE) |
| 195 | echo "setenv port_speed_for_25 $(PORT_25G_SPEED)" >> $(PORT_SPEED_FILE) |
| 196 | endif |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 197 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux OPEN_SOURCE=y |
| 198 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 199 | endif |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 200 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 201 | bal-release: sdk |
| 202 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 203 | |
| 204 | bal-clean: |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 205 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 206 | |
| 207 | ######################################################################## |
| 208 | ## |
| 209 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 210 | ## OpenOLT API |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 211 | ## |
| 212 | ## |
Shad Ansari | 56c8ea4 | 2018-10-30 19:34:35 +0000 | [diff] [blame] | 213 | OPENOLT_PROTOS_DIR = ../protos |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 214 | OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 215 | CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I./device -I./device/$(OPENOLTDEVICE) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 216 | protos: |
| 217 | make -C $(OPENOLT_PROTOS_DIR) all |
Shad Ansari | cc01de1 | 2018-05-21 22:54:45 +0000 | [diff] [blame] | 218 | protos-clean: |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 219 | -make -C $(OPENOLT_PROTOS_DIR) clean |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 220 | |
| 221 | ######################################################################## |
| 222 | ## |
| 223 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 224 | ## common |
Shad Ansari | 7193ae2 | 2018-08-08 22:23:18 +0000 | [diff] [blame] | 225 | ## |
| 226 | ## |
Girish Gowdra | fe64970 | 2019-10-30 12:49:58 +0530 | [diff] [blame] | 227 | |
| 228 | # A hack to force a re-build of common/main.cc everytime. |
| 229 | # This is needed to bake in the git VCS information in the openolt binary |
| 230 | # at the time of building the openolt package. |
| 231 | common/main.o: .FORCE |
| 232 | .FORCE: |
| 233 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c common/main.cc -o common/main.o |
| 234 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 235 | common/%.o: common/%.cc |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 236 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c $< -o $@ |
Shad Ansari | 7193ae2 | 2018-08-08 22:23:18 +0000 | [diff] [blame] | 237 | |
| 238 | ######################################################################## |
| 239 | ## |
| 240 | ## |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 241 | ## device |
| 242 | ## |
| 243 | ## |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 244 | device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 245 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@ |
| 246 | |
| 247 | device/generic/%.o: device/generic/%.cc |
| 248 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@ |
| 249 | |
| 250 | ######################################################################## |
| 251 | ## |
| 252 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 253 | ## openolt |
| 254 | ## |
| 255 | ## |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 256 | OLT_SW_UPGRADE_DIR = ../olt-sw-upgrade |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 257 | SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc) |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 258 | ANSIBLE_DIR = /etc/ansible |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 259 | OBJS = $(SRCS:.cc=.o) |
| 260 | DEPS = $(SRCS:.cc=.d) |
| 261 | .DEFAULT_GOAL := all |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 262 | all: $(BUILD_DIR)/openolt |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 263 | $(BUILD_DIR)/openolt: sdk protos $(OBJS) |
Girish Gowdra | 1935e6a | 2020-10-31 21:48:22 -0700 | [diff] [blame] | 264 | $(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 Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 265 | ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/. |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 266 | ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_reference/host_api/strip/libbal_host_api.so $(BUILD_DIR)/. |
| 267 | ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_driver/dev_mgmt_daemon/dev_mgmt_daemon $(BUILD_DIR)/. |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 268 | ln -sf $(LIBGRPC_PATH)/libz.so.1 $(BUILD_DIR)/libz.so.1 |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 269 | ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6 |
| 270 | strip $(BUILD_DIR)/openolt |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 271 | echo "inband=n" > $(ONL_DIR)/onl_build.mode |
| 272 | if [ $(INBAND) = y ]; then \ |
| 273 | echo "Building ONL+BAL+OpenoltAgent allinone image"; \ |
| 274 | make deb; \ |
| 275 | make inband-onl; \ |
| 276 | fi; |
| 277 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 278 | src/%.o: src/%.cc |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 279 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 280 | |
Shad Ansari | 6cd46a6 | 2018-05-13 23:20:51 +0000 | [diff] [blame] | 281 | deb: |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 282 | cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz device/$(OPENOLTDEVICE)/mkdebian/debian |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 283 | cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 284 | cp $(BUILD_DIR)/libz.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 285 | cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian |
| 286 | cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian |
| 287 | cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 288 | cp -a scripts/watchdog device/$(OPENOLTDEVICE)/mkdebian/debian |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 289 | cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh |
Girish Gowdra | bc6e085 | 2020-03-26 11:36:12 -0700 | [diff] [blame] | 290 | mv device/$(OPENOLTDEVICE)/*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 291 | make deb-cleanup |
Shad Ansari | 6cd46a6 | 2018-05-13 23:20:51 +0000 | [diff] [blame] | 292 | |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 293 | inband-onl: |
| 294 | # Clean previous ONL build and build freshly |
| 295 | sudo rm -rf $(ONL_DIR) |
| 296 | mkdir -p $(ONL_DIR) |
| 297 | git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux |
| 298 | cp download/Makefile.onl $(ONL_DIR)/Makefile |
| 299 | install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux |
| 300 | |
| 301 | # Check ONL commit equals to Inband patch commit |
| 302 | ONL_COMMIT_ID=$(awk \'/COMMIT_ID = /{print $0}\' $(ONL_DIR)/Makefile | awk -F \"=\" \'{print $2}\') |
| 303 | INBAND_PATCH_COMMIT_ID=$(echo cp $(TOP_DIR)/inband/patch/*.patch | cut -d- -f 2 | cut -d. -f 1) |
| 304 | if [ "$(ONL_COMMIT_ID)" = "$(INBAND_PATCH_COMMIT_ID)" ]; then \ |
| 305 | echo "ONL commit and inband patch commit matched."; \ |
| 306 | cp $(TOP_DIR)/inband/patch/*.patch $(ONL_DIR)/OpenNetworkLinux; \ |
| 307 | else \ |
| 308 | echo "ONL commit and inband patch commit does not match. Exiting."; \ |
| 309 | exit 1; \ |
| 310 | fi; |
| 311 | |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 312 | # Update inband.config file with VLAN ID argument passed |
| 313 | sed -i 's/asfvolt16_vlan_id_eth2=.*/asfvolt16_vlan_id_eth2=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config |
| 314 | sed -i 's/asgvolt64_vlan_id_eth1=.*/asgvolt64_vlan_id_eth1=$(VLAN_ID)/' $(TOP_DIR)/inband/config/inband.config |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 315 | |
| 316 | # Copy Inband config files and olt startup scripts to ONL source code and build |
| 317 | cd $(TOP_DIR) && mkdir -p $(ONL_DIR)/OpenNetworkLinux/bal_packages |
| 318 | cp $(TOP_DIR)/inband/scripts/* $(ONL_DIR)/OpenNetworkLinux/bal_packages |
Girish Gowdra | 6e74552 | 2020-07-15 15:52:13 -0700 | [diff] [blame] | 319 | cp $(TOP_DIR)/inband/config/inband.config $(ONL_DIR)/OpenNetworkLinux/bal_packages |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 320 | cp $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb $(ONL_DIR)/OpenNetworkLinux/bal_packages/openolt_$(OPENOLTDEVICE).deb |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 321 | cp $(OLT_SW_UPGRADE_DIR)/change_labels.sh $(ONL_DIR)/OpenNetworkLinux/bal_packages |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 322 | |
| 323 | # Rebuild ONL packed with already built BAL+Openolt debian package |
| 324 | make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR) INBAND=y |
| 325 | echo "inband=y" > $(ONL_DIR)/onl_build.mode |
| 326 | make inband-onl-cleanup |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 327 | # requires 'sudo' privileges |
| 328 | |
| 329 | ansible: |
| 330 | (ONL_INSTALLED_INSTALLER="$(shell find "$$(cd ./build/onl/OpenNetworkLinux/RELEASE/jessie/amd64; pwd)" -name "ONL-onl-*_AMD64_INSTALLED_INSTALLER")"; \ |
| 331 | rm -rf $(ANSIBLE_DIR)/roles/upgrade/files; \ |
| 332 | mkdir -p $(ANSIBLE_DIR)/roles/upgrade/files; \ |
| 333 | cp ../olt-sw-upgrade/install_onl.sh $(ANSIBLE_DIR)/roles/upgrade/files; \ |
| 334 | chmod +x $(ANSIBLE_DIR)/roles/upgrade/files/*.sh; \ |
| 335 | ln -s $$ONL_INSTALLED_INSTALLER $(ANSIBLE_DIR)/roles/upgrade/files/ONL_INSTALLED_INSTALLER) |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 336 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 337 | src/%.o: %.cpp |
| 338 | $(CXX) -MMD -c $< -o $@ |
| 339 | |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 340 | deb-cleanup: |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 341 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log |
| 342 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper |
| 343 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper |
| 344 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars |
| 345 | @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/ |
| 346 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 347 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libz.so.1 |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 348 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6 |
| 349 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api.so |
| 350 | @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/ |
| 351 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 352 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 353 | @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/ |
| 354 | @rm -f device/$(OPENOLTDEVICE)/$(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes |
Shad Ansari | cc01de1 | 2018-05-21 22:54:45 +0000 | [diff] [blame] | 355 | |
Thiyagarajan Subramani | e84935d | 2020-04-23 17:45:44 +0530 | [diff] [blame] | 356 | inband-onl-cleanup: |
| 357 | @rm -f $(ONL_DIR)/OpenNetworkLinux/*.patch |
| 358 | @rm -rf $(ONL_DIR)/OpenNetworkLinux/bal_packages |
| 359 | |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 360 | clean: protos-clean deb-cleanup |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 361 | @rm -f $(OBJS) $(DEPS) |
| 362 | @rm -rf $(OPENOLT_PROTOS_DIR)/googleapis |
Girish Gowdra | 252f497 | 2020-09-07 21:24:01 -0700 | [diff] [blame] | 363 | @rm -f $(BUILD_DIR)/libz.so.1 |
Girish Gowdra | ab7ea55 | 2020-01-07 13:25:15 +0530 | [diff] [blame] | 364 | @rm -f $(BUILD_DIR)/libbal_host_api.so |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 365 | @rm -f $(BUILD_DIR)/openolt |
Girish Gowdra | ab7ea55 | 2020-01-07 13:25:15 +0530 | [diff] [blame] | 366 | @rm -f $(BUILD_DIR)/dev_mgmt_daemon |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame] | 367 | @rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz |
Girish Gowdra | bc6e085 | 2020-03-26 11:36:12 -0700 | [diff] [blame] | 368 | @rm -f $(BUILD_DIR)/openolt_$(OPENOLTDEVICE)-$(VERSION)-$(LABEL_VCS_REF).deb |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 369 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 370 | clean-src: protos-clean |
| 371 | @rm -f $(OBJS) $(DEPS) |
| 372 | |
| 373 | distclean: clean-src clean |
| 374 | @rm -rf $(BUILD_DIR) |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 375 | |
Humera Kouser | 9c2bd9f | 2020-09-25 02:41:29 -0400 | [diff] [blame] | 376 | .PHONY: onl sdk bal protos inband-onl ansible .FORCE |