Commit | Line | Data |
---|---|---|
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 | ||
c56b9301 | 19 | |
e6be9fb0 MJ |
20 | SRCDIR="$WORKSPACE/src/babeltrace" |
21 | TMPDIR="$WORKSPACE/tmp" | |
275b59d2 JRJ |
22 | PREFIX="$WORKSPACE/build" |
23 | ||
e6be9fb0 MJ |
24 | # Create build and tmp directories |
25 | rm -rf "$PREFIX" "$TMPDIR" | |
26 | mkdir -p "$PREFIX" "$TMPDIR" | |
27 | ||
0e9967db MJ |
28 | export TMPDIR |
29 | ||
c56b9301 | 30 | # Set platform variables |
87e41bca MJ |
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 | ;; | |
221450b6 MJ |
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 | ;; | |
87e41bca MJ |
57 | *) |
58 | MAKE=make | |
59 | TAR=tar | |
60 | NPROC=nproc | |
61 | BISON=bison | |
62 | YACC="$BISON -y" | |
63 | ;; | |
64 | esac | |
65 | ||
c56b9301 MJ |
66 | # Set configure options for each build configuration |
67 | CONF_OPTS="" | |
275b59d2 JRJ |
68 | case "$conf" in |
69 | static) | |
70 | echo "Static build" | |
71 | CONF_OPTS="--enable-static --disable-shared" | |
72 | ;; | |
221450b6 | 73 | python-bindings) |
275b59d2 JRJ |
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 | ||
e6be9fb0 MJ |
86 | # Enter the source directory |
87 | cd "$SRCDIR" | |
c56b9301 | 88 | |
e6be9fb0 | 89 | # Run bootstrap in the source directory prior to configure |
c56b9301 MJ |
90 | ./bootstrap |
91 | ||
92 | ||
aad6ac90 JR |
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 | |
e6be9fb0 | 100 | BUILD_PATH="$SRCDIR" |
aad6ac90 | 101 | case "$build" in |
c56b9301 MJ |
102 | oot) |
103 | echo "Out of tree build" | |
944a6c86 MJ |
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 | |
c56b9301 MJ |
108 | ;; |
109 | ||
110 | dist) | |
111 | echo "Distribution out of tree build" | |
944a6c86 | 112 | BUILD_PATH="`mktemp -d`" |
c56b9301 MJ |
113 | |
114 | # Initial configure and generate tarball | |
e6be9fb0 | 115 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" |
c56b9301 MJ |
116 | $MAKE dist |
117 | ||
944a6c86 MJ |
118 | mkdir -p "$BUILD_PATH" |
119 | cp ./*.tar.* "$BUILD_PATH/" | |
120 | cd "$BUILD_PATH" | |
c56b9301 MJ |
121 | |
122 | # Ignore level 1 of tar | |
944a6c86 | 123 | $TAR xvf ./*.tar.* --strip 1 |
c56b9301 | 124 | |
944a6c86 | 125 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
c56b9301 MJ |
126 | ;; |
127 | ||
0628a9d8 MJ |
128 | clang) |
129 | echo "LLVM clang build" | |
130 | export CC=clang | |
131 | clang -v | |
944a6c86 | 132 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS |
0628a9d8 MJ |
133 | ;; |
134 | *) | |
e6be9fb0 | 135 | echo "Standard in-tree build" |
944a6c86 | 136 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS |
c56b9301 | 137 | ;; |
aad6ac90 JR |
138 | esac |
139 | ||
c56b9301 | 140 | # BUILD! |
fe584a39 | 141 | $MAKE -j `$NPROC` V=1 |
87e41bca | 142 | $MAKE install |
c56b9301 MJ |
143 | |
144 | # Run tests | |
221450b6 | 145 | $MAKE check |
c56b9301 | 146 | |
e6be9fb0 MJ |
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 | |
275b59d2 | 152 | |
c56b9301 | 153 | # Cleanup rpath in executables and shared libraries |
944a6c86 MJ |
154 | find "$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \; |
155 | find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \; | |
c56b9301 MJ |
156 | |
157 | # Remove libtool .la files | |
944a6c86 | 158 | find "$PREFIX/lib" -name "*.la" -exec rm -f {} \; |
aad6ac90 | 159 | |
c56b9301 MJ |
160 | # Clean temp dir for dist build |
161 | if [ "$build" = "dist" ]; then | |
944a6c86 MJ |
162 | cd "$SRCDIR" |
163 | rm -rf "$BUILD_PATH" | |
aad6ac90 | 164 | fi |
87e41bca MJ |
165 | |
166 | # EOF |