3 # Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 # 2016 - Michael Jeanson <mjeanson@efficios.com>
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.
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.
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/>.
19 # Version compare functions
22 if [[ "$1" == "$2" ]]; then
26 local i ver1
=($1) ver2
=($2)
27 # fill empty fields in ver1 with zeros
28 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
31 for ((i
=0; i
<${#ver1[@]}; i
++)); do
32 if [[ -z ${ver2[i]} ]]; then
33 # fill empty fields in ver2 with zeros
36 if ((10#${ver1[i]} > 10#${ver2[i]})); then
39 if ((10#${ver1[i]} < 10#${ver2[i]})); then
48 vercomp
"$1" "$2"; local res
="$?"
49 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
53 vercomp
"$1" "$2"; local res
="$?"
58 vercomp
"$1" "$2"; local res
="$?"
59 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
63 vercomp
"$1" "$2"; local res
="$?"
68 vercomp
"$1" "$2"; local res
="$?"
79 SRCDIR
="$WORKSPACE/src/babeltrace"
80 TMPDIR
="$WORKSPACE/tmp"
81 PREFIX
="$WORKSPACE/build"
83 # Create build and tmp directories
84 rm -rf "$PREFIX" "$TMPDIR"
85 mkdir
-p "$PREFIX" "$TMPDIR"
88 export CFLAGS
="-g -O2"
90 # Set compiler variables
122 export CXX
=clang
++-3.9
126 export CXX
=clang
++-4.0
130 export CXX
=clang
++-5.0
134 export CXX
=clang
++-6.0
141 if [ "x$cc" != "x" ]; then
147 if [ "x${CC:-}" != "x" ]; then
148 echo "Selected compiler:"
152 # Set platform variables
159 export YACC
="$BISON -y"
160 export PATH
="/opt/csw/bin:/usr/ccs/bin:$PATH"
161 export CPPFLAGS
="-I/opt/csw/include"
162 export LDFLAGS
="-L/opt/csw/lib -R/opt/csw/lib"
163 export PKG_CONFIG_PATH
="/opt/csw/lib/pkgconfig"
169 export PATH
="$PATH:/usr/perl5/bin"
170 export LD_ALTEXEC
=/usr
/bin
/gld
171 export LD
=/usr
/bin
/gld
176 export NPROC
="getconf _NPROCESSORS_ONLN"
178 export YACC
="$BISON -y"
179 export PATH
="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
180 export CFLAGS
="$CFLAGS -I/opt/local/include"
181 export LDFLAGS
="-L/opt/local/lib"
190 # Enter the source directory
193 # Run bootstrap in the source directory prior to configure
196 # Get source version from configure script
197 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
199 # Enable dev mode by default for BT 2.0 builds
200 export BABELTRACE_DEBUG_MODE
=1
201 export BABELTRACE_DEV_MODE
=1
202 export BABELTRACE_MINIMAL_LOG_LEVEL
=TRACE
204 # Set configure options for each build configuration
209 CONF_OPTS
="--enable-static --disable-shared"
210 if vergte
"$PACKAGE_VERSION" "2.0"; then
211 CONF_OPTS
="${CONF_OPTS} --enable-built-in-plugins"
215 echo "Build with python bindings"
216 # We only support bindings built with Python 3
217 export PYTHON
="python3"
218 export PYTHON_CONFIG
="python3-config"
219 CONF_OPTS
="--enable-python-bindings"
221 if vergte
"$PACKAGE_VERSION" "2.0"; then
222 CONF_OPTS
="${CONF_OPTS} --enable-python-bindings-doc --enable-python-plugins"
226 echo "Production build"
228 # Unset the developper variables
229 unset BABELTRACE_DEBUG_MODE
230 unset BABELTRACE_DEV_MODE
231 unset BABELTRACE_MINIMAL_LOG_LEVEL
233 # Enable the python bindings
234 export PYTHON
="python3"
235 export PYTHON_CONFIG
="python3-config"
236 CONF_OPTS
="--enable-python-bindings --enable-python-bindings-doc --enable-python-plugins"
243 echo "Standard build"
246 # Enable the python bindings / plugins by default with babeltrace2
247 # the test suite is mostly useless without it.
248 if vergte
"$PACKAGE_VERSION" "2.0"; then
249 export PYTHON
="python3"
250 export PYTHON_CONFIG
="python3-config"
251 CONF_OPTS
="${CONF_OPTS} --enable-python-bindings --enable-python-plugins"
257 # oot : out-of-tree build
258 # dist: build via make dist
259 # * : normal tree build
261 # Make sure to move to the build_path and configure
266 echo "Out of tree build"
267 BUILD_PATH
="$WORKSPACE/oot"
268 mkdir
-p "$BUILD_PATH"
270 "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
274 echo "Distribution out of tree build"
275 BUILD_PATH
="$(mktemp -d)"
277 # Initial configure and generate tarball
281 mkdir
-p "$BUILD_PATH"
282 cp .
/*.
tar.
* "$BUILD_PATH/"
285 # Ignore level 1 of tar
286 $TAR xvf .
/*.
tar.
* --strip 1
288 "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS
292 echo "Standard in-tree build"
293 "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
298 $MAKE -j "$($NPROC)" V
=1
302 $MAKE --keep-going check
304 # Copy tap logs for the jenkins tap parser
305 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
307 # Clean the build directory
310 # Cleanup rpath in executables and shared libraries
311 find "$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
312 find "$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
314 # Remove libtool .la files
315 find "$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
317 # Clean temp dir for dist build
318 if [ "$build" = "dist" ]; then