session: optimize ct fifo segment allocations
[vpp.git] / configure
1 #!/usr/bin/env bash
2 set -o pipefail -o errtrace -o nounset -o errexit
3
4 # Experimental script, please consult with dmarion@me.com before
5 # submitting any changes
6
7 # defaults
8 build_dir=.
9 install_dir=/usr/local
10 build_type=release
11 prefix_path=/opt/vpp/external/$(uname -m)/
12 src_dir="$(dirname "$(readlink -f "$0")")"
13
14 help()
15 {
16   cat << __EOF__
17 VPP Build Configuration Script
18
19 USAGE: ${0} [options]
20
21 OPTIONS:
22   --help, -h              This help
23   --build-dir, -b         Build directory
24   --install-dir, -i       Install directory
25   --build-type, -t        Build type (release, debug, ...)
26   --wipe, -w              Wipe whole repo (except startup.* files)
27 __EOF__
28 }
29
30 while (( "$#" )); do
31   case "$1" in
32     -h|--help)
33       help
34       exit 1
35       ;;
36     -b|--build-dir)
37       if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
38         build_dir=$2
39         shift 2
40       else
41         echo "Error: Argument for $1 is missing" >&2
42         exit 1
43       fi
44       ;;
45     -i|--install-dir)
46       if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
47         install_dir=$2
48         shift 2
49       else
50         echo "Error: Argument for $1 is missing" >&2
51         exit 1
52       fi
53       ;;
54     -t|--build-type)
55       if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
56         build_type=$2
57         shift 2
58       else
59         echo "Error: Argument for $1 is missing" >&2
60         exit 1
61       fi
62       ;;
63     -w|--wipe)
64       git clean -fdx --exclude=startup.\*
65       exit 1
66       ;;
67     -*|--*=) # unsupported flags
68       echo "Error: Unsupported flag $1" >&2
69       exit 1
70       ;;
71     *) # preserve positional arguments
72       PARAMS="$PARAMS $1"
73       shift
74       ;;
75   esac
76 done
77
78 cmake \
79   -G Ninja \
80   -S ${src_dir}/src \
81   -B ${build_dir} \
82   -DCMAKE_PREFIX_PATH=${prefix_path} \
83   -DCMAKE_INSTALL_PREFIX=${install_dir} \
84   -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \
85   -DCMAKE_BUILD_TYPE:STRING=${build_type}
86
87   cat << __EOF__
88
89   Useful build commands:
90
91   ninja                   Build VPP
92   ninja set-build-type-*  Change build type to <debug|release|gcov|...>
93   ninja config            Start build configuration TUI
94   ninja run               Runs VPP using startup.conf in the build directory
95   ninja debug             Runs VPP inside GDB using startup.conf in the build directory
96   ninja pkg-deb           Create .deb packages
97   ninja install           Install VPP to $install_dir
98
99 __EOF__