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 | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame^] | 30 | BAL_MINOR_VER = 2 |
| 31 | BAL_REV_A_VER = 3 |
| 32 | BAL_REV_B_VER = 2 |
| 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 |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame^] | 36 | DEV_VER ?= 201912230101 |
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 | c78b9e1 | 2019-11-29 11:14:51 +0000 | [diff] [blame] | 45 | OPENOLT_PROTO_VER ?= v3.1.0 |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 46 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 47 | # |
| 48 | # Build directory |
| 49 | BUILD_DIR = build |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 50 | # |
| 51 | # GRPC installation |
| 52 | GRPC_ADDR = https://github.com/grpc/grpc |
| 53 | GRPC_DST = /tmp/grpc |
| 54 | GRPC_VER = v1.10.x |
Shad Ansari | 2cddc55 | 2018-06-26 20:34:27 +0000 | [diff] [blame] | 55 | |
| 56 | USER := $(shell echo $(USER)) |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 57 | # |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 58 | ######################################################################## |
| 59 | ## |
| 60 | ## |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 61 | ## Install prerequisites |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 62 | ## |
| 63 | ## |
| 64 | HOST_SYSTEM = $(shell uname | cut -f 1 -d_) |
| 65 | SYSTEM ?= $(HOST_SYSTEM) |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 66 | |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 67 | VERSION ?= $(shell cat ../VERSION) |
| 68 | |
| 69 | #set ref and commit date only if committed |
| 70 | LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 71 | LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 72 | LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 73 | LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
| 74 | |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 75 | LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g) |
| 76 | LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g) |
| 77 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 78 | CXX = @CXX@-4.9 |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 79 | CXXFLAGS += @CXXFLAGS@ |
| 80 | CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++) |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 81 | CPPFLAGS += @CPPFLAGS@ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 82 | CPPFLAGS += `pkg-config --cflags protobuf grpc` |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 83 | CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBAL_VER=\"$(BAL_VER)\" -DLABEL_VCS_URL=\"$(LABEL_VCS_URL)\" \ |
| 84 | -DLABEL_VCS_REF=\"$(LABEL_VCS_REF)\" -DLABEL_BUILD_DATE=\"$(LABEL_BUILD_DATE)\" \ |
| 85 | -DLABEL_COMMIT_DATE=\"$(LABEL_COMMIT_DATE)\" |
Craig Lutgen | 7ebee13 | 2018-11-16 15:31:11 -0600 | [diff] [blame] | 86 | CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 87 | LDFLAGS += @LDFLAGS@ |
| 88 | LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 89 | CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 90 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 91 | export CXX CXXFLAGS OPENOLT_PROTO_VER |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 92 | |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 93 | prereq: |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 94 | sudo apt-get -q -y install git pkg-config build-essential autoconf libtool libgflags-dev libgtest-dev clang libc++-dev unzip docker.io |
| 95 | sudo apt-get install -y build-essential autoconf libssl-dev gawk debhelper dh-systemd init-system-helpers curl cmake ccache g++-4.9 |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 96 | |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 97 | # Install GRPC, libprotobuf and protoc |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 98 | rm -rf $(GRPC_DST) |
| 99 | git clone -b $(GRPC_VER) $(GRPC_ADDR) $(GRPC_DST) |
| 100 | cd $(GRPC_DST) && git submodule update --init |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 101 | cd $(GRPC_DST)/third_party/protobuf && ./autogen.sh && ./configure |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 102 | make -C $(GRPC_DST)/third_party/protobuf |
| 103 | sudo make -C $(GRPC_DST)/third_party/protobuf install |
| 104 | sudo ldconfig |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 105 | make -C $(GRPC_DST) |
| 106 | sudo make -C $(GRPC_DST) install |
| 107 | sudo ldconfig |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 108 | |
Shad Ansari | 2cddc55 | 2018-06-26 20:34:27 +0000 | [diff] [blame] | 109 | docker: |
| 110 | echo $(USER) |
| 111 | sudo groupadd -f docker |
| 112 | ifneq "$(USER)" "" |
| 113 | sudo usermod -aG docker $(USER) |
| 114 | endif |
| 115 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 116 | ######################################################################## |
| 117 | ## |
| 118 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 119 | ## ONL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 120 | ## |
| 121 | ## |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 122 | ONL_REPO = onl |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 123 | ONL_DIR = $(BUILD_DIR)/$(ONL_REPO) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 124 | onl: |
| 125 | if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \ |
| 126 | mkdir -p $(ONL_DIR); \ |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 127 | git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \ |
| 128 | cp download/Makefile.onl $(ONL_DIR)/Makefile; \ |
| 129 | install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \ |
| 130 | make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR); \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 131 | fi; |
| 132 | onl-force: |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 133 | make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 134 | distclean-onl: |
| 135 | sudo rm -rf $(ONL_DIR) |
| 136 | |
| 137 | ######################################################################## |
| 138 | ## |
| 139 | ## |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 140 | ## Broadcom LIBRARY APIs |
| 141 | ## |
| 142 | ## |
| 143 | BAL_API_DIR = $(BUILD_DIR)/bal-api-$(BAL_API_VER) |
| 144 | |
| 145 | bal-api-$(BAL_API_VER): |
| 146 | if [ ! -d "$(BAL_API_DIR)" ]; then \ |
| 147 | mkdir -p $(BAL_API_DIR); \ |
| 148 | git clone https://github.com/balapi/bal-api-$(BAL_API_VER).git $(BAL_API_DIR); \ |
| 149 | fi; |
| 150 | bal-api-clean: |
| 151 | rm $(BAL_API_DIR) |
| 152 | |
| 153 | ######################################################################## |
| 154 | ## |
| 155 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 156 | ## BAL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 157 | ## |
| 158 | ## |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame^] | 159 | BAL_ZIP = SW-BCM686OLT_$(subst .,_,$(BAL_VER)).tgz |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 160 | SDK_ZIP = sdk-all-$(SDK_VER).tar.gz |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 161 | ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 162 | BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 163 | BCM_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER) |
| 164 | BALLIBDIR = $(BAL_DIR)/build/host_reference/host_api |
| 165 | BALLIBNAME = bal_host_api |
| 166 | BAL_INC = -I$(BAL_DIR)/host_driver/bal/bal_include \ |
| 167 | -I$(BAL_DIR)/host_driver/topology \ |
| 168 | -I$(BAL_DIR)/host_driver/utils \ |
| 169 | -I$(BAL_DIR)/host_driver/api \ |
| 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 |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 182 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 183 | sdk: onl bal-api-$(BAL_API_VER) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 184 | ifeq ("$(wildcard $(BAL_DIR))","") |
| 185 | mkdir $(BAL_DIR) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 186 | tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 187 | cp download/$(SDK_ZIP) $(BCM_SDK) |
| 188 | chmod -R 744 $(BAL_DIR) |
| 189 | cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR) |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 190 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux OPEN_SOURCE=y |
| 191 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 192 | endif |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 193 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 194 | bal-release: sdk |
| 195 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 196 | |
| 197 | bal-clean: |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 198 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 199 | |
| 200 | ######################################################################## |
| 201 | ## |
| 202 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 203 | ## OpenOLT API |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 204 | ## |
| 205 | ## |
Shad Ansari | 56c8ea4 | 2018-10-30 19:34:35 +0000 | [diff] [blame] | 206 | OPENOLT_PROTOS_DIR = ../protos |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 207 | OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 208 | CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 209 | protos: |
| 210 | make -C $(OPENOLT_PROTOS_DIR) all |
Shad Ansari | cc01de1 | 2018-05-21 22:54:45 +0000 | [diff] [blame] | 211 | protos-clean: |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 212 | -make -C $(OPENOLT_PROTOS_DIR) clean |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 213 | |
| 214 | ######################################################################## |
| 215 | ## |
| 216 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 217 | ## common |
Shad Ansari | 7193ae2 | 2018-08-08 22:23:18 +0000 | [diff] [blame] | 218 | ## |
| 219 | ## |
Girish Gowdra | fe64970 | 2019-10-30 12:49:58 +0530 | [diff] [blame] | 220 | |
| 221 | # A hack to force a re-build of common/main.cc everytime. |
| 222 | # This is needed to bake in the git VCS information in the openolt binary |
| 223 | # at the time of building the openolt package. |
| 224 | common/main.o: .FORCE |
| 225 | .FORCE: |
| 226 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c common/main.cc -o common/main.o |
| 227 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 228 | common/%.o: common/%.cc |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 229 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c $< -o $@ |
Shad Ansari | 7193ae2 | 2018-08-08 22:23:18 +0000 | [diff] [blame] | 230 | |
| 231 | ######################################################################## |
| 232 | ## |
| 233 | ## |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 234 | ## device |
| 235 | ## |
| 236 | ## |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 237 | device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 238 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@ |
| 239 | |
| 240 | device/generic/%.o: device/generic/%.cc |
| 241 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@ |
| 242 | |
| 243 | ######################################################################## |
| 244 | ## |
| 245 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 246 | ## sim |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 247 | ## |
| 248 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 249 | SIM_SRCS = $(wildcard sim/*.cc) $(wildcard common/*.cc) |
| 250 | SIM_OBJS = $(SIM_SRCS:.cc=.o) |
| 251 | SIM_DEPS = $(SIM_SRCS:.cc=.d) |
| 252 | sim: sim/openoltsim |
| 253 | sim/openoltsim: protos $(SIM_OBJS) |
| 254 | $(CXX) -pthread -L/usr/local/lib $(SIM_OBJS) $(OPENOLT_API_LIB) /usr/local/lib/libprotobuf.a -o $@ -lgrpc++ -lgrpc -lpthread -ldl |
| 255 | sim/%.o: sim/%.cc |
| 256 | $(CXX) -std=c++11 -fpermissive -Wno-literal-suffix -I./common -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens -c $< -o $@ |
| 257 | clean-sim: |
| 258 | rm -f sim/openoltsim $(SIM_OBJS) $(SIM_DEPS) |
| 259 | |
| 260 | ######################################################################## |
| 261 | ## |
| 262 | ## |
| 263 | ## openolt |
| 264 | ## |
| 265 | ## |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 266 | SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 267 | OBJS = $(SRCS:.cc=.o) |
| 268 | DEPS = $(SRCS:.cc=.d) |
| 269 | .DEFAULT_GOAL := all |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 270 | all: $(BUILD_DIR)/openolt |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 271 | $(BUILD_DIR)/openolt: sdk protos $(OBJS) |
Shad Ansari | 06a1332 | 2018-09-29 01:55:33 +0000 | [diff] [blame] | 272 | $(CXX) $(LDFLAGS) -L$(BALLIBDIR) $(OBJS) $(OPENOLT_API_LIB) $(LIBPROTOBUF_PATH)/libprotobuf.a -o $@ -l$(BALLIBNAME) $(shell pkg-config --libs protobuf grpc++ grpc) |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame^] | 273 | 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] | 274 | ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_reference/host_api/strip/libbal_host_api.so $(BUILD_DIR)/. |
| 275 | ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_driver/dev_mgmt_daemon/dev_mgmt_daemon $(BUILD_DIR)/. |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 276 | ln -sf $(LIBGRPC_PATH)/libgrpc.so.6 $(BUILD_DIR)/libgrpc.so.6 |
| 277 | ln -sf $(LIBGRPC_PATH)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++.so.1 |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 278 | ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6 |
| 279 | strip $(BUILD_DIR)/openolt |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 280 | src/%.o: src/%.cc |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame] | 281 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 282 | |
Shad Ansari | 6cd46a6 | 2018-05-13 23:20:51 +0000 | [diff] [blame] | 283 | deb: |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame^] | 284 | 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] | 285 | cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian |
| 286 | cp $(BUILD_DIR)/libgrpc.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian |
| 287 | cp $(BUILD_DIR)/libgrpc++.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian |
| 288 | cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian |
| 289 | cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian |
| 290 | cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian |
| 291 | cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh |
| 292 | mv device/$(OPENOLTDEVICE)/*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE).deb |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 293 | make deb-cleanup |
Shad Ansari | 6cd46a6 | 2018-05-13 23:20:51 +0000 | [diff] [blame] | 294 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 295 | src/%.o: %.cpp |
| 296 | $(CXX) -MMD -c $< -o $@ |
| 297 | |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 298 | deb-cleanup: |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 299 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log |
| 300 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper |
| 301 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper |
| 302 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars |
| 303 | @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/ |
| 304 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp |
| 305 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libgrpc++.so.1 |
| 306 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libgrpc.so.6 |
| 307 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6 |
| 308 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api.so |
| 309 | @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/ |
| 310 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame^] | 311 | @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] | 312 | @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/ |
| 313 | @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] | 314 | |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 315 | clean: protos-clean deb-cleanup |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 316 | @rm -f $(OBJS) $(DEPS) |
| 317 | @rm -rf $(OPENOLT_PROTOS_DIR)/googleapis |
| 318 | @rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1 |
Girish Gowdra | ab7ea55 | 2020-01-07 13:25:15 +0530 | [diff] [blame] | 319 | @rm -f $(BUILD_DIR)/libbal_host_api.so |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 320 | @rm -f $(BUILD_DIR)/openolt |
Girish Gowdra | ab7ea55 | 2020-01-07 13:25:15 +0530 | [diff] [blame] | 321 | @rm -f $(BUILD_DIR)/dev_mgmt_daemon |
Jason Huang | 09b73ea | 2020-01-08 17:52:05 +0800 | [diff] [blame^] | 322 | @rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_VER).$(DEV_VER).tar.gz |
Girish Gowdra | ab7ea55 | 2020-01-07 13:25:15 +0530 | [diff] [blame] | 323 | @rm -f $(BUILD_DIR)/openolt_$(OPENOLTDEVICE).deb |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 324 | |
Thiyagarajan Subramani | 89fffc0 | 2019-05-13 21:33:20 +0000 | [diff] [blame] | 325 | clean-src: protos-clean |
| 326 | @rm -f $(OBJS) $(DEPS) |
| 327 | |
| 328 | distclean: clean-src clean |
| 329 | @rm -rf $(BUILD_DIR) |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 330 | |
Girish Gowdra | fe64970 | 2019-10-30 12:49:58 +0530 | [diff] [blame] | 331 | .PHONY: onl sdk bal protos prereq sim .FORCE |