这里提供一个直接安装p4c的脚本:install_p4c.sh。python
1.git clone下来p4c:ios
$ git clone --recursive https://github.com/p4lang/p4c.git
注意, 若是没有使用--recursive
, 则须要再将submodule clone下来:git
[option] $ git submodule update --init --recursive
2.安装依赖:github
依赖(原文):ubuntu
$ sudo apt-get install g++ git automake libtool libgc-dev bison flex libfl-dev libgmp-dev libboost-dev libboost-iostreams-dev pkg-config python python-scapy python-ipaddr tcpdump cmake
可选, 用于生成文档:tcp
[option] $ sudo apt-get install -y doxygen graphviz texlive-full
GCC4.9升级方法: ubuntu 14.04 更新 gcc/g++ 4.9.2ide
安装protobuf: Ubuntu 14.04 下 安装Protocol Buffersflex
更新cmake: Ubuntu14.04下 升级 cmakeui
3.构建:
$ mkdir build $ cd build $ cmake .. [-DCMAKE_BUILD_TYPE=RELEASE|DEBUG] [-DCMAKE_INSTALL_PREFIX=<path>] [-DENABLE_DOCS=ON (default off)] [-DENABLE_P4RUNTIME_TO_PD=OFF (default on)] $ make -j4 $ make -j4 check
4.安装:
$ sudo make install
2017.9