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 local i ver1
=($1) ver2
=($2)
29 # fill empty fields in ver1 with zeros
30 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
33 for ((i
=0; i
<${#ver1[@]}; i
++)); do
34 if [[ -z ${ver2[i]} ]]; then
35 # fill empty fields in ver2 with zeros
38 if ((10#${ver1[i]} > 10#${ver2[i]})); then
41 if ((10#${ver1[i]} < 10#${ver2[i]})); then
50 vercomp
"$1" "$2"; local res
="$?"
51 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
55 vercomp
"$1" "$2"; local res
="$?"
60 vercomp
"$1" "$2"; local res
="$?"
61 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
65 vercomp
"$1" "$2"; local res
="$?"
70 vercomp
"$1" "$2"; local res
="$?"
75 # Assume we are in the configured build directory
76 echo "#################### BEGIN config.log ####################"
78 echo "#################### END config.log ####################"
80 # End the build with failure
85 WORKSPACE
=${WORKSPACE:-}
92 # Controls if the tests are run
93 USERSPACE_RCU_RUN_TESTS
="${USERSPACE_RCU_RUN_TESTS:=yes}"
95 SRCDIR
="$WORKSPACE/src/liburcu"
96 TMPDIR
="$WORKSPACE/tmp"
99 # Create tmp directory
104 export CFLAGS
="-g -O2"
106 # Set compiler variables
113 export CC
=gcc-
${cc#gcc-}
114 export CXX
=g
++-${cc#gcc-}
121 export CC
=clang-
${cc#clang-}
122 export CXX
=clang
++-${cc#clang-}
125 if [ "x$cc" != "x" ]; then
131 if [ "x${CC:-}" != "x" ]; then
132 echo "Selected compiler:"
136 # Set platform variables
141 export NPROC
="getconf _NPROCESSORS_ONLN"
142 export PATH
="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
143 export CPPFLAGS
="-I/opt/local/include"
144 export LDFLAGS
="-L/opt/local/lib"
145 export PYTHON
="python3.9"
146 export PYTHON_CONFIG
="python3.9-config"
152 export NPROC
="getconf _NPROCESSORS_ONLN"
153 export CPPFLAGS
="-I/usr/local/include"
154 export LDFLAGS
="-L/usr/local/lib"
155 export PYTHON
="python3"
156 export PYTHON_CONFIG
="python3-config"
163 export PYTHON
="python3"
164 export PYTHON_CONFIG
="python3-config"
168 # Print build env details
170 print_tooling || true
172 # Enter the source directory
175 # Run bootstrap in the source directory prior to configure
178 # Get source version from configure script
179 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
180 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
182 # Set configure options and environment variables for each build
184 CONF_OPTS
=("--prefix=$PREFIX")
187 echo "Static lib only configuration"
189 CONF_OPTS
+=("--enable-static" "--disable-shared")
193 echo "Using pthread_getspecific() to emulate TLS"
194 CONF_OPTS
+=("--disable-compiler-tls")
198 echo "Enable RCU sanity checks for debugging"
199 if vergte
"$PACKAGE_VERSION" "0.10"; then
200 CONF_OPTS
+=("--enable-rcu-debug")
202 export CFLAGS
="$CFLAGS -DDEBUG_RCU"
205 echo "Enable iterator sanity validator"
206 if vergte
"$PACKAGE_VERSION" "0.11"; then
207 CONF_OPTS
+=("--enable-cds-lfht-iter-debug")
212 echo "Standard configuration"
217 # oot : out-of-tree build
218 # dist : build via make dist
219 # oot-dist: build via make dist out-of-tree
220 # * : normal tree build
222 # Make sure to move to the build directory and run configure
226 echo "Out of tree build"
228 # Create and enter a temporary build directory
229 builddir
=$
(mktemp
-d)
232 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
236 echo "Distribution in-tree build"
238 # Run configure and generate the tar file
239 # in the source directory
240 .
/configure || failed_configure
243 # Create and enter a temporary build directory
244 builddir
=$
(mktemp
-d)
247 # Extract the distribution tar in the build directory,
248 # ignore the first directory level
249 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
251 # Build in extracted source tree
252 .
/configure
"${CONF_OPTS[@]}" || failed_configure
256 echo "Distribution out of tree build"
258 # Create and enter a temporary build directory
259 builddir
=$
(mktemp
-d)
262 # Run configure out of tree and generate the tar file
263 "$SRCDIR/configure" || failed_configure
266 dist_srcdir
="$(mktemp -d)"
269 # Extract the distribution tar in the new source directory,
270 # ignore the first directory level
271 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
273 # Create and enter a second temporary build directory
274 builddir
="$(mktemp -d)"
277 # Run configure from the extracted distribution tar,
278 # out of the source tree
279 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
283 echo "Standard in-tree build"
284 .
/configure
"${CONF_OPTS[@]}" || failed_configure
288 # We are now inside a configured build directory
291 $MAKE -j "$($NPROC)" V
=1
293 # Install in the workspace
294 $MAKE install DESTDIR
="$WORKSPACE"
296 # Run tests, don't fail now, we want to run the archiving steps
298 if [ "$USERSPACE_RCU_RUN_TESTS" = "yes" ]; then
299 $MAKE --keep-going check || failed_tests
=1
300 # Only run regtest for 0.9 and up
301 if vergte
"$PACKAGE_VERSION" "0.9"; then
302 $MAKE --keep-going regtest || failed_tests
=1
305 # Copy tap logs for the jenkins tap parser before cleaning the build dir
306 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
308 # The test suite prior to 0.11 did not produce TAP logs
309 if verlt
"$PACKAGE_VERSION" "0.11"; then
310 mkdir
-p "$WORKSPACE/tap/no-log"
311 echo "1..1" > "$WORKSPACE/tap/no-log/tests.log"
312 echo "ok 1 - Test suite doesn't support logging" >> "$WORKSPACE/tap/no-log/tests.log"
316 # Clean the build directory
319 # Cleanup rpath in executables and shared libraries
320 #find "$WORKSPACE/$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \;
321 find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
323 # Remove libtool .la files
324 find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
326 # Exit with failure if any of the tests failed