blob: b4b1551793ff9e1c20415bc47eb10f729dacf289 [file] [log] [blame]
Kim Kempf531d52d2017-10-02 17:10:54 -07001#
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16#
17# Run from OpenNetworkLinux top directory
18#
19#cd /aux/OpenNetworkLinux
20set -e
Kim Kempf531d52d2017-10-02 17:10:54 -070021ASFVOLT_REPO_NAME=asfvolt16-driver
Kim Kempfe109db72017-10-05 13:12:54 -070022: ${MAKE_JOBS:=4}
Kim Kempf531d52d2017-10-02 17:10:54 -070023
24# override shell variables to match custom local build environment
25: ${ONL_TOPDIR:=`pwd`}
Girish Gowdru9ebd8b22018-09-26 03:21:03 -070026: ${BALSRC_RELEASE=${BROADCOM_DOWNLOAD_DIR}/bal_src_release}
27: ${VOLTHA_TOPDIR:=${HOME}/voltha}
28: ${BALSRC_TOPDIR:=${BALSRC_RELEASE}/bal_release}
29: ${ASFSRC_TOPDIR:=${EDGECORE_DOWNLOAD_DIR}/${ASFVOLT_REPO_NAME}/src}
30: ${PATCHF_TOPDIR:=${EDGECORE_DOWNLOAD_DIR}/${ASFVOLT_REPO_NAME}/patches}
31: ${GRPC_C_PATH:=${EDGECORE_DOWNLOAD_DIR}/grpc-c}
Kim Kempf531d52d2017-10-02 17:10:54 -070032
33echo ONL_TOPDIR=${ONL_TOPDIR}
Kim Kempfe109db72017-10-05 13:12:54 -070034echo MAKE_JOBS=${MAKE_JOBS}
Kim Kempf531d52d2017-10-02 17:10:54 -070035echo BALSRC_RELEASE=${BALSRC_RELEASE}
36echo VOLTHA_TOPDIR=${VOLTHA_TOPDIR}
37echo BALSRC_TOPDIR=${BALSRC_TOPDIR}
38echo ASFSRC_TOPDIR=${ASFSRC_TOPDIR}
Kim Kempf531d52d2017-10-02 17:10:54 -070039echo PATCHF_TOPDIR=${PATCHF_TOPDIR}
40
41# archived ZIP files from "https://github.com/opennetworkinglab/asfvolt16-driver/tree/master/third_party"
42GRPC_ARCH=ed7d06af3eef1c27f10328c73b3ae3ab10d72b10
43GRPC_C_ARCH=be82ab1605717f33e2e0d3038996ea46d9efe25e
44PROTOBUF_ARCH=703cd8e11c8d34283d4c8bf869c61866e8211c9d
45PROTOBUF_C_ARCH=6a4f9a9a67c06769aaa9f65e8f89a56483271f5a
46
Girish Gowdru9ebd8b22018-09-26 03:21:03 -070047cd ${EDGECORE_DOWNLOAD_DIR}
48
Kim Kempfe109db72017-10-05 13:12:54 -070049# Note: removes existing directories: grpc, protobuf
Kim Kempf531d52d2017-10-02 17:10:54 -070050rm -rf grpc protobuf grpc-* protobuf-*
51
52#Clone asfvolt16-driver
53# - The guide assumes that the asfvolt16-driver gerrit repo is cloned under the ONL toplevel directory:
54# - git clone ssh://user@gerrit.opencord.org:29418/asfvolt16-driver ${HOME}/OpenNetworkLinux/asfvolt16-driver
55
Kim Kempfe109db72017-10-05 13:12:54 -070056#git clone https://gerrit.opencord.org/${ASFVOLT_REPO_NAME} ${ONL_TOPDIR}/${ASFVOLT_REPO_NAME}
Kim Kempf531d52d2017-10-02 17:10:54 -070057
58#steps to install grpc
59# - Download as zip "grpc", "grpc-c", "protobuf" and "protobuf-c" from "https://github.com/opennetworkinglab/asfvolt16-driver/tree/master/third_party"
Girish Gowdru9ebd8b22018-09-26 03:21:03 -070060#comment the below 4 lines and download manually in case of errors
Kim Kempf531d52d2017-10-02 17:10:54 -070061wget https://github.com/grpc/grpc/archive/${GRPC_ARCH}.zip
62wget https://github.com/Juniper/grpc-c/archive/${GRPC_C_ARCH}.zip
63wget https://github.com/google/protobuf/archive/${PROTOBUF_ARCH}.zip
64wget https://github.com/shadansari/protobuf-c/archive/${PROTOBUF_C_ARCH}.zip
65
66# - extract grpc at ${HOME}/OpenNetworkLinux/grpc
67unzip -q ${GRPC_ARCH}.zip; rm ${GRPC_ARCH}.zip
68mv grpc-${GRPC_ARCH} grpc
69
70# - extract grpc-c at ${HOME}/OpenNetworkLinux/grpc-c
71unzip -q ${GRPC_C_ARCH}.zip; rm ${GRPC_C_ARCH}.zip
72mv grpc-c-${GRPC_C_ARCH} grpc-c
73
74# - extract protobuf at ${HOME}/OpenNetworkLinux/grpc/thirdparty/protobuf
75unzip -q ${PROTOBUF_ARCH}.zip; rm ${PROTOBUF_ARCH}.zip
76mkdir -p grpc/thirdparty
77mv protobuf-${PROTOBUF_ARCH} grpc/thirdparty/protobuf
78
79
80# - extract protobuf-c folder at ${HOME}/OpenNetworkLinux/grpc-c/third_party/protobuf-c
81unzip -q ${PROTOBUF_C_ARCH}.zip; rm ${PROTOBUF_C_ARCH}.zip
82(cd protobuf-c-${PROTOBUF_C_ARCH};tar cf - .)|(cd grpc-c/third_party/protobuf-c;tar xf -)
83rm -rf protobuf-c-${PROTOBUF_C_ARCH}
84
85#steps to install grpc-c
86# cd ${HOME}/OpenNetworkLinux/grpc/thirdparty/protobuf
87# - ./autogen.sh
88# - ./configure
89# - make
90# - sudo make install
Girish Gowdru9ebd8b22018-09-26 03:21:03 -070091cd ${EDGECORE_DOWNLOAD_DIR}/grpc/thirdparty/protobuf
Kim Kempf531d52d2017-10-02 17:10:54 -070092./autogen.sh
93./configure
94make --jobs=${MAKE_JOBS}
95sudo make install
96
97# cd ${HOME}/OpenNetworkLinux/grpc
98# - export LD_LIBRARY_PATH=/usr/local/lib
99# - make
100# - sudo make install
101
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700102cd ${EDGECORE_DOWNLOAD_DIR}/grpc
Kim Kempf531d52d2017-10-02 17:10:54 -0700103export LD_LIBRARY_PATH=/usr/local/lib
104make --jobs=${MAKE_JOBS}
105sudo make install
106
107#cd ${HOME}/OpenNetworkLinux/grpc-c/third_party/protobuf-c
108#- ./autogen.sh
109#- ./configure
110#- export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/protobuf
111#- make
112#- sudo make install
113
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700114cd ${EDGECORE_DOWNLOAD_DIR}/grpc-c/third_party/protobuf-c
Kim Kempf531d52d2017-10-02 17:10:54 -0700115./autogen.sh
116./configure
117export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/protobuf
118make --jobs=${MAKE_JOBS}
119sudo make install
120
121#Apply grpc-c patch
122# - cd ${HOME}/OpenNetworkLinux/grpc-c/
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700123cd ${EDGECORE_DOWNLOAD_DIR}/grpc-c
Kim Kempf531d52d2017-10-02 17:10:54 -0700124# Patch 1:
125# Apply patch in following link for grpc-c/lib - "https://github.com/Juniper/grpc-c/commit/353b40cd920cd749ed6cf71f8df17f1d5cf2c89d"
126# Note:
127# (This patch is having very few changes in two files(grpc-c/lib/client.c, grpc-c/lib/service.c.
128# Download these two files from above link and replace at grpc-c/lib or merge these changes manually.)
129patch -p1 -i ${PATCHF_TOPDIR}/grpc-c_compile-error.patch
130
131# Patch 2:
132# Apply patch in service.c.patch and client.c.patch
133patch -p1 -i ${PATCHF_TOPDIR}/grpc-c_asfvolt16.patch
134
Kim Kempf531d52d2017-10-02 17:10:54 -0700135cd ${ONL_TOPDIR}
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700136cp ${ASFSRC_TOPDIR}/Makefile.am ${EDGECORE_DOWNLOAD_DIR}/grpc-c/examples/
137cp ${ASFSRC_TOPDIR}/voltha_bal_driver.c ${EDGECORE_DOWNLOAD_DIR}/grpc-c/examples/
Kim Kempf531d52d2017-10-02 17:10:54 -0700138
139#
140# - cd ${HOME}/OpenNetworkLinux/grpc-c
141# - autoreconf --install
142# - mkdir build && cd build
143# - ../configure
144# - make
145# - sudo make install
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700146cd ${EDGECORE_DOWNLOAD_DIR}/grpc-c
Kim Kempf531d52d2017-10-02 17:10:54 -0700147autoreconf --install
148mkdir build && cd build
149../configure
150make --jobs=${MAKE_JOBS}
151sudo make install
152
153#To obtain proto files - Have a repo sync of opencord voltha code base:
154# - git clone https://github.com/opencord/voltha.git ${HOME}/voltha
155# - cd ${HOME}/OpenNetworkLinux/grpc-c/
156# - cp ${HOME}/voltha/voltha/adapters/asfvolt16_olt/protos/* examples/
157#
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700158cd ${EDGECORE_DOWNLOAD_DIR}/grpc-c
Kim Kempf531d52d2017-10-02 17:10:54 -0700159cp ${VOLTHA_TOPDIR}/voltha/adapters/asfvolt16_olt/protos/* examples
160
161#To autogenerate code from proto files:
162# - cd ${HOME}/OpenNetworkLinux/grpc-c/build/examples
163# - make autogen
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700164cd ${EDGECORE_DOWNLOAD_DIR}/grpc-c/build/examples
Kim Kempf531d52d2017-10-02 17:10:54 -0700165make autogen
166
167#
168#Build voltha_bal_driver:
169# - cd ${HOME}/OpenNetworkLinux/grpc-c/build/examples
170# - Note: Remove "-O2" from Makefile
171# - Note: Set EDGECORE and BRCM_PATH in Makefile
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700172cd ${EDGECORE_DOWNLOAD_DIR}/grpc-c/build/examples
Kim Kempf531d52d2017-10-02 17:10:54 -0700173sed -i -e 's/-O2/-O0/g' \
174 -e "s:^EDGECORE = /home/asfvolt/shared.*:#&\nEDGECORE = ${ASFSRC_TOPDIR}:" \
175 -e "s:^BRCM_PATH = /home/asfvolt/shared.*:#&\nBRCM_PATH = ${BALSRC_TOPDIR}:" \
176 Makefile
177
178pushd ${ASFSRC_TOPDIR}
179sed -i -e "s:^BRDCM_SRC=/home/asfvolt/shared.*:#&\nBRDCM_SRC = ${BALSRC_TOPDIR}:" \
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700180 -e "s:^GRPC_C_PATH=/home/asfvolt/shared.*:#&\nGRPC_C_PATH = ${GRPC_C_PATH}:" \
181 Makefile
Kim Kempf531d52d2017-10-02 17:10:54 -0700182popd
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700183
Kim Kempf531d52d2017-10-02 17:10:54 -0700184#```
Girish Gowdru9ebd8b22018-09-26 03:21:03 -0700185# EDGECORE = ${EDGECORE_DOWNLOAD_DIR}asfvolt16-driver/src/
186# BRCM_PATH = ${BROADCOM_DOWNLOAD_DIR}/bal_src_release/bal_release
Kim Kempf531d52d2017-10-02 17:10:54 -0700187#```
188# - make clean_all;make
189make clean_all
190make
191#
192#The ultimate executable voltha_bal_driver can be found under ~/grpc-c/build/examples/.libs/
193
194echo "${ASFVOLT_REPO_NAME} build complete"