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 | ## |
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. |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 29 | BAL_MAJOR_VER = 02.06 |
| 30 | BAL_VER = 2.6.0.1 |
| 31 | SDK_VER = 6.5.7 |
| 32 | DEV_VER ?= 201804301043 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 33 | # |
| 34 | # Version of Open Network Linux (ONL). |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 35 | ONL_KERN_VER_MAJOR = 3.7 |
| 36 | ONL_KERN_VER_MINOR = 10 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 37 | # |
| 38 | # Build directory |
| 39 | BUILD_DIR = build |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 40 | # |
| 41 | # GRPC installation |
| 42 | GRPC_ADDR = https://github.com/grpc/grpc |
| 43 | GRPC_DST = /tmp/grpc |
| 44 | GRPC_VER = v1.10.x |
Shad Ansari | 2cddc55 | 2018-06-26 20:34:27 +0000 | [diff] [blame] | 45 | |
| 46 | USER := $(shell echo $(USER)) |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 47 | # |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 48 | ######################################################################## |
| 49 | ## |
| 50 | ## |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 51 | ## Install prerequisites |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 52 | ## |
| 53 | ## |
| 54 | HOST_SYSTEM = $(shell uname | cut -f 1 -d_) |
| 55 | SYSTEM ?= $(HOST_SYSTEM) |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 56 | |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame^] | 57 | VERSION ?= $(shell cat ../VERSION) |
| 58 | |
| 59 | #set ref and commit date only if committed |
| 60 | LABEL_VCS_URL ?= $(shell git remote get-url $(shell git remote)) |
| 61 | LABEL_VCS_REF = $(shell git rev-parse HEAD) |
| 62 | LABEL_BUILD_DATE ?= $(shell date -u "+%Y-%m-%dT%H:%M:%SZ") |
| 63 | LABEL_COMMIT_DATE = $(shell git show -s --format=%cd --date=iso-strict HEAD) |
| 64 | |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 65 | LIBGRPC_PATH=$(shell pkg-config --libs-only-L grpc | sed s/-L// | sed s/\ //g) |
| 66 | LIBPROTOBUF_PATH=$(shell PKG_CONFIG_ALLOW_SYSTEM_LIBS=true pkg-config --libs-only-L protobuf | sed s/-L// | sed s/\ //g) |
| 67 | |
| 68 | CXX = @CXX@ |
| 69 | CXXFLAGS += @CXXFLAGS@ |
| 70 | CXXFLAGS += $(shell pkg-config --cflags-only-I grpc++) |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame^] | 71 | CPPFLAGS += @CPPFLAGS@ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 72 | CPPFLAGS += `pkg-config --cflags protobuf grpc` |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame^] | 73 | CPPFLAGS += -DVERSION=\"$(VERSION)\" -DBAL_VER=\"$(BAL_VER)\" -DLABEL_VCS_URL=\"$(LABEL_VCS_URL)\" \ |
| 74 | -DLABEL_VCS_REF=\"$(LABEL_VCS_REF)\" -DLABEL_BUILD_DATE=\"$(LABEL_BUILD_DATE)\" \ |
| 75 | -DLABEL_COMMIT_DATE=\"$(LABEL_COMMIT_DATE)\" |
Craig Lutgen | 7ebee13 | 2018-11-16 15:31:11 -0600 | [diff] [blame] | 76 | CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 77 | LDFLAGS += @LDFLAGS@ |
| 78 | LDFLAGS += `pkg-config --libs protobuf grpc++ grpc` -ldl -lgpr |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 79 | CXXFLAGSDEVICE = -I./device -I./device/$(OPENOLTDEVICE) -I./device/generic |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 80 | |
| 81 | export CXX CXXFLAGS |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 82 | |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 83 | prereq: |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame^] | 84 | sudo apt-get -q -y install pkg-config build-essential autoconf libtool libgflags-dev libgtest-dev clang libc++-dev unzip docker.io |
nick | 6fa8073 | 2018-05-22 14:47:10 -0400 | [diff] [blame] | 85 | sudo apt-get install -y build-essential autoconf libssl-dev gawk debhelper dh-systemd init-system-helpers |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame^] | 86 | sudo add-apt-repository -y ppa:git-core/ppa && apt-get -y update && apt-get -y install git |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 87 | |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 88 | # Install GRPC, libprotobuf and protoc |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 89 | rm -rf $(GRPC_DST) |
| 90 | git clone -b $(GRPC_VER) $(GRPC_ADDR) $(GRPC_DST) |
| 91 | cd $(GRPC_DST) && git submodule update --init |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 92 | cd $(GRPC_DST)/third_party/protobuf && ./autogen.sh && ./configure |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 93 | make -C $(GRPC_DST)/third_party/protobuf |
| 94 | sudo make -C $(GRPC_DST)/third_party/protobuf install |
| 95 | sudo ldconfig |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 96 | make -C $(GRPC_DST) |
| 97 | sudo make -C $(GRPC_DST) install |
| 98 | sudo ldconfig |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 99 | |
Shad Ansari | 2cddc55 | 2018-06-26 20:34:27 +0000 | [diff] [blame] | 100 | docker: |
| 101 | echo $(USER) |
| 102 | sudo groupadd -f docker |
| 103 | ifneq "$(USER)" "" |
| 104 | sudo usermod -aG docker $(USER) |
| 105 | endif |
| 106 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 107 | ######################################################################## |
| 108 | ## |
| 109 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 110 | ## ONL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 111 | ## |
| 112 | ## |
| 113 | ONL_KERN_VER = $(ONL_KERN_VER_MAJOR).$(ONL_KERN_VER_MINOR) |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 114 | ONL_REPO = $(OPENOLTDEVICE)-onl |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 115 | ONL_DIR = $(BUILD_DIR)/$(ONL_REPO) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 116 | onl: |
| 117 | if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \ |
| 118 | mkdir -p $(ONL_DIR); \ |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 119 | git clone https://gerrit.opencord.org/$(ONL_REPO) $(ONL_DIR); \ |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 120 | make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR); \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 121 | fi; |
| 122 | onl-force: |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 123 | make -C $(ONL_DIR) $(OPENOLTDEVICE)-$(ONL_KERN_VER_MAJOR) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 124 | distclean-onl: |
| 125 | sudo rm -rf $(ONL_DIR) |
| 126 | |
| 127 | ######################################################################## |
| 128 | ## |
| 129 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 130 | ## BAL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 131 | ## |
| 132 | ## |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 133 | BAL_ZIP = SW-BCM68620_$(subst .,_,$(BAL_VER)).zip |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 134 | SDK_ZIP = sdk-all-$(SDK_VER).tar.gz |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 135 | ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(DEV_VER).patch |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 136 | OPENOLT_BAL_PATCH = OPENOLT_BAL_$(BAL_VER).patch |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 137 | BAL_DIR = $(BUILD_DIR)/$(OPENOLTDEVICE)-bal |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 138 | ONL_KERNDIR = $(PWD)/$(ONL_DIR)/OpenNetworkLinux/packages/base/amd64/kernels/kernel-$(ONL_KERN_VER_MAJOR)-x86-64-all/builds |
| 139 | MAPLE_KERNDIR = $(BAL_DIR)/bcm68620_release/$(OPENOLTDEVICE)/kernels |
| 140 | BCM_SDK = $(BAL_DIR)/bal_release/3rdparty/bcm-sdk |
| 141 | BALLIBDIR = $(BAL_DIR)/bal_release/build/core/src/apps/bal_api_dist_shared_lib |
| 142 | BALLIBNAME = bal_api_dist |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 143 | BAL_INC = -I$(BAL_DIR)/bal_release/src/common/os_abstraction \ |
| 144 | -I$(BAL_DIR)/bal_release/src/common/os_abstraction/posix \ |
| 145 | -I$(BAL_DIR)/bal_release/src/common/config \ |
| 146 | -I$(BAL_DIR)/bal_release/src/core/platform \ |
Nicolas Palpacuer | 0f19b1a | 2018-06-07 17:29:31 -0400 | [diff] [blame] | 147 | -I$(BAL_DIR)/bal_release/src/core/main \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 148 | -I$(BAL_DIR)/bal_release/src/common/include \ |
| 149 | -I$(BAL_DIR)/bal_release/src/lib/libbalapi \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 150 | -I$(BAL_DIR)/bal_release/src/balapiend \ |
| 151 | -I$(BAL_DIR)/bal_release/src/common/dev_log \ |
| 152 | -I$(BAL_DIR)/bal_release/src/common/bal_dist_utils \ |
| 153 | -I$(BAL_DIR)/bal_release/src/lib/libtopology \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 154 | -I$(BAL_DIR)/bal_release/src/lib/libcmdline \ |
| 155 | -I$(BAL_DIR)/bal_release/src/lib/libutils \ |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 156 | -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/utils \ |
| 157 | -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/model \ |
| 158 | -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/api \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 159 | -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_reference/cli |
| 160 | CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline |
Nicolas Palpacuer | 967438f | 2018-09-07 14:41:54 -0400 | [diff] [blame] | 161 | CXXFLAGS += -DBCMOS_MSG_QUEUE_DOMAIN_SOCKET -DBCMOS_MSG_QUEUE_UDP_SOCKET -DBCMOS_MEM_CHECK -DBCMOS_SYS_UNITTEST -DENABLE_LOG |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 162 | |
| 163 | sdk: onl |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 164 | ifeq ("$(wildcard $(BAL_DIR))","") |
| 165 | mkdir $(BAL_DIR) |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 166 | unzip download/$(BAL_ZIP) -d $(BAL_DIR) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 167 | cp download/$(SDK_ZIP) $(BCM_SDK) |
| 168 | chmod -R 744 $(BAL_DIR) |
| 169 | cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR) |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 170 | mkdir -p $(MAPLE_KERNDIR) |
| 171 | ln -s $(ONL_KERNDIR)/linux-$(ONL_KERN_VER) $(MAPLE_KERNDIR)/linux-$(ONL_KERN_VER) |
| 172 | ln -s $(ONL_DIR)/OpenNetworkLinux/packages/base/any/kernels/archives/linux-$(ONL_KERN_VER).tar.xz $(MAPLE_KERNDIR)/linux-$(ONL_KERN_VER).tar.xz |
| 173 | ln -s $(ONL_DIR)/OpenNetworkLinux/packages/base/any/kernels/$(ONL_KERN_VER_MAJOR)/configs/x86_64-all/x86_64-all.config $(MAPLE_KERNDIR)/x86_64-all.config |
| 174 | make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) maple_sdk_dir |
| 175 | cat download/$(OPENOLT_BAL_PATCH) | patch -p1 -d $(BAL_DIR) |
| 176 | make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) maple_sdk |
| 177 | make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) switch_sdk_dir |
| 178 | make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) switch_sdk |
| 179 | KERNDIR=$(ONL_KERNDIR)/linux-$(ONL_KERN_VER) BOARD=$(OPENOLTDEVICE) ARCH=x86_64 SDKBUILD=build_bcm_user make -C $(BCM_SDK)/build-$(OPENOLTDEVICE)/sdk-all-$(SDK_VER)/systems/linux/user/x86-generic_64-2_6 |
| 180 | make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) bal |
| 181 | echo 'auto_create_interface_tm=y' >> $(BAL_DIR)/bal_release/3rdparty/maple/cur/$(OPENOLTDEVICE)/board_files/broadcom/bal_config.ini |
| 182 | make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) release_board |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 183 | endif |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 184 | |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 185 | bal: sdk |
| 186 | make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) bal |
| 187 | echo 'auto_create_interface_tm=y' >> $(BAL_DIR)/bal_release/3rdparty/maple/cur/asfvolt16/board_files/broadcom/bal_config.ini |
| 188 | make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) release_board |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 189 | |
| 190 | bal-clean: |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 191 | make -C $(BAL_DIR)/bal_release BOARD=$(OPENOLTDEVICE) clean_bal |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 192 | |
| 193 | ######################################################################## |
| 194 | ## |
| 195 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 196 | ## OpenOLT API |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 197 | ## |
| 198 | ## |
Shad Ansari | 56c8ea4 | 2018-10-30 19:34:35 +0000 | [diff] [blame] | 199 | OPENOLT_PROTOS_DIR = ../protos |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 200 | OPENOLT_API_LIB = $(OPENOLT_PROTOS_DIR)/libopenoltapi.a |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 201 | CXXFLAGS += -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 202 | protos: |
| 203 | make -C $(OPENOLT_PROTOS_DIR) all |
Shad Ansari | cc01de1 | 2018-05-21 22:54:45 +0000 | [diff] [blame] | 204 | protos-clean: |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 205 | -make -C $(OPENOLT_PROTOS_DIR) clean |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 206 | |
| 207 | ######################################################################## |
| 208 | ## |
| 209 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 210 | ## common |
Shad Ansari | 7193ae2 | 2018-08-08 22:23:18 +0000 | [diff] [blame] | 211 | ## |
| 212 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 213 | common/%.o: common/%.cc |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame^] | 214 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -I./common -c $< -o $@ |
Shad Ansari | 7193ae2 | 2018-08-08 22:23:18 +0000 | [diff] [blame] | 215 | |
| 216 | ######################################################################## |
| 217 | ## |
| 218 | ## |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 219 | ## device |
| 220 | ## |
| 221 | ## |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 222 | device/$(OPENOLTDEVICE)/%.o: device/$(OPENOLTDEVICE)/%.cc |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 223 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@ |
| 224 | |
| 225 | device/generic/%.o: device/generic/%.cc |
| 226 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -c $< -o $@ |
| 227 | |
| 228 | ######################################################################## |
| 229 | ## |
| 230 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 231 | ## sim |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 232 | ## |
| 233 | ## |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 234 | SIM_SRCS = $(wildcard sim/*.cc) $(wildcard common/*.cc) |
| 235 | SIM_OBJS = $(SIM_SRCS:.cc=.o) |
| 236 | SIM_DEPS = $(SIM_SRCS:.cc=.d) |
| 237 | sim: sim/openoltsim |
| 238 | sim/openoltsim: protos $(SIM_OBJS) |
| 239 | $(CXX) -pthread -L/usr/local/lib $(SIM_OBJS) $(OPENOLT_API_LIB) /usr/local/lib/libprotobuf.a -o $@ -lgrpc++ -lgrpc -lpthread -ldl |
| 240 | sim/%.o: sim/%.cc |
| 241 | $(CXX) -std=c++11 -fpermissive -Wno-literal-suffix -I./common -I$(OPENOLT_PROTOS_DIR) -I$(OPENOLT_PROTOS_DIR)/googleapis/gens -c $< -o $@ |
| 242 | clean-sim: |
| 243 | rm -f sim/openoltsim $(SIM_OBJS) $(SIM_DEPS) |
| 244 | |
| 245 | ######################################################################## |
| 246 | ## |
| 247 | ## |
| 248 | ## openolt |
| 249 | ## |
| 250 | ## |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 251 | SRCS = $(wildcard src/*.cc) $(wildcard common/*.cc) $(wildcard device/$(OPENOLTDEVICE)/*.cc) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 252 | OBJS = $(SRCS:.cc=.o) |
| 253 | DEPS = $(SRCS:.cc=.d) |
| 254 | .DEFAULT_GOAL := all |
Shad Ansari | 2ae2767 | 2019-05-09 00:26:34 +0000 | [diff] [blame] | 255 | all: $(BUILD_DIR)/openolt |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 256 | $(BUILD_DIR)/openolt: sdk protos $(OBJS) |
Shad Ansari | 06a1332 | 2018-09-29 01:55:33 +0000 | [diff] [blame] | 257 | $(CXX) $(LDFLAGS) -L$(BALLIBDIR) $(OBJS) $(OPENOLT_API_LIB) $(LIBPROTOBUF_PATH)/libprotobuf.a -o $@ -l$(BALLIBNAME) $(shell pkg-config --libs protobuf grpc++ grpc) |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 258 | ln -sf $(PWD)/$(BAL_DIR)/bcm68620_release/$(OPENOLTDEVICE)/release/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz $(BUILD_DIR)/. |
| 259 | ln -sf $(PWD)/$(BAL_DIR)/bcm68620_release/$(OPENOLTDEVICE)/release/broadcom/libbal_api_dist.so $(BUILD_DIR)/. |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 260 | ln -sf $(PWD)/$(BAL_DIR)/bal_release/build/core/src/apps/bal_core_dist/bal_core_dist $(BUILD_DIR)/. |
Craig Lutgen | f040dba | 2018-09-27 11:21:43 -0500 | [diff] [blame] | 261 | ln -sf $(LIBGRPC_PATH)/libgrpc.so.6 $(BUILD_DIR)/libgrpc.so.6 |
| 262 | ln -sf $(LIBGRPC_PATH)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++.so.1 |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 263 | src/%.o: src/%.cc |
Humera Kouser | 5ac5661 | 2019-07-25 20:23:01 -0400 | [diff] [blame^] | 264 | $(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) $(CPPFLAGS) -I./common -c $< -o $@ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 265 | |
Shad Ansari | 6cd46a6 | 2018-05-13 23:20:51 +0000 | [diff] [blame] | 266 | deb: |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 267 | cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz mkdebian/debian |
Shad Ansari | 9fb007d | 2018-05-14 18:31:38 +0000 | [diff] [blame] | 268 | cp $(BUILD_DIR)/openolt mkdebian/debian |
| 269 | cp $(BUILD_DIR)/libgrpc.so.6 mkdebian/debian |
| 270 | cp $(BUILD_DIR)/libgrpc++.so.1 mkdebian/debian |
Shad Ansari | d0eaf75 | 2018-08-16 00:26:12 +0000 | [diff] [blame] | 271 | cp -a scripts/init.d mkdebian/debian |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 272 | cd mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh |
Shad Ansari | 6cd46a6 | 2018-05-13 23:20:51 +0000 | [diff] [blame] | 273 | mv *.deb $(BUILD_DIR)/openolt.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: |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 280 | rm -f mkdebian/debian/$(OPENOLTDEVICE).debhelper.log |
| 281 | rm -f mkdebian/debian/$(OPENOLTDEVICE).postinst.debhelper |
| 282 | rm -f mkdebian/debian/$(OPENOLTDEVICE).postrm.debhelper |
| 283 | rm -f mkdebian/debian/$(OPENOLTDEVICE).substvars |
| 284 | rm -rf mkdebian/debian/$(OPENOLTDEVICE)/ |
Shad Ansari | cc01de1 | 2018-05-21 22:54:45 +0000 | [diff] [blame] | 285 | rm -f mkdebian/debian/libgrpc++.so.1 |
Shad Ansari | cc01de1 | 2018-05-21 22:54:45 +0000 | [diff] [blame] | 286 | rm -f mkdebian/debian/libgrpc.so.6 |
| 287 | rm -f mkdebian/debian/openolt |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 288 | rm -f mkdebian/debian/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz |
Shad Ansari | cc01de1 | 2018-05-21 22:54:45 +0000 | [diff] [blame] | 289 | rm -rf mkdebian/debian/tmp/ |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 290 | rm -f $(OPENOLTDEVICE)_$(BAL_VER)+edgecore-V$(DEV_VER)_amd64.changes |
Shad Ansari | cc01de1 | 2018-05-21 22:54:45 +0000 | [diff] [blame] | 291 | |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 292 | clean: protos-clean deb-cleanup |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 293 | rm -f $(OBJS) $(DEPS) |
Craig Lutgen | 1951231 | 2018-11-02 10:14:46 -0500 | [diff] [blame] | 294 | rm -rf $(OPENOLT_PROTOS_DIR)/googleapis |
Shad Ansari | 563ea82 | 2018-06-28 14:56:27 +0000 | [diff] [blame] | 295 | rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1 |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 296 | rm -f $(BUILD_DIR)/libbal_api_dist.so |
| 297 | rm -f $(BUILD_DIR)/openolt |
| 298 | rm -f $(BUILD_DIR)/bal_core_dist |
Shad Ansari | 9acc973 | 2018-10-30 18:01:44 +0000 | [diff] [blame] | 299 | rm -f $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 300 | rm -f $(BUILD_DIR)/openolt.deb |
Shad Ansari | 1924958 | 2018-04-30 04:31:00 +0000 | [diff] [blame] | 301 | |
| 302 | distclean: |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 303 | rm -rf $(BUILD_DIR) |
Shad Ansari | cb004c5 | 2018-05-30 18:07:23 +0000 | [diff] [blame] | 304 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 305 | .PHONY: onl sdk bal protos prereq sim |