Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1 | # Copyright (C) 2018 Open Networking Foundation |
| 2 | # |
| 3 | # This program is free software: you can redistribute it and/or modify |
| 4 | # it under the terms of the GNU General Public License as published by |
| 5 | # the Free Software Foundation, either version 3 of the License, or |
| 6 | # (at your option) any later version. |
| 7 | # |
| 8 | # This program is distributed in the hope that it will be useful, |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | # GNU General Public License for more details. |
| 12 | # |
| 13 | # You should have received a copy of the GNU General Public License |
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | |
| 16 | ######################################################################## |
| 17 | ## |
| 18 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 19 | ## Config |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 20 | ## |
| 21 | ## |
Jason Huang | af7f647 | 2019-05-04 03:19:07 +0800 | [diff] [blame] | 22 | TOP_DIR=`pwd` |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 23 | OPENOLTDEVICE ?= generic |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 24 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 25 | # |
| 26 | # Three vendor proprietary source files are required to build BAL. |
| 27 | # SW-BCM68620_<VER>.zip - Broadcom BAL source and Maple SDK. |
| 28 | # sdk-all-<SDK_VER>.tar.gz - Broadcom Qumran SDK. |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 29 | # ACCTON_BAL_<BAL_VER>-<DEV_VER>.patch - Accton/Edgecore's patch. |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 30 | BAL_MAJOR_VER = 3 |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 31 | BAL_MINOR_VER = 1 |
| 32 | BAL_REV_A_VER = 1 |
| 33 | BAL_REV_B_VER = 1 |
| 34 | BAL_API_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER) |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 35 | BAL_VER = $(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(BAL_REV_B_VER) |
Jason Huang | af7f647 | 2019-05-04 03:19:07 +0800 | [diff] [blame] | 36 | SDK_VER = 6.5.13 |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 37 | DEV_VER ?= 201908010203 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 38 | # |
| 39 | # Version of Open Network Linux (ONL). |
Jason Huang | af7f647 | 2019-05-04 03:19:07 +0800 | [diff] [blame] | 40 | ONL_KERN_VER_MAJOR = 4.14 |
Girish Gowdra | 897f5ab | 2019-10-17 17:05:31 +0530 | [diff] [blame] | 41 | |
| 42 | # OpenOLT Proto version. |
| 43 | # This specifies the GIT tag in https://github.com/opencord/voltha-protos |
| 44 | # repo that we need to refer to, to pick the right version of |
| 45 | # openolt.proto and tech_profile.proto |
| 46 | OPENOLT_PROTO_VER ?= v1.0.3 |
| 47 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 48 | # |
| 49 | # Build directory |
| 50 | BUILD_DIR = build |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 51 | # |
| 52 | # GRPC installation |
| 53 | GRPC_ADDR = https://github.com/grpc/grpc |
| 54 | GRPC_DST = /tmp/grpc |
| 55 | GRPC_VER = v1.10.x |
Shad Ansari | 2cddc55 | 2018-06-26 20:34:27 +0000 | [diff] [blame] | 56 | |
| 57 | USER := $(shell echo $(USER)) |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 58 | # |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 59 | ######################################################################## |
| 60 | ## |
| 61 | ## |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 62 | ## Install prerequisites |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 63 | ## |
| 64 | ## |
| 65 | HOST_SYSTEM = $(shell uname | cut -f 1 -d_) |
| 66 | SYSTEM ?= $(HOST_SYSTEM) |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 67 | |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 68 | LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g) |
| 69 | LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g) |
| 70 | |
Jason Huang | 313ae31 | 2019-06-18 17:54:15 +0800 | [diff] [blame] | 71 | CXX = @CXX@-4.9 |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 72 | CXXFLAGS += @CXXFLAGS@ |
| 73 | CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 74 | CPPFLAGS += `pkg-config --cflags protobuf grpc` |
Craig Lutgen | 7ebee13 | 2018-11-16 15:31:11 -0600 | [diff] [blame] | 75 | CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 76 | LDFLAGS += @LDFLAGS@ |
| 77 | LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 78 | CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 79 | |
Girish Gowdra | 897f5ab | 2019-10-17 17:05:31 +0530 | [diff] [blame] | 80 | export CXX CXXFLAGS OPENOLT_PROTO_VER |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 81 | |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 82 | prereq: |
nick | 6fa8073 | 2018-05-22 14:47:10 -0400 | [diff] [blame] | 83 | sudo apt-get -q -y install git pkg-config build-essential autoconf libtool libgflags-dev libgtest-dev clang libc++-dev unzip docker.io |
Jason Huang | 313ae31 | 2019-06-18 17:54:15 +0800 | [diff] [blame] | 84 | 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] | 85 | |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 86 | # Install GRPC, libprotobuf and protoc |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 87 | rm -rf $(GRPC_DST) |
| 88 | git clone -b $(GRPC_VER) $(GRPC_ADDR) $(GRPC_DST) |
| 89 | cd $(GRPC_DST) && git submodule update --init |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 90 | cd $(GRPC_DST)/third_party/protobuf && ./autogen.sh && ./configure |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 91 | make -C $(GRPC_DST)/third_party/protobuf |
| 92 | sudo make -C $(GRPC_DST)/third_party/protobuf install |
| 93 | sudo ldconfig |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 94 | make -C $(GRPC_DST) |
| 95 | sudo make -C $(GRPC_DST) install |
| 96 | sudo ldconfig |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 97 | |
Shad Ansari | 2cddc55 | 2018-06-26 20:34:27 +0000 | [diff] [blame] | 98 | docker: |
| 99 | echo $(USER) |
| 100 | sudo groupadd -f docker |
| 101 | ifneq "$(USER)" "" |
| 102 | sudo usermod -aG docker $(USER) |
| 103 | endif |
| 104 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 105 | ######################################################################## |
| 106 | ## |
| 107 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 108 | ## ONL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 109 | ## |
| 110 | ## |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 111 | ONL_REPO = onl |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 112 | ONL_DIR = $(BUILD_DIR)/$(ONL_REPO) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 113 | onl: |
| 114 | if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \ |
| 115 | mkdir -p $(ONL_DIR); \ |
Jason Huang | af7f647 | 2019-05-04 03:19:07 +0800 | [diff] [blame] | 116 | git clone https://github.com/opencomputeproject/OpenNetworkLinux.git $(ONL_DIR)/OpenNetworkLinux; \ |
| 117 | cp download/Makefile.onl $(ONL_DIR)/Makefile; \ |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 118 | install -m 755 download/build-onl.sh $(ONL_DIR)/OpenNetworkLinux; \ |
| 119 | make -C $(ONL_DIR) onl-$(ONL_KERN_VER_MAJOR); \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 120 | fi; |
| 121 | onl-force: |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 122 | make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 123 | distclean-onl: |
| 124 | sudo rm -rf $(ONL_DIR) |
| 125 | |
| 126 | ######################################################################## |
| 127 | ## |
| 128 | ## |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 129 | ## Broadcom LIBRARY APIs |
| 130 | ## |
| 131 | ## |
| 132 | BAL_API_DIR = $(BUILD_DIR)/bal-api-$(BAL_API_VER) |
| 133 | |
| 134 | bal-api-$(BAL_API_VER): |
| 135 | if [ ! -d "$(BAL_API_DIR)" ]; then \ |
| 136 | mkdir -p $(BAL_API_DIR); \ |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 137 | git clone https://github.com/balapi/bal-api-$(BAL_API_VER).git $(BAL_API_DIR); \ |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 138 | fi; |
| 139 | bal-api-clean: |
| 140 | rm $(BAL_API_DIR) |
| 141 | |
| 142 | ######################################################################## |
| 143 | ## |
| 144 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 145 | ## BAL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 146 | ## |
| 147 | ## |
Jason Huang | af7f647 | 2019-05-04 03:19:07 +0800 | [diff] [blame] | 148 | BAL_ZIP = SW-BCM68620_$(subst .,_,$(BAL_VER)).tgz |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 149 | SDK_ZIP = sdk-all-$(SDK_VER).tar.gz |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 150 | ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 151 | BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 152 | BCM_SDK = $(BAL_DIR)/switch_sdk/$(SDK_VER) |
| 153 | BALLIBDIR = $(BAL_DIR)/build/host_reference/host_api |
| 154 | BALLIBNAME = bal_host_api |
| 155 | BAL_INC = -I$(BAL_DIR)/host_driver/bal/bal_include \ |
| 156 | -I$(BAL_DIR)/host_driver/topology \ |
| 157 | -I$(BAL_DIR)/host_driver/utils \ |
| 158 | -I$(BAL_DIR)/host_driver/api \ |
| 159 | -I$(BAL_DIR)/host_customized/os_abstraction \ |
| 160 | -I$(BAL_DIR)/host_customized/os_abstraction/posix \ |
| 161 | -I$(BAL_DIR)/host_customized/config \ |
| 162 | -I$(BAL_DIR)/host_driver/api_conn_mgr \ |
| 163 | -I$(BAL_DIR)/host_driver/conn_mgr \ |
| 164 | -I$(BAL_DIR)/host_driver/api/host/topology \ |
| 165 | -I$(BAL_DIR)/host_reference/cli \ |
| 166 | -I$(BAL_DIR)/host_reference/api_cli \ |
| 167 | -I$(BAL_API_DIR)/include \ |
| 168 | -I$(BAL_API_DIR)/include/object_model |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 169 | CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 170 | 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] | 171 | |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 172 | sdk: onl bal-api-$(BAL_API_VER) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 173 | ifeq ("$(wildcard $(BAL_DIR))","") |
| 174 | mkdir $(BAL_DIR) |
Jason Huang | af7f647 | 2019-05-04 03:19:07 +0800 | [diff] [blame] | 175 | tar zxvf download/$(BAL_ZIP) --strip 1 -C $(BAL_DIR) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 176 | cp download/$(SDK_ZIP) $(BCM_SDK) |
| 177 | chmod -R 744 $(BAL_DIR) |
| 178 | cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR) |
Jason Huang | b6843dc | 2019-07-22 17:46:06 +0800 | [diff] [blame] | 179 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) ONL_DIR=$(TOP_DIR)/$(ONL_DIR)/OpenNetworkLinux OPEN_SOURCE=y |
Jason Huang | af7f647 | 2019-05-04 03:19:07 +0800 | [diff] [blame] | 180 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 181 | endif |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 182 | |
Jason Huang | af7f647 | 2019-05-04 03:19:07 +0800 | [diff] [blame] | 183 | bal-release: sdk |
Jason Huang | af7f647 | 2019-05-04 03:19:07 +0800 | [diff] [blame] | 184 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) release_board |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 185 | |
| 186 | bal-clean: |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 187 | make -C $(BAL_DIR) BOARD=$(OPENOLTDEVICE) clean_all |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 188 | |
| 189 | ######################################################################## |
| 190 | ## |
| 191 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 192 | ## OpenOLT API |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 193 | ## |
| 194 | ## |
Shad Ansari | 56c8ea4 | 2018-10-30 19:34:35 +0000 | [diff] [blame] | 195 | OPENOLT_PROTOS_DIR = ../protos |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 196 | OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 197 | CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 198 | protos: |
| 199 | make -C $(OPENOLT_PROTOS_DIR) all |
Shad Ansari | cc01de1 | 2018-05-21 22:54:45 +0000 | [diff] [blame] | 200 | protos-clean: |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 201 | -make -C $(OPENOLT_PROTOS_DIR) clean |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 202 | |
| 203 | ######################################################################## |
| 204 | ## |
| 205 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 206 | ## common |
Shad Ansari | 7193ae2 | 2018-08-08 22:23:18 +0000 | [diff] [blame] | 207 | ## |
| 208 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 209 | common/%.o: common/%.cc |
| 210 | $(CXX) $(CXXFLAGS) -I./common -c $< -o $@ |
Shad Ansari | 7193ae2 | 2018-08-08 22:23:18 +0000 | [diff] [blame] | 211 | |
| 212 | ######################################################################## |
| 213 | ## |
| 214 | ## |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 215 | ## device |
| 216 | ## |
| 217 | ## |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 218 | device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 219 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@ |
| 220 | |
| 221 | device/generic/%.o: device/generic/%.cc |
| 222 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@ |
| 223 | |
| 224 | ######################################################################## |
| 225 | ## |
| 226 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 227 | ## sim |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 228 | ## |
| 229 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 230 | SIM_SRCS = $(wildcard sim/*.cc) $(wildcard common/*.cc) |
| 231 | SIM_OBJS = $(SIM_SRCS:.cc=.o) |
| 232 | SIM_DEPS = $(SIM_SRCS:.cc=.d) |
| 233 | sim: sim/openoltsim |
| 234 | sim/openoltsim: protos $(SIM_OBJS) |
| 235 | $(CXX) -pthread -L/usr/local/lib $(SIM_OBJS) $(OPENOLT_API_LIB) /usr/local/lib/libprotobuf.a -o $@ -lgrpc++ -lgrpc -lpthread -ldl |
| 236 | sim/%.o: sim/%.cc |
| 237 | $(CXX) -std=c++11 -fpermissive -Wno-literal-suffix -I./common -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens -c $< -o $@ |
| 238 | clean-sim: |
| 239 | rm -f sim/openoltsim $(SIM_OBJS) $(SIM_DEPS) |
| 240 | |
| 241 | ######################################################################## |
| 242 | ## |
| 243 | ## |
| 244 | ## openolt |
| 245 | ## |
| 246 | ## |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 247 | SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 248 | OBJS = $(SRCS:.cc=.o) |
| 249 | DEPS = $(SRCS:.cc=.d) |
| 250 | .DEFAULT_GOAL := all |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 251 | all: $(BUILD_DIR)/openolt |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 252 | $(BUILD_DIR)/openolt: sdk protos $(OBJS) |
Shad Ansari | 06a1332 | 2018-09-29 01:55:33 +0000 | [diff] [blame] | 253 | $(CXX) $(LDFLAGS) -L$(BALLIBDIR) $(OBJS) $(OPENOLT_API_LIB) $(LIBPROTOBUF_PATH)/libprotobuf.a -o $@ -l$(BALLIBNAME) $(shell pkg-config --libs protobuf grpc++ grpc) |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 254 | ln -sf $(TOP_DIR)/$(BAL_DIR)/build/fs/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/. |
| 255 | ln -sf $(TOP_DIR)/$(BAL_DIR)/build/host_reference/host_api/strip/libbal_host_api.so $(BUILD_DIR)/. |
| 256 | 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] | 257 | ln -sf $(LIBGRPC_PATH)/libgrpc.so.6 $(BUILD_DIR)/libgrpc.so.6 |
| 258 | ln -sf $(LIBGRPC_PATH)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++.so.1 |
Jason Huang | d33b4d8 | 2019-05-15 18:22:57 +0800 | [diff] [blame] | 259 | ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6 |
Jason Huang | fd78f66 | 2019-06-05 20:25:01 +0800 | [diff] [blame] | 260 | strip $(BUILD_DIR)/openolt |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 261 | src/%.o: src/%.cc |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 262 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I./common -c $< -o $@ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 263 | |
Shad Ansari | 6cd46a6 | 2018-05-13 23:20:51 +0000 | [diff] [blame] | 264 | deb: |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 265 | cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(DEV_VER).tar.gz device/$(OPENOLTDEVICE)/mkdebian/debian |
| 266 | cp $(BUILD_DIR)/openolt device/$(OPENOLTDEVICE)/mkdebian/debian |
| 267 | cp $(BUILD_DIR)/libgrpc.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian |
| 268 | cp $(BUILD_DIR)/libgrpc++.so.1 device/$(OPENOLTDEVICE)/mkdebian/debian |
| 269 | cp $(BUILD_DIR)/libstdc++.so.6 device/$(OPENOLTDEVICE)/mkdebian/debian |
| 270 | cp $(BUILD_DIR)/libbal_host_api.so device/$(OPENOLTDEVICE)/mkdebian/debian |
| 271 | cp -a scripts/init.d device/$(OPENOLTDEVICE)/mkdebian/debian |
| 272 | cd device/$(OPENOLTDEVICE)/mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh |
| 273 | mv device/$(OPENOLTDEVICE)/*.deb $(BUILD_DIR)/openolt_$(OPENOLTDEVICE).deb |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 274 | make deb-cleanup |
Shad Ansari | 6cd46a6 | 2018-05-13 23:20:51 +0000 | [diff] [blame] | 275 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 276 | src/%.o: %.cpp |
| 277 | $(CXX) -MMD -c $< -o $@ |
| 278 | |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 279 | deb-cleanup: |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 280 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).debhelper.log |
| 281 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper |
| 282 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper |
| 283 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE).substvars |
| 284 | @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/$(OPENOLTDEVICE)/ |
| 285 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/debhelper-build-stamp |
| 286 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libgrpc++.so.1 |
| 287 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libgrpc.so.6 |
| 288 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libstdc++.so.6 |
| 289 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/libbal_host_api.so |
| 290 | @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/init.d/ |
| 291 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/openolt |
| 292 | @rm -f device/$(OPENOLTDEVICE)/mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(DEV_VER).tar.gz |
| 293 | @rm -rf device/$(OPENOLTDEVICE)/mkdebian/debian/tmp/ |
| 294 | @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] | 295 | |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 296 | clean: protos-clean deb-cleanup |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 297 | @rm -f $(OBJS) $(DEPS) |
| 298 | @rm -rf $(OPENOLT_PROTOS_DIR)/googleapis |
| 299 | @rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1 |
| 300 | @rm -f $(BUILD_DIR)/libbal_api_dist.so |
| 301 | @rm -f $(BUILD_DIR)/openolt |
| 302 | @rm -f $(BUILD_DIR)/bal_core_dist |
| 303 | @rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz |
| 304 | @rm -f $(BUILD_DIR)/openolt.deb |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 305 | |
Thiyagarajan Subramani | 1f1280b | 2019-08-13 18:41:19 +0800 | [diff] [blame] | 306 | clean-src: protos-clean |
| 307 | @rm -f $(OBJS) $(DEPS) |
| 308 | |
| 309 | distclean: clean-src clean |
| 310 | @rm -rf $(BUILD_DIR) |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 311 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 312 | .PHONY: onl sdk bal protos prereq sim |