licenses: Add license headers
[ovsnfv.git] / fuel-plugin-ovsnfv / deployment_scripts / puppet / modules / ovsdpdk / files / build_ovs_dpdk.erb
1 #!/usr/bin/env  bash
2
3 # Copyright (c) 2016 Open Platform for NFV Project, Inc. and its contributors
4 #
5 #    Licensed under the Apache License, Version 2.0 (the "License");
6 #    you may not use this file except in compliance with the License.
7 #    You may obtain a copy of the License at
8 #
9 #        http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #    Unless required by applicable law or agreed to in writing, software
12 #    distributed under the License is distributed on an "AS IS" BASIS,
13 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #    See the License for the specific language governing permissions and
15 #    limitations under the License.
16
17 set -o xtrace
18
19 if [  -e <%= @ovs_dir %>/BUILD_COMPLETE ]; then
20    echo "Build already done."
21    cd <%= @ovs_dir %>
22    sudo make install
23 else
24    cd <%= @ovs_dpdk_dir %>
25    make config T=<%= @rte_target %>
26
27    if [ -e <%= @ovs_dpdk_dir %>/<%= @rte_target %> ]; then
28       rm <%= @rte_target %>
29    fi
30
31    # block of code with more strict error handling
32    set -o errexit
33    ln -s -f build <%= @rte_target %>
34    sed "s/CONFIG_RTE_BUILD_COMBINE_LIBS=n/CONFIG_RTE_BUILD_COMBINE_LIBS=y/" -i <%= @ovs_dpdk_dir %>/build/.config
35    sed "s/CONFIG_RTE_MAX_MEMSEG=.*$/CONFIG_RTE_MAX_MEMSEG=<%= @ovs_dpdk_mem_segments %>/" -i <%= @ovs_dpdk_dir %>/build/.config
36    sed "s/CONFIG_RTE_LIBRTE_VHOST=.*$/CONFIG_RTE_LIBRTE_VHOST=<%= @ovs_dpdk_rte_librte_vhost %>/" -i <%= @ovs_dpdk_dir %>/build/.config
37    sed "s/CONFIG_RTE_LIBRTE_VHOST_DEBUG=.*$/CONFIG_RTE_LIBRTE_VHOST_DEBUG=<%= @ovs_dpdk_vhost_user_debug %>/" -i <%= @ovs_dpdk_dir %>/build/.config
38    make -j `nproc`
39    sudo cp <%= @ovs_dpdk_dir %>/build/lib/*dpdk.* /lib
40    cd <%= @ovs_dir %>
41    ./boot.sh
42    ./configure --with-dpdk=<%= @ovs_dpdk_dir %>/<%= @rte_target %> --prefix=/usr --with-dbdir=<%= @ovs_db_conf_dir %> --with-rundir=<%= @ovs_db_socket_dir %>
43    make -j `nproc` CFLAGS='-O3 -march=native'
44    touch <%= @ovs_dir %>/BUILD_COMPLETE
45    sudo make install
46    set +o errexit
47 fi
48
49
50 set +o xtrace