3 # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 # Copyright (C) 2016-2020 Michael Jeanson <mjeanson@efficios.com>
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.
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.
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/>.
21 # Version compare functions
24 if [[ "$1" == "$2" ]]; then
28 # Ignore the shellcheck warning, we want splitting to happen based on IFS.
29 # shellcheck disable=SC2206
30 local i ver1
=($1) ver2
=($2)
31 # fill empty fields in ver1 with zeros
32 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
35 for ((i
=0; i
<${#ver1[@]}; i
++)); do
36 if [[ -z ${ver2[i]} ]]; then
37 # fill empty fields in ver2 with zeros
40 if ((10#${ver1[i]} > 10#${ver2[i]})); then
43 if ((10#${ver1[i]} < 10#${ver2[i]})); then
52 vercomp
"$1" "$2"; local res
="$?"
53 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
57 vercomp
"$1" "$2"; local res
="$?"
62 vercomp
"$1" "$2"; local res
="$?"
63 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
67 vercomp
"$1" "$2"; local res
="$?"
72 vercomp
"$1" "$2"; local res
="$?"
77 # Assume we are in the configured build directory
78 echo "#################### BEGIN config.log ####################"
80 echo "#################### END config.log ####################"
82 # End the build with failure
87 WORKSPACE
=${WORKSPACE:-}
89 platform
=${platform:-}
94 # Controls if the tests are run
95 USERSPACE_RCU_RUN_TESTS
="${USERSPACE_RCU_RUN_TESTS:=yes}"
97 SRCDIR
="$WORKSPACE/src/liburcu"
98 TMPDIR
="$WORKSPACE/tmp"
101 LIBDIR_ARCH
="$LIBDIR"
103 # RHEL and SLES both use lib64 but don't bother shipping a default autoconf
104 # site config that matches this.
105 if [[ ( -f /etc
/redhat-release ||
-f /etc
/SuSE-release ||
-f /etc
/yocto-release
) ]]; then
106 # Detect the userspace bitness in a distro agnostic way
107 if file -L /bin
/bash |
grep '64-bit' >/dev
/null
2>&1; then
108 LIBDIR_ARCH
="${LIBDIR}64"
112 # Create tmp directory
117 export CFLAGS
="-g -O2"
119 # Set compiler variables
126 export CC
=gcc-
${cc#gcc-}
127 export CXX
=g
++-${cc#gcc-}
134 export CC
=clang-
${cc#clang-}
135 export CXX
=clang
++-${cc#clang-}
138 if [ "x$cc" != "x" ]; then
144 if [ "x${CC:-}" != "x" ]; then
145 echo "Selected compiler:"
149 # Set platform variables
154 export NPROC
="getconf _NPROCESSORS_ONLN"
155 export PATH
="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
156 export CPPFLAGS
="-I/opt/local/include"
157 export LDFLAGS
="-L/opt/local/lib"
158 export PYTHON
="python3"
159 export PYTHON_CONFIG
="python3-config"
165 export NPROC
="getconf _NPROCESSORS_ONLN"
166 export CPPFLAGS
="-I/usr/local/include"
167 export LDFLAGS
="-L/usr/local/lib"
168 export PYTHON
="python3"
169 export PYTHON_CONFIG
="python3-config"
176 export PYTHON
="python3"
177 export PYTHON_CONFIG
="python3-config"
181 # Print build env details
183 print_tooling || true
185 # Enter the source directory
188 # Run bootstrap in the source directory prior to configure
191 # Get source version from configure script
192 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
193 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
195 # Set configure options and environment variables for each build
197 CONF_OPTS
=("--prefix=$PREFIX" "--libdir=$PREFIX/$LIBDIR_ARCH")
200 echo "Static lib only configuration"
202 CONF_OPTS
+=("--enable-static" "--disable-shared")
206 echo "Using pthread_getspecific() to emulate TLS"
207 CONF_OPTS
+=("--disable-compiler-tls")
211 echo "Enable RCU sanity checks for debugging"
212 if vergte
"$PACKAGE_VERSION" "0.10"; then
213 CONF_OPTS
+=("--enable-rcu-debug")
215 export CFLAGS
="$CFLAGS -DDEBUG_RCU"
218 echo "Enable iterator sanity validator"
219 if vergte
"$PACKAGE_VERSION" "0.11"; then
220 CONF_OPTS
+=("--enable-cds-lfht-iter-debug")
225 echo "Standard configuration"
230 # oot : out-of-tree build
231 # dist : build via make dist
232 # oot-dist: build via make dist out-of-tree
233 # * : normal tree build
235 # Make sure to move to the build directory and run configure
239 echo "Out of tree build"
241 # Create and enter a temporary build directory
242 builddir
=$
(mktemp
-d)
245 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
249 echo "Distribution in-tree build"
251 # Run configure and generate the tar file
252 # in the source directory
253 .
/configure || failed_configure
256 # Create and enter a temporary build directory
257 builddir
=$
(mktemp
-d)
260 # Extract the distribution tar in the build directory,
261 # ignore the first directory level
262 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
264 # Build in extracted source tree
265 .
/configure
"${CONF_OPTS[@]}" || failed_configure
269 echo "Distribution out of tree build"
271 # Create and enter a temporary build directory
272 builddir
=$
(mktemp
-d)
275 # Run configure out of tree and generate the tar file
276 "$SRCDIR/configure" || failed_configure
279 dist_srcdir
="$(mktemp -d)"
282 # Extract the distribution tar in the new source directory,
283 # ignore the first directory level
284 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
286 # Create and enter a second temporary build directory
287 builddir
="$(mktemp -d)"
290 # Run configure from the extracted distribution tar,
291 # out of the source tree
292 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
296 echo "Standard in-tree build"
297 .
/configure
"${CONF_OPTS[@]}" || failed_configure
301 # We are now inside a configured build directory
304 $MAKE -j "$($NPROC)" V
=1
306 # Install in the workspace
307 $MAKE install DESTDIR
="$WORKSPACE"
309 # Run tests, don't fail now, we want to run the archiving steps
311 if [ "$USERSPACE_RCU_RUN_TESTS" = "yes" ]; then
312 $MAKE --keep-going check || failed_tests
=1
313 # Only run regtest for 0.9 and up
314 if vergte
"$PACKAGE_VERSION" "0.9"; then
315 $MAKE --keep-going regtest || failed_tests
=1
318 # Copy tap logs for the jenkins tap parser before cleaning the build dir
319 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
321 # The test suite prior to 0.11 did not produce TAP logs
322 if verlt
"$PACKAGE_VERSION" "0.11"; then
323 mkdir
-p "$WORKSPACE/tap/no-log"
324 echo "1..1" > "$WORKSPACE/tap/no-log/tests.log"
325 echo "ok 1 - Test suite doesn't support logging" >> "$WORKSPACE/tap/no-log/tests.log"
329 # Clean the build directory
332 # Cleanup rpath in executables and shared libraries
333 #find "$WORKSPACE/$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \;
334 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.so" -exec chrpath
--delete {} \
;
336 # Remove libtool .la files
337 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.la" -exec rm -f {} \
;
339 # Exit with failure if any of the tests failed