blob: 33d9578a500c9303be489934848afcb782ce5951 [file] [log] [blame]
Carmelo Casconeacf12252017-06-05 01:05:43 -04001#!/usr/bin/env bash
2# -----------------------------------------------------------------------------
3# Builds and installs all tools needed for developing and testing P4 support in
4# ONOS.
5#
6# Tested on Ubuntu 14.04.
7#
8# Recommended minimum system requirements:
9# 4 GB of RAM
10# 2 cores
11# > 5 GB free hard drive space (~4 GB to build everything)
12# -----------------------------------------------------------------------------
13
14# Exit on errors.
15set -e
16
17BMV2_COMMIT="487ee8f907153d93d4806f3e9e209ed9cb668c2b"
18PI_COMMIT="d7418b386e2301f82c1330a1d2dca131ef7b4fe3"
19P4C_COMMIT="80db63762314494b313f39c40067b3d3416007d3"
20PROTOBUF_VER="3.0.2"
21GRPC_VER="1.3.0"
22
23DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
24
25cd ${DIR}
26
27sudo apt update
28sudo apt install -y python-software-properties software-properties-common
29sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
30sudo apt update
31sudo apt install -y \
32 autoconf \
33 automake \
34 bison \
35 curl \
36 dpkg-dev \
37 flex \
38 g++-4.9 \
39 gcc-4.9 \
40 git \
41 libboost-dev \
42 libboost-iostreams-dev \
43 libfl-dev \
44 libgc-dev \
45 libgmp-dev \
46 libreadline6 \
47 libreadline6-dev \
48 libtool \
49 libc6-dev \
50 make \
51 pkg-config \
52 python \
53 python-ipaddr \
54 python-scapy \
55 tcpdump \
56 unzip
57
58# Needed for p4c.
59sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
60sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50
61
62# Protobuf
63if [ ! -d protobuf ]; then
64 git clone https://github.com/google/protobuf.git
65fi
66cd protobuf
67git fetch
68git checkout tags/v${PROTOBUF_VER}
69./autogen.sh
70./configure --prefix=/usr
71make -j2
72sudo make install
73sudo ldconfig
74
75# gRPC
76cd ${DIR}
77if [ ! -d grpc ]; then
78 git clone https://github.com/grpc/grpc.git
79fi
80cd grpc
81git fetch
82git checkout tags/v${GRPC_VER}
83git submodule update --init
84make -j2
85sudo make install
86sudo ldconfig
87
88# BMv2 part 1 (without PI)
89cd ${DIR}
90if [ ! -d bmv2 ]; then
91 git clone https://github.com/p4lang/behavioral-model.git bmv2
92fi
93cd bmv2
94git fetch
95git checkout ${BMV2_COMMIT}
96./install_deps.sh
97./autogen.sh
98./configure --enable-debugger
99make -j2
100sudo make install
101sudo ldconfig
102
103# P4Runtime (PI)
104cd ${DIR}
105if [ ! -d p4runtime ]; then
106 git clone https://github.com/p4lang/PI.git p4runtime
107fi
108cd p4runtime
109git fetch
110git checkout ${PI_COMMIT}
111git submodule update --init --recursive
112./autogen.sh
113./configure --with-bmv2 --with-proto
114make -j2
115sudo make install
116sudo ldconfig
117
118# BMv2 part 2 (with PI)
119cd ${DIR}/bmv2
120./configure --enable-debugger --with-pi
121make -j2
122sudo make install
123sudo ldconfig
124
125# Simple_switch_grpc target
126cd targets/simple_switch_grpc
127./autogen.sh
128./configure
129make -j2
130sudo make install
131sudo ldconfig
132
133# p4c
134cd ${DIR}
135if [ ! -d p4c ]; then
136 git clone https://github.com/p4lang/p4c.git
137fi
138cd p4c
139git fetch
140git checkout ${P4C_COMMIT}
141git submodule update --init --recursive
142./bootstrap.sh
143cd build
144make -j2
145sudo make install
146sudo ldconfig
147
148# p4c-bmv2 (old BMv2 compiler)
149cd ${DIR}
150if [ ! -d p4c-bmv2 ]; then
151 git clone https://github.com/p4lang/p4c-bm.git p4c-bmv2
152fi
153cd p4c-bmv2
154git fetch
155sudo pip install -r requirements.txt
156sudo python setup.py install
157
158echo "DONE!"