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 | ## |
| 22 | DEVICE = asfvolt16 |
| 23 | # |
| 24 | # Three vendor proprietary source files are required to build BAL. |
| 25 | # SW-BCM68620_<VER>.zip - Broadcom BAL source and Maple SDK. |
| 26 | # sdk-all-<SDK_VER>.tar.gz - Broadcom Qumran SDK. |
| 27 | # ACCTON_BAL_<BAL_VER>-<ACCTON_VER>.patch - Accton/Edgecore's patch. |
| 28 | BAL_MAJOR_VER = 02.04 |
| 29 | BAL_VER = 2.4.3.6 |
| 30 | SDK_VER = 6.5.7 |
| 31 | ACCTON_VER = 201710131639 |
| 32 | # |
| 33 | # Version of Open Network Linux (ONL). |
| 34 | ONL_KERN_VER_MAJOR = 3.7 |
| 35 | ONL_KERN_VER_MINOR = 10 |
| 36 | # |
| 37 | # Build directory |
| 38 | BUILD_DIR = build |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 39 | # |
| 40 | # GRPC installation |
| 41 | GRPC_ADDR = https://github.com/grpc/grpc |
| 42 | GRPC_DST = /tmp/grpc |
| 43 | GRPC_VER = v1.10.x |
| 44 | # |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 45 | ######################################################################## |
| 46 | ## |
| 47 | ## |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 48 | ## Install prerequisites |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 49 | ## |
| 50 | ## |
| 51 | HOST_SYSTEM = $(shell uname | cut -f 1 -d_) |
| 52 | SYSTEM ?= $(HOST_SYSTEM) |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 53 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 54 | CXX = g++ |
| 55 | CPPFLAGS += `pkg-config --cflags protobuf grpc` |
| 56 | CXXFLAGS += -std=c++11 -fpermissive -Wno-literal-suffix |
| 57 | ifeq ($(SYSTEM),Darwin) |
| 58 | LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\ |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 59 | -lgrpc++_reflection\ |
| 60 | -ldl |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 61 | else |
| 62 | LDFLAGS += -L/usr/local/lib `pkg-config --libs protobuf grpc++ grpc`\ |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 63 | -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed\ |
| 64 | -ldl |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 65 | endif |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 66 | |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 67 | prereq: |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 68 | sudo apt-get -q -y install git pkg-config build-essential autoconf libtool libgflags-dev libgtest-dev clang libc++-dev |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 69 | |
| 70 | # Install GRPC plugins |
| 71 | rm -rf $(GRPC_DST) |
| 72 | git clone -b $(GRPC_VER) $(GRPC_ADDR) $(GRPC_DST) |
| 73 | cd $(GRPC_DST) && git submodule update --init |
| 74 | make -C $(GRPC_DST) |
| 75 | sudo make -C $(GRPC_DST) install |
| 76 | # Install libprotobuf and protoc |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 77 | cd $(GRPC_DST)/third_party/protobuf && ./autogen.sh |
| 78 | cd $(GRPC_DST)/third_party/protobuf && ./configure |
| 79 | make -C $(GRPC_DST)/third_party/protobuf |
| 80 | sudo make -C $(GRPC_DST)/third_party/protobuf install |
| 81 | sudo ldconfig |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 82 | |
| 83 | ######################################################################## |
| 84 | ## |
| 85 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 86 | ## ONL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 87 | ## |
| 88 | ## |
| 89 | ONL_KERN_VER = $(ONL_KERN_VER_MAJOR).$(ONL_KERN_VER_MINOR) |
| 90 | ONL_REPO = $(DEVICE)-onl |
| 91 | ONL_DIR = $(BUILD_DIR)/$(ONL_REPO) |
| 92 | .PHONY: onl |
| 93 | onl: |
| 94 | if [ ! -d "$(ONL_DIR)/OpenNetworkLinux" ]; then \ |
| 95 | mkdir -p $(ONL_DIR); \ |
Luca Prete | b788628 | 2018-04-06 15:34:08 -0700 | [diff] [blame] | 96 | git clone https://gerrit.opencord.org/$(ONL_REPO) $(ONL_DIR); \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 97 | make -C $(ONL_DIR) $(DEVICE)-$(ONL_KERN_VER_MAJOR); \ |
| 98 | fi; |
| 99 | onl-force: |
| 100 | make -C $(ONL_DIR) $(DEVICE)-$(ONL_KERN_VER_MAJOR) |
| 101 | clean-onl: |
| 102 | distclean-onl: |
| 103 | sudo rm -rf $(ONL_DIR) |
| 104 | |
| 105 | ######################################################################## |
| 106 | ## |
| 107 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 108 | ## BAL |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 109 | ## |
| 110 | ## |
| 111 | BAL_ZIP = SW-BCM68620_$(subst .,_,$(BAL_VER)).zip |
| 112 | SDK_ZIP = sdk-all-$(SDK_VER).tar.gz |
| 113 | ACCTON_PATCH = ACCTON_BAL_$(BAL_VER)-V$(ACCTON_VER).patch |
| 114 | OPENOLT_BAL_PATCH = OPENOLT_BAL_$(BAL_VER).patch |
| 115 | BAL_DIR = $(BUILD_DIR)/$(DEVICE)-bal |
| 116 | ONL_KERNDIR = $(PWD)/$(ONL_DIR)/OpenNetworkLinux/packages/base/amd64/kernels/kernel-$(ONL_KERN_VER_MAJOR)-x86-64-all/builds |
| 117 | MAPLE_KERNDIR = $(BAL_DIR)/bcm68620_release/$(DEVICE)/kernels |
| 118 | BCM_SDK = $(BAL_DIR)/bal_release/3rdparty/bcm-sdk |
| 119 | BALLIBDIR = $(BAL_DIR)/bal_release/build/core/lib |
| 120 | BALLIBNAME = bal_api_dist |
| 121 | BAL_INC = -I$(BAL_DIR)/bal_release/src/common/os_abstraction \ |
| 122 | -I$(BAL_DIR)/bal_release/src/common/os_abstraction/posix \ |
| 123 | -I$(BAL_DIR)/bal_release/src/common/config \ |
| 124 | -I$(BAL_DIR)/bal_release/src/core/platform \ |
| 125 | -I$(BAL_DIR)/bal_release/src/common/include \ |
| 126 | -I$(BAL_DIR)/bal_release/src/lib/libbalapi \ |
| 127 | -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/utils \ |
| 128 | -I$(BAL_DIR)/bal_release/src/balapiend \ |
| 129 | -I$(BAL_DIR)/bal_release/src/common/dev_log \ |
| 130 | -I$(BAL_DIR)/bal_release/src/common/bal_dist_utils \ |
| 131 | -I$(BAL_DIR)/bal_release/src/lib/libtopology \ |
| 132 | -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/model \ |
| 133 | -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_driver/api \ |
| 134 | -I$(BAL_DIR)/bal_release/src/lib/libcmdline \ |
| 135 | -I$(BAL_DIR)/bal_release/src/lib/libutils \ |
| 136 | -I$(BAL_DIR)/bal_release/3rdparty/maple/sdk/host_reference/cli |
| 137 | CXXFLAGS += $(BAL_INC) -I $(BAL_DIR)/lib/cmdline |
| 138 | .PHONY: get-$(BAL_DIR) |
| 139 | get-$(BAL_DIR): |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 140 | # if [ ! -e "download/$(BAL_ZIP)" ]; then \ |
| 141 | # rm -rf /tmp/broadcom-proprietary; \ |
| 142 | # git clone git@github.com:shadansari/broadcom-proprietary.git /tmp/broadcom-proprietary; \ |
| 143 | # mv -f /tmp/broadcom-proprietary/$(BAL_VER)/$(BAL_ZIP) ./download; \ |
| 144 | # mv -f /tmp/broadcom-proprietary/$(BAL_VER)/$(SDK_ZIP) ./download; \ |
| 145 | # mv -f /tmp/broadcom-proprietary/$(BAL_VER)/$(ACCTON_PATCH) ./download; \ |
| 146 | # mv -f /tmp/broadcom-proprietary/$(BAL_VER)/$(OPENOLT_BAL_PATCH) ./download; \ |
| 147 | # rm -rf /tmp/broadcom-proprietary; \ |
| 148 | # fi; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 149 | .PHONY: bal |
| 150 | bal: onl get-$(BAL_DIR) |
| 151 | ifeq ("$(wildcard $(BAL_DIR))","") |
| 152 | mkdir $(BAL_DIR) |
| 153 | unzip download/$(BAL_ZIP) -d $(BAL_DIR) |
| 154 | cp download/$(SDK_ZIP) $(BCM_SDK) |
| 155 | chmod -R 744 $(BAL_DIR) |
| 156 | cat download/$(ACCTON_PATCH) | patch -p1 -d $(BAL_DIR) |
| 157 | mkdir -p $(MAPLE_KERNDIR) |
| 158 | ln -s $(ONL_KERNDIR)/linux-$(ONL_KERN_VER) $(MAPLE_KERNDIR)/linux-$(ONL_KERN_VER) |
| 159 | ln -s $(ONL_DIR)/OpenNetworkLinux/packages/base/any/kernels/archives/linux-$(ONL_KERN_VER).tar.xz $(MAPLE_KERNDIR)/linux-$(ONL_KERN_VER).tar.xz |
| 160 | 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 |
| 161 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) maple_sdk_dir |
| 162 | cat download/$(OPENOLT_BAL_PATCH) | patch -p1 -d $(BAL_DIR) |
| 163 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) maple_sdk |
| 164 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) switch_sdk_dir |
| 165 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) switch_sdk |
| 166 | KERNDIR=$(ONL_KERNDIR)/linux-$(ONL_KERN_VER) BOARD=$(DEVICE) ARCH=x86_64 SDKBUILD=build_bcm_user make -C $(BCM_SDK)/build-$(DEVICE)/sdk-all-$(SDK_VER)/systems/linux/user/x86-generic_64-2_6 |
| 167 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) bal |
| 168 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) release_board |
| 169 | ln -s -f $(PWD)/$(BAL_DIR)/bcm68620_release/asfvolt16/release/release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz . |
| 170 | ln -s -f $(PWD)/$(BAL_DIR)/bal_release/build/core/lib/libbal_api_dist.so . |
| 171 | ln -s -f $(PWD)/$(BAL_DIR)/bal_release/build/core/src/apps/bal_core_dist/bal_core_dist |
| 172 | mv -f release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz $(BUILD_DIR) |
| 173 | mv -f libbal_api_dist.so $(BUILD_DIR) |
| 174 | mv -f bal_core_dist $(BUILD_DIR) |
| 175 | endif |
| 176 | bal-rebuild: |
| 177 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) maple_sdk |
| 178 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) switch_sdk |
| 179 | KERNDIR=$(ONL_KERNDIR)/linux-$(ONL_KERN_VER) BOARD=$(DEVICE) ARCH=x86_64 SDKBUILD=build_bcm_user make -C $(BCM_SDK)/build-$(DEVICE)/sdk-all-$(SDK_VER)/systems/linux/user/x86-generic_64-2_6 |
| 180 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) bal |
| 181 | make -C $(BAL_DIR)/bal_release BOARD=$(DEVICE) release_board |
| 182 | ln -s -f $(PWD)/$(BAL_DIR)/bcm68620_release/asfvolt16/release/release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz . |
| 183 | ln -s -f $(PWD)/$(BAL_DIR)/bal_release/build/core/lib/libbal_api_dist.so . |
| 184 | ln -s -f $(PWD)/$(BAL_DIR)/bal_release/build/core/src/apps/bal_core_dist/bal_core_dist . |
| 185 | mv -f release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz $(BUILD_DIR) |
| 186 | mv -f libbal_api_dist.so $(BUILD_DIR) |
| 187 | mv -f bal_core_dist $(BUILD_DIR) |
| 188 | clean-bal: clean-onl |
| 189 | distclean-bal: distclean-onl |
| 190 | sudo rm -rf $(BAL_DIR) |
| 191 | rm -f build/release_$(DEVICE)_V$(BAL_MAJOR_VER).$(ACCTON_VER).tar.gz |
| 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 | ## |
| 199 | OPENOLT_API_DIR = $(BUILD_DIR)/openolt-api |
| 200 | OPENOLT_API_LIB = $(OPENOLT_API_DIR)/libopenoltapi.a |
| 201 | CXXFLAGS += -I./$(OPENOLT_API_DIR) -I $(OPENOLT_API_DIR)/googleapis/gens |
| 202 | .PHONY: openolt-api |
| 203 | openolt-api: |
| 204 | if [ ! -e "$(OPENOLT_API_DIR)" ]; then \ |
| 205 | mkdir -p $(BUILD_DIR); \ |
Luca Prete | b788628 | 2018-04-06 15:34:08 -0700 | [diff] [blame] | 206 | git clone https://gerrit.opencord.org/openolt-api $(OPENOLT_API_DIR); \ |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 207 | fi; |
| 208 | make -C $(OPENOLT_API_DIR) all |
| 209 | clean-openolt-api: |
| 210 | -make -C $(OPENOLT_API_DIR) clean |
| 211 | distclean-openolt-api: |
| 212 | |
| 213 | ######################################################################## |
| 214 | ## |
| 215 | ## |
Luca Prete | e75aaa5 | 2018-04-13 12:19:12 -0700 | [diff] [blame] | 216 | ## Main |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 217 | ## |
| 218 | ## |
| 219 | SRCS = $(wildcard src/*.cc) |
| 220 | OBJS = $(SRCS:.cc=.o) |
| 221 | DEPS = $(SRCS:.cc=.d) |
| 222 | .DEFAULT_GOAL := all |
| 223 | all: $(BUILD_DIR)/openolt |
Luca Prete | 08e6f80 | 2018-04-17 11:49:45 -0700 | [diff] [blame] | 224 | $(BUILD_DIR)/openolt: openolt-api bal $(OBJS) |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 225 | $(CXX) $(OBJS) $(LDFLAGS) $(OPENOLT_API_LIB) -o $@ -L$(BALLIBDIR) -l$(BALLIBNAME) |
Shad Ansari | a0eeec5 | 2018-04-18 22:05:38 +0000 | [diff] [blame] | 226 | ln -s $(shell ldconfig -p | grep libgrpc.so.6 | tr ' ' '\n' | grep /) $(BUILD_DIR)/libgrpc.so.6 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 227 | ln -s $(shell ldconfig -p | grep libgrpc++.so.1 | tr ' ' '\n' | grep /) $(BUILD_DIR)/libgrpc++.so.1 |
| 228 | ln -s $(shell ldconfig -p | grep libgrpc++_reflection.so.1 | tr ' ' '\n' | grep /) $(BUILD_DIR)/libgrpc++_reflection.so.1 |
| 229 | |
| 230 | src/%.o: %.cpp |
| 231 | $(CXX) -MMD -c $< -o $@ |
| 232 | |
| 233 | clean: clean-bal |
| 234 | rm -f $(OBJS) $(DEPS) $(BUILD_DIR)/openolt |
| 235 | rm -rf $(OPENOLT_API_DIR) |
Shad Ansari | a0eeec5 | 2018-04-18 22:05:38 +0000 | [diff] [blame] | 236 | rm -f $(BUILD_DIR)/libgrpc.so.6 $(BUILD_DIR)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++_reflection.so.1 |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 237 | distclean: distclean-openolt-api distclean-bal |
| 238 | rm -rf $(BUILD_DIR) |
| 239 | -include $(DEPS) |