Commit | Line | Data |
---|---|---|
72f4f0c1 | 1 | #!/bin/bash -exu |
e3022ad9 | 2 | # |
69d7af71 MJ |
3 | # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
4 | # 2016-2019 Michael Jeanson <mjeanson@efficios.com> | |
e3022ad9 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 | ||
5fd8db76 | 19 | # Version compare functions |
0a6e708b MJ |
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 | ||
5fd8db76 | 47 | verlte() { |
0a6e708b MJ |
48 | vercomp "$1" "$2"; local res="$?" |
49 | [ "$res" -eq "0" ] || [ "$res" -eq "2" ] | |
5fd8db76 MJ |
50 | } |
51 | ||
52 | verlt() { | |
0a6e708b MJ |
53 | vercomp "$1" "$2"; local res="$?" |
54 | [ "$res" -eq "2" ] | |
5fd8db76 MJ |
55 | } |
56 | ||
57 | vergte() { | |
0a6e708b MJ |
58 | vercomp "$1" "$2"; local res="$?" |
59 | [ "$res" -eq "0" ] || [ "$res" -eq "1" ] | |
5fd8db76 MJ |
60 | } |
61 | ||
62 | vergt() { | |
0a6e708b MJ |
63 | vercomp "$1" "$2"; local res="$?" |
64 | [ "$res" -eq "1" ] | |
65 | } | |
66 | ||
67 | verne() { | |
68 | vercomp "$1" "$2"; local res="$?" | |
69 | [ "$res" -ne "0" ] | |
5fd8db76 MJ |
70 | } |
71 | ||
a57a60d9 MJ |
72 | # Required parameters |
73 | arch=${arch:-} | |
74 | conf=${conf:-} | |
75 | build=${build:-} | |
76 | ||
e3022ad9 | 77 | |
6d35c326 MJ |
78 | SRCDIR="$WORKSPACE/src/liburcu" |
79 | TMPDIR="$WORKSPACE/tmp" | |
56162e2a JRJ |
80 | PREFIX="$WORKSPACE/build" |
81 | ||
69d7af71 MJ |
82 | # The build dir defaults to the source dir |
83 | BUILDDIR="$SRCDIR" | |
84 | ||
6d35c326 MJ |
85 | # Create build and tmp directories |
86 | rm -rf "$PREFIX" "$TMPDIR" | |
87 | mkdir -p "$PREFIX" "$TMPDIR" | |
88 | ||
89 | export TMPDIR | |
72d087d4 | 90 | export CFLAGS="-g -O2" |
6d35c326 | 91 | |
72f4f0c1 | 92 | # Set platform variables |
7491c28d | 93 | case "$arch" in |
995ac8f2 MJ |
94 | sol10-i386) |
95 | export MAKE=gmake | |
96 | export TAR=gtar | |
97 | export NPROC=gnproc | |
98 | export BISON=bison | |
99 | export YACC="$BISON -y" | |
ad11244c | 100 | export PATH="/opt/csw/bin:/usr/ccs/bin:$PATH" |
995ac8f2 MJ |
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" | |
7491c28d | 104 | ;; |
995ac8f2 MJ |
105 | sol11-i386) |
106 | export MAKE=gmake | |
107 | export TAR=gtar | |
108 | export NPROC=nproc | |
7491c28d | 109 | export PATH="$PATH:/usr/perl5/bin" |
995ac8f2 MJ |
110 | #export LD_ALTEXEC=/usr/sfw/bin/gld |
111 | #export LD=/usr/sfw/bin/gld | |
7491c28d | 112 | ;; |
f7bf4d7a | 113 | macosx) |
995ac8f2 MJ |
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" | |
72d087d4 | 120 | export CFLAGS="$CFLAGS -I/opt/local/include" |
f7bf4d7a | 121 | export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" |
f7bf4d7a MJ |
122 | ;; |
123 | ||
7491c28d | 124 | *) |
995ac8f2 MJ |
125 | export MAKE=make |
126 | export TAR=tar | |
127 | export NPROC=nproc | |
7491c28d MJ |
128 | ;; |
129 | esac | |
130 | ||
cd9733d5 JR |
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. | |
72f4f0c1 | 142 | CONF_OPTS="" |
56162e2a JRJ |
143 | case "$conf" in |
144 | static) | |
145 | echo "Static build" | |
146 | CONF_OPTS="--enable-static --disable-shared" | |
147 | ;; | |
72f4f0c1 | 148 | |
a57a60d9 | 149 | tls_fallback) |
56162e2a JRJ |
150 | echo "Using pthread_getspecific() to emulate TLS" |
151 | CONF_OPTS="--disable-compiler-tls" | |
152 | ;; | |
72f4f0c1 | 153 | |
cd9733d5 JR |
154 | debug-rcu) |
155 | echo "Enable RCU sanity checks for debugging" | |
a0493692 | 156 | if vergte "$PACKAGE_VERSION" "0.10"; then |
b3fa9d68 | 157 | CONF_OPTS="--enable-rcu-debug" |
cd9733d5 | 158 | else |
72d087d4 | 159 | export CFLAGS="$CFLAGS -DDEBUG_RCU" |
cd9733d5 | 160 | fi |
25e13783 JR |
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 | |
cd9733d5 JR |
166 | ;; |
167 | ||
56162e2a JRJ |
168 | *) |
169 | echo "Standard build" | |
170 | CONF_OPTS="" | |
171 | ;; | |
172 | esac | |
173 | ||
595a34c7 JR |
174 | # Build type |
175 | # oot : out-of-tree build | |
176 | # dist: build via make dist | |
177 | # * : normal tree build | |
178 | # | |
69d7af71 MJ |
179 | # Make sure to move to the build dir and run configure |
180 | # before continuing. | |
595a34c7 | 181 | case "$build" in |
72f4f0c1 MJ |
182 | oot) |
183 | echo "Out of tree build" | |
69d7af71 MJ |
184 | |
185 | BUILDDIR=$WORKSPACE/oot | |
186 | mkdir -p "$BUILDDIR" | |
187 | cd "$BUILDDIR" | |
188 | ||
995ac8f2 | 189 | "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS |
72f4f0c1 MJ |
190 | ;; |
191 | ||
192 | dist) | |
193 | echo "Distribution out of tree build" | |
72f4f0c1 | 194 | |
69d7af71 MJ |
195 | tar_file="userspace-rcu-$PACKAGE_VERSION.tar.bz2" |
196 | ||
197 | # Initial configure in src dir and tarball generation | |
198 | ./configure | |
72f4f0c1 MJ |
199 | $MAKE dist |
200 | ||
69d7af71 MJ |
201 | BUILDDIR=$(mktemp -d) |
202 | mkdir -p "$BUILDDIR" | |
203 | cd "$BUILDDIR" | |
72f4f0c1 MJ |
204 | |
205 | # Ignore level 1 of tar | |
69d7af71 | 206 | $TAR xvf "$SRCDIR/$tar_file" --strip 1 |
72f4f0c1 | 207 | |
69d7af71 | 208 | ./configure --prefix="$PREFIX" $CONF_OPTS |
72f4f0c1 MJ |
209 | ;; |
210 | *) | |
6d35c326 | 211 | echo "Standard in-tree build" |
69d7af71 | 212 | ./configure --prefix="$PREFIX" $CONF_OPTS |
72f4f0c1 | 213 | ;; |
595a34c7 JR |
214 | esac |
215 | ||
72f4f0c1 | 216 | # BUILD! |
a57a60d9 | 217 | $MAKE -j "$($NPROC)" V=1 |
7491c28d | 218 | $MAKE install |
72f4f0c1 MJ |
219 | |
220 | # Run tests | |
6827c67a | 221 | $MAKE --keep-going check |
5fd8db76 MJ |
222 | # Only run regtest for 0.9 and up |
223 | if vergte "$PACKAGE_VERSION" "0.9"; then | |
69d7af71 | 224 | $MAKE --keep-going regtest |
5fd8db76 | 225 | fi |
72f4f0c1 | 226 | |
69d7af71 MJ |
227 | # Copy tap logs for the jenkins tap parser |
228 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap" | |
229 | ||
72f4f0c1 | 230 | # Cleanup |
7491c28d | 231 | $MAKE clean |
56162e2a | 232 | |
72f4f0c1 | 233 | # Cleanup rpath in executables and shared libraries |
0a6e708b | 234 | find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \; |
72f4f0c1 MJ |
235 | |
236 | # Remove libtool .la files | |
0a6e708b | 237 | find "$PREFIX/lib" -name "*.la" -exec rm -f {} \; |
595a34c7 | 238 | |
cdcf7df4 | 239 | # Cleanup temp directory of dist build |
72f4f0c1 | 240 | if [ "$build" = "dist" ]; then |
0a6e708b | 241 | cd "$SRCDIR" |
69d7af71 | 242 | rm -rf "$BUILDDIR" |
595a34c7 | 243 | fi |
7491c28d MJ |
244 | |
245 | # EOF |