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