Carmelo Cascone | acf1225 | 2017-06-05 01:05:43 -0400 | [diff] [blame^] | 1 | #!/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. |
| 15 | set -e |
| 16 | |
| 17 | BMV2_COMMIT="487ee8f907153d93d4806f3e9e209ed9cb668c2b" |
| 18 | PI_COMMIT="d7418b386e2301f82c1330a1d2dca131ef7b4fe3" |
| 19 | P4C_COMMIT="80db63762314494b313f39c40067b3d3416007d3" |
| 20 | PROTOBUF_VER="3.0.2" |
| 21 | GRPC_VER="1.3.0" |
| 22 | |
| 23 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 24 | |
| 25 | cd ${DIR} |
| 26 | |
| 27 | sudo apt update |
| 28 | sudo apt install -y python-software-properties software-properties-common |
| 29 | sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test |
| 30 | sudo apt update |
| 31 | sudo 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. |
| 59 | sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50 |
| 60 | sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50 |
| 61 | |
| 62 | # Protobuf |
| 63 | if [ ! -d protobuf ]; then |
| 64 | git clone https://github.com/google/protobuf.git |
| 65 | fi |
| 66 | cd protobuf |
| 67 | git fetch |
| 68 | git checkout tags/v${PROTOBUF_VER} |
| 69 | ./autogen.sh |
| 70 | ./configure --prefix=/usr |
| 71 | make -j2 |
| 72 | sudo make install |
| 73 | sudo ldconfig |
| 74 | |
| 75 | # gRPC |
| 76 | cd ${DIR} |
| 77 | if [ ! -d grpc ]; then |
| 78 | git clone https://github.com/grpc/grpc.git |
| 79 | fi |
| 80 | cd grpc |
| 81 | git fetch |
| 82 | git checkout tags/v${GRPC_VER} |
| 83 | git submodule update --init |
| 84 | make -j2 |
| 85 | sudo make install |
| 86 | sudo ldconfig |
| 87 | |
| 88 | # BMv2 part 1 (without PI) |
| 89 | cd ${DIR} |
| 90 | if [ ! -d bmv2 ]; then |
| 91 | git clone https://github.com/p4lang/behavioral-model.git bmv2 |
| 92 | fi |
| 93 | cd bmv2 |
| 94 | git fetch |
| 95 | git checkout ${BMV2_COMMIT} |
| 96 | ./install_deps.sh |
| 97 | ./autogen.sh |
| 98 | ./configure --enable-debugger |
| 99 | make -j2 |
| 100 | sudo make install |
| 101 | sudo ldconfig |
| 102 | |
| 103 | # P4Runtime (PI) |
| 104 | cd ${DIR} |
| 105 | if [ ! -d p4runtime ]; then |
| 106 | git clone https://github.com/p4lang/PI.git p4runtime |
| 107 | fi |
| 108 | cd p4runtime |
| 109 | git fetch |
| 110 | git checkout ${PI_COMMIT} |
| 111 | git submodule update --init --recursive |
| 112 | ./autogen.sh |
| 113 | ./configure --with-bmv2 --with-proto |
| 114 | make -j2 |
| 115 | sudo make install |
| 116 | sudo ldconfig |
| 117 | |
| 118 | # BMv2 part 2 (with PI) |
| 119 | cd ${DIR}/bmv2 |
| 120 | ./configure --enable-debugger --with-pi |
| 121 | make -j2 |
| 122 | sudo make install |
| 123 | sudo ldconfig |
| 124 | |
| 125 | # Simple_switch_grpc target |
| 126 | cd targets/simple_switch_grpc |
| 127 | ./autogen.sh |
| 128 | ./configure |
| 129 | make -j2 |
| 130 | sudo make install |
| 131 | sudo ldconfig |
| 132 | |
| 133 | # p4c |
| 134 | cd ${DIR} |
| 135 | if [ ! -d p4c ]; then |
| 136 | git clone https://github.com/p4lang/p4c.git |
| 137 | fi |
| 138 | cd p4c |
| 139 | git fetch |
| 140 | git checkout ${P4C_COMMIT} |
| 141 | git submodule update --init --recursive |
| 142 | ./bootstrap.sh |
| 143 | cd build |
| 144 | make -j2 |
| 145 | sudo make install |
| 146 | sudo ldconfig |
| 147 | |
| 148 | # p4c-bmv2 (old BMv2 compiler) |
| 149 | cd ${DIR} |
| 150 | if [ ! -d p4c-bmv2 ]; then |
| 151 | git clone https://github.com/p4lang/p4c-bm.git p4c-bmv2 |
| 152 | fi |
| 153 | cd p4c-bmv2 |
| 154 | git fetch |
| 155 | sudo pip install -r requirements.txt |
| 156 | sudo python setup.py install |
| 157 | |
| 158 | echo "DONE!" |