jjb: Fix msys2 mingw32/64 builds
[lttng-ci.git] / scripts / babeltrace / build.sh
CommitLineData
c56b9301 1#!/bin/bash -exu
890bff23
MJ
2#
3# Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
0e9967db 4# 2016 - Michael Jeanson <mjeanson@efficios.com>
890bff23
MJ
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
a57a60d9
MJ
19# Required parameters
20arch=${arch:-}
21conf=${conf:-}
22build=${build:-}
23
c56b9301 24
e6be9fb0
MJ
25SRCDIR="$WORKSPACE/src/babeltrace"
26TMPDIR="$WORKSPACE/tmp"
275b59d2
JRJ
27PREFIX="$WORKSPACE/build"
28
e6be9fb0
MJ
29# Create build and tmp directories
30rm -rf "$PREFIX" "$TMPDIR"
31mkdir -p "$PREFIX" "$TMPDIR"
32
0e9967db
MJ
33export TMPDIR
34
c56b9301 35# Set platform variables
87e41bca
MJ
36case "$arch" in
37solaris10)
38 MAKE=gmake
39 TAR=gtar
40 NPROC=gnproc
41 BISON=bison
42 YACC="$BISON -y"
43 ;;
44solaris11)
45 MAKE=gmake
46 TAR=gtar
47 NPROC=nproc
48 BISON="/opt/csw/bin/bison"
49 YACC="$BISON -y"
50 export PATH="$PATH:/usr/perl5/bin"
51 ;;
221450b6
MJ
52macosx)
53 MAKE=make
54 TAR=tar
55 NPROC="getconf _NPROCESSORS_ONLN"
56 BISON="bison"
57 YACC="$BISON -y"
58 export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
59 export CFLAGS="-I/opt/local/include"
60 export LDFLAGS="-L/opt/local/lib"
61 ;;
87e41bca
MJ
62*)
63 MAKE=make
64 TAR=tar
65 NPROC=nproc
66 BISON=bison
67 YACC="$BISON -y"
68 ;;
69esac
70
c56b9301
MJ
71# Set configure options for each build configuration
72CONF_OPTS=""
275b59d2
JRJ
73case "$conf" in
74static)
75 echo "Static build"
76 CONF_OPTS="--enable-static --disable-shared"
77 ;;
221450b6 78python-bindings)
275b59d2
JRJ
79 echo "Build with python bindings"
80 # We only support bindings built with Python 3
81 export PYTHON="python3"
82 export PYTHON_CONFIG="/usr/bin/python3-config"
83 CONF_OPTS="--enable-python-bindings"
84 ;;
85*)
86 echo "Standard build"
87 CONF_OPTS=""
88 ;;
89esac
90
e6be9fb0
MJ
91# Enter the source directory
92cd "$SRCDIR"
c56b9301 93
e6be9fb0 94# Run bootstrap in the source directory prior to configure
c56b9301
MJ
95./bootstrap
96
97
aad6ac90
JR
98# Build type
99# oot : out-of-tree build
100# dist: build via make dist
101# * : normal tree build
102#
103# Make sure to move to the build_path and configure
104# before continuing
e6be9fb0 105BUILD_PATH="$SRCDIR"
aad6ac90 106case "$build" in
c56b9301
MJ
107 oot)
108 echo "Out of tree build"
944a6c86
MJ
109 BUILD_PATH="$WORKSPACE/oot"
110 mkdir -p "$BUILD_PATH"
111 cd "$BUILD_PATH"
112 MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
c56b9301
MJ
113 ;;
114
115 dist)
116 echo "Distribution out of tree build"
a57a60d9 117 BUILD_PATH="$(mktemp -d)"
c56b9301
MJ
118
119 # Initial configure and generate tarball
e6be9fb0 120 MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure"
c56b9301
MJ
121 $MAKE dist
122
944a6c86
MJ
123 mkdir -p "$BUILD_PATH"
124 cp ./*.tar.* "$BUILD_PATH/"
125 cd "$BUILD_PATH"
c56b9301
MJ
126
127 # Ignore level 1 of tar
944a6c86 128 $TAR xvf ./*.tar.* --strip 1
c56b9301 129
944a6c86 130 MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS
c56b9301
MJ
131 ;;
132
0628a9d8
MJ
133 clang)
134 echo "LLVM clang build"
135 export CC=clang
136 clang -v
944a6c86 137 MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
0628a9d8
MJ
138 ;;
139 *)
e6be9fb0 140 echo "Standard in-tree build"
944a6c86 141 MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
c56b9301 142 ;;
aad6ac90
JR
143esac
144
c56b9301 145# BUILD!
a57a60d9 146$MAKE -j "$($NPROC)" V=1
87e41bca 147$MAKE install
c56b9301
MJ
148
149# Run tests
221450b6 150$MAKE check
c56b9301 151
e6be9fb0
MJ
152# Copy tap logs for the jenkins tap parser
153rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap"
154
155# Clean the build directory
156$MAKE clean
275b59d2 157
c56b9301 158# Cleanup rpath in executables and shared libraries
944a6c86
MJ
159find "$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \;
160find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \;
c56b9301
MJ
161
162# Remove libtool .la files
944a6c86 163find "$PREFIX/lib" -name "*.la" -exec rm -f {} \;
aad6ac90 164
c56b9301
MJ
165# Clean temp dir for dist build
166if [ "$build" = "dist" ]; then
944a6c86
MJ
167 cd "$SRCDIR"
168 rm -rf "$BUILD_PATH"
aad6ac90 169fi
87e41bca
MJ
170
171# EOF
This page took 0.032726 seconds and 4 git commands to generate.