Lava: kernel: append config for x86_64 kvm
[lttng-ci.git] / scripts / lttng-tools / build.sh
CommitLineData
0cdaa21c 1#!/bin/bash -xue
b4005bbf
MJ
2#
3# Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4# Michael Jeanson <mjeanson@efficios.com>
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
0cdaa21c
MJ
19# Version compare functions
20verlte() {
21 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | head -n1`" ]
22}
23
24verlt() {
25 [ "$1" = "$2" ] && return 1 || verlte $1 $2
26}
27
28vergte() {
29 [ "$1" = "`printf '%s\n%s' $1 $2 | sort -V | tail -n1`" ]
30}
31
32vergt() {
33 [ "$1" = "$2" ] && return 1 || vergte $1 $2
34}
35
b4005bbf
MJ
36
37# Create build directory
38rm -rf $WORKSPACE/build
39mkdir -p $WORKSPACE/build
40
41# liburcu
42URCU_INCS="$WORKSPACE/deps/liburcu/build/include/"
43URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/"
44
45# lttng-ust
46UST_INCS="$WORKSPACE/deps/lttng-ust/build/include/"
47UST_LIBS="$WORKSPACE/deps/lttng-ust/build/lib/"
95654431 48UST_JAVA="$WORKSPACE/deps/lttng-ust/build/share/java/"
b4005bbf
MJ
49
50# babeltrace
51BABEL_INCS="$WORKSPACE/deps/babeltrace/build/include/"
52BABEL_LIBS="$WORKSPACE/deps/babeltrace/build/lib/"
53BABEL_BINS="$WORKSPACE/deps/babeltrace/build/bin/"
54
55PREFIX="$WORKSPACE/build"
56
0cdaa21c
MJ
57# Set platform variables
58case "$arch" in
59solaris10)
60 MAKE=gmake
61 TAR=gtar
62 NPROC=gnproc
63 BISON="bison"
64 YACC="$BISON -y"
65 CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1"
66 RUN_TESTS="no"
67 ;;
68
69solaris11)
70 MAKE=gmake
71 TAR=gtar
72 NPROC=nproc
73 BISON="/opt/csw/bin/bison"
74 YACC="$BISON -y"
75 CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1"
76 RUN_TESTS="no"
77
78 export PATH="$PATH:/usr/perl5/bin"
79 ;;
80
81*)
82 MAKE=make
83 TAR=tar
84 NPROC=nproc
85 BISON="bison"
86 YACC="$BISON -y"
87 CFLAGS=""
88 RUN_TESTS="yes"
89
90 PYTHON2=python2
91 PYTHON3=python3
92
93 P2_VERSION=$($PYTHON2 -c "import sys;print(sys.version[:3])")
94 P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])")
95
96 UST_PYTHON2="$WORKSPACE/deps/lttng-ust/build/lib/python$P2_VERSION/site-packages"
97 UST_PYTHON3="$WORKSPACE/deps/lttng-ust/build/lib/python$P3_VERSION/site-packages"
98 ;;
99esac
100
101
102# Run bootstrap prior to configure
103./bootstrap
104
105# Get source version from configure script
106eval `grep '^PACKAGE_VERSION=' ./configure`
107
108
109# Export build flags
110case "$conf" in
111no-ust)
b4005bbf
MJ
112 export CPPFLAGS="-I$URCU_INCS"
113 export LDFLAGS="-L$URCU_LIBS"
114 export LD_LIBRARY_PATH="$URCU_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}"
0cdaa21c
MJ
115 ;;
116
117*)
b4005bbf
MJ
118 export CPPFLAGS="-I$URCU_INCS -I$UST_INCS"
119 export LDFLAGS="-L$URCU_LIBS -L$UST_LIBS"
120 export LD_LIBRARY_PATH="$URCU_LIBS:$UST_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}"
0cdaa21c
MJ
121 ;;
122esac
b4005bbf 123
0cdaa21c
MJ
124# The switch to build without UST changed in 2.8
125if vergte "$PACKAGE_VERSION" "2.8"; then
126 NO_UST="--without-lttng-ust"
127else
128 NO_UST="--disable-lttng-ust"
129fi
b4005bbf 130
0cdaa21c 131# Set configure options for each build configuration
b4005bbf
MJ
132CONF_OPTS=""
133case "$conf" in
0cdaa21c
MJ
134static)
135 echo "Static build"
136 CONF_OPTS="--enable-static --disable-shared"
137 ;;
138
139python-bindings)
140 echo "Build with python bindings"
141 # We only support bindings built with Python 3
142 export PYTHON="python3"
143 export PYTHON_CONFIG="/usr/bin/python3-config"
144 CONF_OPTS="--enable-python-bindings"
145 ;;
146
147no-ust)
148 echo "Build without UST support"
149 CONF_OPTS="$NO_UST"
150 ;;
151
152java-agent)
153 echo "Build with Java Agents"
154 export JAVA_HOME="/usr/lib/jvm/default-java"
155 export CLASSPATH="$UST_JAVA/*:/usr/share/java/*"
156 CONF_OPTS="--enable-test-java-agent-all"
157 ;;
158
159python-agent)
160 echo "Build with python agents"
161 export PYTHONPATH="$UST_PYTHON2:$UST_PYTHON3"
162 CONF_OPTS="--enable-test-python-agent-all"
163 ;;
164
165relayd-only)
166 echo "Build relayd only"
167 CONF_OPTS="--disable-bin-lttng --disable-bin-lttng-consumerd --disable-bin-lttng-crash --disable-bin-lttng-sessiond --disable-extras $NO_UST"
168 ;;
169
170*)
171 echo "Standard build"
172 CONF_OPTS=""
173 ;;
b4005bbf
MJ
174esac
175
0cdaa21c 176
b4005bbf
MJ
177# Build type
178# oot : out-of-tree build
179# dist: build via make dist
180# * : normal tree build
181#
0cdaa21c 182# Make sure to move to the build_path and run configure
b4005bbf 183# before continuing
b4005bbf
MJ
184BUILD_PATH=$WORKSPACE
185case "$build" in
95654431
MJ
186 oot)
187 echo "Out of tree build"
188 BUILD_PATH=$WORKSPACE/oot
189 mkdir -p $BUILD_PATH
190 cd $BUILD_PATH
0cdaa21c 191 MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
95654431
MJ
192 ;;
193
194 dist)
195 echo "Distribution out of tree build"
196 BUILD_PATH=`mktemp -d`
197
198 # Initial configure and generate tarball
0cdaa21c
MJ
199 MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" ./configure $CONF_OPTS
200 $MAKE dist
95654431
MJ
201
202 mkdir -p $BUILD_PATH
203 cp *.tar.* $BUILD_PATH/
204 cd $BUILD_PATH
205
206 # Ignore level 1 of tar
0cdaa21c 207 $TAR xvf *.tar.* --strip 1
95654431 208
0cdaa21c 209 MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS
95654431
MJ
210 ;;
211
212 *)
213 BUILD_PATH=$WORKSPACE
214 echo "Standard tree build"
0cdaa21c 215 MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" $WORKSPACE/configure --prefix=$PREFIX $CONF_OPTS
95654431 216 ;;
b4005bbf
MJ
217esac
218
0cdaa21c 219# BUILD!
fe584a39 220$MAKE -j `$NPROC` V=1
0cdaa21c 221$MAKE install
b4005bbf
MJ
222
223# Run tests
0cdaa21c
MJ
224if [ "$RUN_TESTS" = "yes" ]; then
225 # Allow core dumps
226 ulimit -c unlimited
227
228 # Add 'babeltrace' binary to PATH
229 chmod +x $BABEL_BINS/babeltrace
230 export PATH="$PATH:$BABEL_BINS"
231
232 # Prepare tap output dirs
233 rm -rf $WORKSPACE/tap
234 mkdir -p $WORKSPACE/tap
235 mkdir -p $WORKSPACE/tap/unit
236 mkdir -p $WORKSPACE/tap/fast_regression
237 mkdir -p $WORKSPACE/tap/with_bindings_regression
238
239 cd $BUILD_PATH/tests
240
241 # Run 'unit_tests' and 'fast_regression' test suites for all configs except 'no-ust'
242 if [ "$conf" != "no-ust" ]; then
243 prove --merge -v --exec '' - < $BUILD_PATH/tests/unit_tests --archive $WORKSPACE/tap/unit/ || true
244 prove --merge -v --exec '' - < $BUILD_PATH/tests/fast_regression --archive $WORKSPACE/tap/fast_regression/ || true
245 else
246 # Regression is disabled for now, we need to adjust the testsuite for no ust builds.
247 echo "Testsuite disabled for 'no-ust'. See job configuration for more info."
248 fi
249
250 # Run 'with_bindings_regression' test suite for 'python-bindings' config
251 if [ "$conf" = "python-bindings" ]; then
252 prove --merge -v --exec '' - < $WORKSPACE/tests/with_bindings_regression --archive $WORKSPACE/tap/with_bindings_regression/ || true
253 fi
254
255 # TAP plugin is having a hard time with .yml files.
256 rm -f $WORKSPACE/tap/unit/meta.yml
257 rm -f $WORKSPACE/tap/fast_regression/meta.yml
258 rm -f $WORKSPACE/tap/with_bindings_regression/meta.yml
259
260 # And also with files without extension, so rename all result to *.tap
261 find $WORKSPACE/tap/unit/ -type f -exec mv {} {}.tap \;
262 find $WORKSPACE/tap/fast_regression/ -type f -exec mv {} {}.tap \;
263 find $WORKSPACE/tap/with_bindings_regression/ -type f -exec mv {} {}.tap \;
b4005bbf
MJ
264fi
265
b4005bbf 266# Cleanup
0cdaa21c 267$MAKE clean
b4005bbf 268
0cdaa21c
MJ
269# Cleanup rpath in executables and shared libraries
270find $WORKSPACE/build/bin -type f -perm -0500 -exec chrpath --delete {} \;
b4005bbf 271find $WORKSPACE/build/lib -name "*.so" -exec chrpath --delete {} \;
0cdaa21c
MJ
272
273# Remove libtool .la files
b4005bbf
MJ
274find $WORKSPACE/build/lib -name "*.la" -exec rm -f {} \;
275
276# Clean temp dir for dist build
0cdaa21c
MJ
277if [ "$build" = "dist" ]; then
278 cd $WORKSPACE
279 rm -rf $BUILD_PATH
b4005bbf 280fi
95654431
MJ
281
282# EOF
This page took 0.053866 seconds and 4 git commands to generate.