Commit | Line | Data |
---|---|---|
c56b9301 | 1 | #!/bin/bash -exu |
890bff23 MJ |
2 | # |
3 | # Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> | |
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation, either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
c56b9301 | 18 | |
e6be9fb0 MJ |
19 | SRCDIR="$WORKSPACE/src/babeltrace" |
20 | TMPDIR="$WORKSPACE/tmp" | |
275b59d2 JRJ |
21 | PREFIX="$WORKSPACE/build" |
22 | ||
e6be9fb0 MJ |
23 | # Create build and tmp directories |
24 | rm -rf "$PREFIX" "$TMPDIR" | |
25 | mkdir -p "$PREFIX" "$TMPDIR" | |
26 | ||
c56b9301 | 27 | # Set platform variables |
87e41bca MJ |
28 | case "$arch" in |
29 | solaris10) | |
30 | MAKE=gmake | |
31 | TAR=gtar | |
32 | NPROC=gnproc | |
33 | BISON=bison | |
34 | YACC="$BISON -y" | |
35 | ;; | |
36 | solaris11) | |
37 | MAKE=gmake | |
38 | TAR=gtar | |
39 | NPROC=nproc | |
40 | BISON="/opt/csw/bin/bison" | |
41 | YACC="$BISON -y" | |
42 | export PATH="$PATH:/usr/perl5/bin" | |
43 | ;; | |
221450b6 MJ |
44 | macosx) |
45 | MAKE=make | |
46 | TAR=tar | |
47 | NPROC="getconf _NPROCESSORS_ONLN" | |
48 | BISON="bison" | |
49 | YACC="$BISON -y" | |
50 | export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" | |
51 | export CFLAGS="-I/opt/local/include" | |
52 | export LDFLAGS="-L/opt/local/lib" | |
53 | ;; | |
87e41bca MJ |
54 | *) |
55 | MAKE=make | |
56 | TAR=tar | |
57 | NPROC=nproc | |
58 | BISON=bison | |
59 | YACC="$BISON -y" | |
60 | ;; | |
61 | esac | |
62 | ||
c56b9301 MJ |
63 | # Set configure options for each build configuration |
64 | CONF_OPTS="" | |
275b59d2 JRJ |
65 | case "$conf" in |
66 | static) | |
67 | echo "Static build" | |
68 | CONF_OPTS="--enable-static --disable-shared" | |
69 | ;; | |
221450b6 | 70 | python-bindings) |
275b59d2 JRJ |
71 | echo "Build with python bindings" |
72 | # We only support bindings built with Python 3 | |
73 | export PYTHON="python3" | |
74 | export PYTHON_CONFIG="/usr/bin/python3-config" | |
75 | CONF_OPTS="--enable-python-bindings" | |
76 | ;; | |
77 | *) | |
78 | echo "Standard build" | |
79 | CONF_OPTS="" | |
80 | ;; | |
81 | esac | |
82 | ||
e6be9fb0 MJ |
83 | # Enter the source directory |
84 | cd "$SRCDIR" | |
c56b9301 | 85 | |
e6be9fb0 | 86 | # Run bootstrap in the source directory prior to configure |
c56b9301 MJ |
87 | ./bootstrap |
88 | ||
89 | ||
aad6ac90 JR |
90 | # Build type |
91 | # oot : out-of-tree build | |
92 | # dist: build via make dist | |
93 | # * : normal tree build | |
94 | # | |
95 | # Make sure to move to the build_path and configure | |
96 | # before continuing | |
e6be9fb0 | 97 | BUILD_PATH="$SRCDIR" |
aad6ac90 | 98 | case "$build" in |
c56b9301 MJ |
99 | oot) |
100 | echo "Out of tree build" | |
101 | BUILD_PATH=$WORKSPACE/oot | |
102 | mkdir -p $BUILD_PATH | |
103 | cd $BUILD_PATH | |
e6be9fb0 | 104 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" --prefix=$PREFIX $CONF_OPTS |
c56b9301 MJ |
105 | ;; |
106 | ||
107 | dist) | |
108 | echo "Distribution out of tree build" | |
221450b6 | 109 | BUILD_PATH=`mktemp -d` |
c56b9301 MJ |
110 | |
111 | # Initial configure and generate tarball | |
e6be9fb0 | 112 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" |
c56b9301 MJ |
113 | $MAKE dist |
114 | ||
115 | mkdir -p $BUILD_PATH | |
116 | cp *.tar.* $BUILD_PATH/ | |
117 | cd $BUILD_PATH | |
118 | ||
119 | # Ignore level 1 of tar | |
120 | $TAR xvf *.tar.* --strip 1 | |
121 | ||
122 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS | |
c56b9301 MJ |
123 | ;; |
124 | ||
0628a9d8 MJ |
125 | clang) |
126 | echo "LLVM clang build" | |
127 | export CC=clang | |
128 | clang -v | |
e6be9fb0 | 129 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" --prefix=$PREFIX $CONF_OPTS |
0628a9d8 MJ |
130 | ;; |
131 | *) | |
e6be9fb0 MJ |
132 | echo "Standard in-tree build" |
133 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" --prefix=$PREFIX $CONF_OPTS | |
c56b9301 | 134 | ;; |
aad6ac90 JR |
135 | esac |
136 | ||
c56b9301 | 137 | # BUILD! |
fe584a39 | 138 | $MAKE -j `$NPROC` V=1 |
87e41bca | 139 | $MAKE install |
c56b9301 MJ |
140 | |
141 | # Run tests | |
221450b6 | 142 | $MAKE check |
c56b9301 | 143 | |
e6be9fb0 MJ |
144 | # Copy tap logs for the jenkins tap parser |
145 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap" | |
146 | ||
147 | # Clean the build directory | |
148 | $MAKE clean | |
275b59d2 | 149 | |
c56b9301 | 150 | # Cleanup rpath in executables and shared libraries |
e6be9fb0 MJ |
151 | find $PREFIX/bin -type f -perm -0500 -exec chrpath --delete {} \; |
152 | find $PREFIX/lib -name "*.so" -exec chrpath --delete {} \; | |
c56b9301 MJ |
153 | |
154 | # Remove libtool .la files | |
e6be9fb0 | 155 | find $PREFIX/lib -name "*.la" -exec rm -f {} \; |
aad6ac90 | 156 | |
c56b9301 MJ |
157 | # Clean temp dir for dist build |
158 | if [ "$build" = "dist" ]; then | |
e6be9fb0 | 159 | cd $SRCDIR |
87e41bca | 160 | rm -rf $BUILD_PATH |
aad6ac90 | 161 | fi |
87e41bca MJ |
162 | |
163 | # EOF |