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