jjb: Update liburcu jobs
[lttng-ci.git] / scripts / liburcu / build.sh
1 #!/bin/bash -exu
2 #
3 # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 # 2016-2019 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 # Version compare functions
20 vercomp () {
21 set +u
22 if [[ "$1" == "$2" ]]; then
23 return 0
24 fi
25 local IFS=.
26 local i ver1=($1) ver2=($2)
27 # fill empty fields in ver1 with zeros
28 for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
29 ver1[i]=0
30 done
31 for ((i=0; i<${#ver1[@]}; i++)); do
32 if [[ -z ${ver2[i]} ]]; then
33 # fill empty fields in ver2 with zeros
34 ver2[i]=0
35 fi
36 if ((10#${ver1[i]} > 10#${ver2[i]})); then
37 return 1
38 fi
39 if ((10#${ver1[i]} < 10#${ver2[i]})); then
40 return 2
41 fi
42 done
43 set -u
44 return 0
45 }
46
47 verlte() {
48 vercomp "$1" "$2"; local res="$?"
49 [ "$res" -eq "0" ] || [ "$res" -eq "2" ]
50 }
51
52 verlt() {
53 vercomp "$1" "$2"; local res="$?"
54 [ "$res" -eq "2" ]
55 }
56
57 vergte() {
58 vercomp "$1" "$2"; local res="$?"
59 [ "$res" -eq "0" ] || [ "$res" -eq "1" ]
60 }
61
62 vergt() {
63 vercomp "$1" "$2"; local res="$?"
64 [ "$res" -eq "1" ]
65 }
66
67 verne() {
68 vercomp "$1" "$2"; local res="$?"
69 [ "$res" -ne "0" ]
70 }
71
72 # Required parameters
73 arch=${arch:-}
74 conf=${conf:-}
75 build=${build:-}
76
77
78 SRCDIR="$WORKSPACE/src/liburcu"
79 TMPDIR="$WORKSPACE/tmp"
80 PREFIX="$WORKSPACE/build"
81
82 # The build dir defaults to the source dir
83 BUILDDIR="$SRCDIR"
84
85 # Create build and tmp directories
86 rm -rf "$PREFIX" "$TMPDIR"
87 mkdir -p "$PREFIX" "$TMPDIR"
88
89 export TMPDIR
90 export CFLAGS="-g -O2"
91
92 # Set platform variables
93 case "$arch" in
94 sol10-i386)
95 export MAKE=gmake
96 export TAR=gtar
97 export NPROC=gnproc
98 export BISON=bison
99 export YACC="$BISON -y"
100 export PATH="/opt/csw/bin:/usr/ccs/bin:$PATH"
101 export CPPFLAGS="-I/opt/csw/include"
102 export LDFLAGS="-L/opt/csw/lib -R/opt/csw/lib"
103 export PKG_CONFIG_PATH="/opt/csw/lib/pkgconfig"
104 ;;
105 sol11-i386)
106 export MAKE=gmake
107 export TAR=gtar
108 export NPROC=nproc
109 export PATH="$PATH:/usr/perl5/bin"
110 #export LD_ALTEXEC=/usr/sfw/bin/gld
111 #export LD=/usr/sfw/bin/gld
112 ;;
113 macosx)
114 export MAKE=make
115 export TAR=tar
116 export NPROC="getconf _NPROCESSORS_ONLN"
117 export BISON="bison"
118 export YACC="$BISON -y"
119 export LDFLAGS="-L/opt/local/lib"
120 export CFLAGS="$CFLAGS -I/opt/local/include"
121 export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
122 ;;
123
124 *)
125 export MAKE=make
126 export TAR=tar
127 export NPROC=nproc
128 ;;
129 esac
130
131 # Enter the source directory
132 cd "$SRCDIR"
133
134 # Run bootstrap in the source directory prior to configure
135 ./bootstrap
136
137 # Get source version from configure script
138 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
139
140 # Set configure options and environment variables for each build
141 # configuration.
142 CONF_OPTS=""
143 case "$conf" in
144 static)
145 echo "Static build"
146 CONF_OPTS="--enable-static --disable-shared"
147 ;;
148
149 tls_fallback)
150 echo "Using pthread_getspecific() to emulate TLS"
151 CONF_OPTS="--disable-compiler-tls"
152 ;;
153
154 debug-rcu)
155 echo "Enable RCU sanity checks for debugging"
156 if vergte "$PACKAGE_VERSION" "0.10"; then
157 CONF_OPTS="--enable-rcu-debug"
158 else
159 export CFLAGS="$CFLAGS -DDEBUG_RCU"
160 fi
161
162 echo "Enable iterator sanity validator"
163 if vergte "$PACKAGE_VERSION" "0.11"; then
164 CONF_OPTS+=" --enable-cds-lfht-iter-debug"
165 fi
166 ;;
167
168 *)
169 echo "Standard build"
170 CONF_OPTS=""
171 ;;
172 esac
173
174 # Build type
175 # oot : out-of-tree build
176 # dist: build via make dist
177 # * : normal tree build
178 #
179 # Make sure to move to the build dir and run configure
180 # before continuing.
181 case "$build" in
182 oot)
183 echo "Out of tree build"
184
185 BUILDDIR=$WORKSPACE/oot
186 mkdir -p "$BUILDDIR"
187 cd "$BUILDDIR"
188
189 "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
190 ;;
191
192 dist)
193 echo "Distribution out of tree build"
194
195 tar_file="userspace-rcu-$PACKAGE_VERSION.tar.bz2"
196
197 # Initial configure in src dir and tarball generation
198 ./configure
199 $MAKE dist
200
201 BUILDDIR=$(mktemp -d)
202 mkdir -p "$BUILDDIR"
203 cd "$BUILDDIR"
204
205 # Ignore level 1 of tar
206 $TAR xvf "$SRCDIR/$tar_file" --strip 1
207
208 ./configure --prefix="$PREFIX" $CONF_OPTS
209 ;;
210 *)
211 echo "Standard in-tree build"
212 ./configure --prefix="$PREFIX" $CONF_OPTS
213 ;;
214 esac
215
216 # BUILD!
217 $MAKE -j "$($NPROC)" V=1
218 $MAKE install
219
220 # Run tests
221 $MAKE --keep-going check
222 # Only run regtest for 0.9 and up
223 if vergte "$PACKAGE_VERSION" "0.9"; then
224 $MAKE --keep-going regtest
225 fi
226
227 # Copy tap logs for the jenkins tap parser
228 rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap"
229
230 # Cleanup
231 $MAKE clean
232
233 # Cleanup rpath in executables and shared libraries
234 find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \;
235
236 # Remove libtool .la files
237 find "$PREFIX/lib" -name "*.la" -exec rm -f {} \;
238
239 # Cleanup temp directory of dist build
240 if [ "$build" = "dist" ]; then
241 cd "$SRCDIR"
242 rm -rf "$BUILDDIR"
243 fi
244
245 # EOF
This page took 0.047582 seconds and 5 git commands to generate.