3 # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 # Copyright (C) 2019-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:-}
87 platform
=${platform:-}
93 SRCDIR
="$WORKSPACE/src/librseq"
94 TMPDIR
="$WORKSPACE/tmp"
97 # Create tmp directory
102 export CFLAGS
="-g -O2"
104 # Add the convenience headers in extra to the
106 export CPPFLAGS
="-I$SRCDIR/extra"
108 # Set compiler variables
115 export CC
=gcc-
${cc#gcc-}
116 export CXX
=g
++-${cc#gcc-}
123 export CC
=clang-
${cc#clang-}
124 export CXX
=clang
++-${cc#clang-}
127 if [ "x$cc" != "x" ]; then
133 if [ "x${CC:-}" != "x" ]; then
134 echo "Selected compiler:"
138 # Set platform variables
144 export PYTHON
="python3"
145 export PYTHON_CONFIG
="python3-config"
149 # Print build env details
151 print_tooling || true
153 # Enter the source directory
156 # Run bootstrap in the source directory prior to configure
159 # Get source version from configure script
160 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
161 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
164 # Set configure options and environment variables for each build
166 CONF_OPTS
=("--prefix=$PREFIX")
169 echo "Static lib only configuration"
171 CONF_OPTS
+=("--enable-static" "--disable-shared")
175 echo "Standard configuration"
180 # oot : out-of-tree build
181 # dist : build via make dist
182 # oot-dist: build via make dist out-of-tree
183 # * : normal tree build
185 # Make sure to move to the build directory and run configure
189 echo "Out of tree build"
191 # Create and enter a temporary build directory
192 builddir
=$
(mktemp
-d)
195 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
199 echo "Distribution in-tree build"
201 # Run configure and generate the tar file
202 # in the source directory
203 .
/configure || failed_configure
206 # Create and enter a temporary build directory
207 builddir
=$
(mktemp
-d)
210 # Extract the distribution tar in the build directory,
211 # ignore the first directory level
212 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
214 # Build in extracted source tree
215 .
/configure
"${CONF_OPTS[@]}" || failed_configure
219 echo "Distribution out of tree build"
221 # Create and enter a temporary build directory
222 builddir
=$
(mktemp
-d)
225 # Run configure out of tree and generate the tar file
226 "$SRCDIR/configure" || failed_configure
229 dist_srcdir
="$(mktemp -d)"
232 # Extract the distribution tar in the new source directory,
233 # ignore the first directory level
234 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
236 # Create and enter a second temporary build directory
237 builddir
="$(mktemp -d)"
240 # Run configure from the extracted distribution tar,
241 # out of the source tree
242 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
246 echo "Standard in-tree build"
247 .
/configure
"${CONF_OPTS[@]}" || failed_configure
251 # We are now inside a configured build directory
254 $MAKE -j "$($NPROC)" V
=1
256 # Install in the workspace
257 $MAKE install DESTDIR
="$WORKSPACE"
259 # Run tests, don't fail now, we want to run the archiving steps
261 $MAKE --keep-going check
265 # Copy tap logs for the jenkins tap parser before cleaning the build dir
266 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
268 # Clean the build directory
271 # Cleanup rpath in executables and shared libraries
272 #find "$WORKSPACE/$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \;
273 find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
275 # Remove libtool .la files
276 find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
278 # Exit with the return code of the test suite