Commit | Line | Data |
---|---|---|
72f4f0c1 | 1 | #!/bin/bash -exu |
e3022ad9 MJ |
2 | # |
3 | # Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> | |
6d35c326 | 4 | # 2016 - 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 | ||
6d35c326 MJ |
82 | # Create build and tmp directories |
83 | rm -rf "$PREFIX" "$TMPDIR" | |
84 | mkdir -p "$PREFIX" "$TMPDIR" | |
85 | ||
86 | export TMPDIR | |
72d087d4 | 87 | export CFLAGS="-g -O2" |
6d35c326 | 88 | |
72f4f0c1 | 89 | # Set platform variables |
7491c28d | 90 | case "$arch" in |
995ac8f2 MJ |
91 | sol10-i386) |
92 | export MAKE=gmake | |
93 | export TAR=gtar | |
94 | export NPROC=gnproc | |
95 | export BISON=bison | |
96 | export YACC="$BISON -y" | |
ad11244c | 97 | export PATH="/opt/csw/bin:/usr/ccs/bin:$PATH" |
995ac8f2 MJ |
98 | export CPPFLAGS="-I/opt/csw/include" |
99 | export LDFLAGS="-L/opt/csw/lib -R/opt/csw/lib" | |
100 | export PKG_CONFIG_PATH="/opt/csw/lib/pkgconfig" | |
7491c28d | 101 | ;; |
995ac8f2 MJ |
102 | sol11-i386) |
103 | export MAKE=gmake | |
104 | export TAR=gtar | |
105 | export NPROC=nproc | |
106 | export BISON="/opt/csw/bin/bison" | |
107 | export YACC="$BISON -y" | |
7491c28d | 108 | export PATH="$PATH:/usr/perl5/bin" |
995ac8f2 MJ |
109 | #export LD_ALTEXEC=/usr/sfw/bin/gld |
110 | #export LD=/usr/sfw/bin/gld | |
7491c28d | 111 | ;; |
f7bf4d7a | 112 | macosx) |
995ac8f2 MJ |
113 | export MAKE=make |
114 | export TAR=tar | |
115 | export NPROC="getconf _NPROCESSORS_ONLN" | |
116 | export BISON="bison" | |
117 | export YACC="$BISON -y" | |
118 | export LDFLAGS="-L/opt/local/lib" | |
72d087d4 | 119 | export CFLAGS="$CFLAGS -I/opt/local/include" |
f7bf4d7a | 120 | export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" |
f7bf4d7a MJ |
121 | ;; |
122 | ||
7491c28d | 123 | *) |
995ac8f2 MJ |
124 | export MAKE=make |
125 | export TAR=tar | |
126 | export NPROC=nproc | |
7491c28d MJ |
127 | ;; |
128 | esac | |
129 | ||
cd9733d5 JR |
130 | # Enter the source directory |
131 | cd "$SRCDIR" | |
132 | ||
133 | # Run bootstrap in the source directory prior to configure | |
134 | ./bootstrap | |
135 | ||
136 | # Get source version from configure script | |
137 | eval "$(grep '^PACKAGE_VERSION=' ./configure)" | |
138 | ||
139 | # Set configure options and environment variables for each build | |
140 | # configuration. | |
72f4f0c1 | 141 | CONF_OPTS="" |
56162e2a JRJ |
142 | case "$conf" in |
143 | static) | |
144 | echo "Static build" | |
145 | CONF_OPTS="--enable-static --disable-shared" | |
146 | ;; | |
72f4f0c1 | 147 | |
a57a60d9 | 148 | tls_fallback) |
56162e2a JRJ |
149 | echo "Using pthread_getspecific() to emulate TLS" |
150 | CONF_OPTS="--disable-compiler-tls" | |
151 | ;; | |
72f4f0c1 | 152 | |
cd9733d5 JR |
153 | debug-rcu) |
154 | echo "Enable RCU sanity checks for debugging" | |
a0493692 | 155 | if vergte "$PACKAGE_VERSION" "0.10"; then |
b3fa9d68 | 156 | CONF_OPTS="--enable-rcu-debug" |
cd9733d5 | 157 | else |
72d087d4 | 158 | export CFLAGS="$CFLAGS -DDEBUG_RCU" |
cd9733d5 JR |
159 | fi |
160 | ;; | |
161 | ||
56162e2a JRJ |
162 | *) |
163 | echo "Standard build" | |
164 | CONF_OPTS="" | |
165 | ;; | |
166 | esac | |
167 | ||
595a34c7 JR |
168 | # Build type |
169 | # oot : out-of-tree build | |
170 | # dist: build via make dist | |
171 | # * : normal tree build | |
172 | # | |
173 | # Make sure to move to the build_path and configure | |
174 | # before continuing | |
6d35c326 | 175 | BUILD_PATH=$SRCDIR |
595a34c7 | 176 | case "$build" in |
72f4f0c1 MJ |
177 | oot) |
178 | echo "Out of tree build" | |
179 | BUILD_PATH=$WORKSPACE/oot | |
0a6e708b MJ |
180 | mkdir -p "$BUILD_PATH" |
181 | cd "$BUILD_PATH" | |
995ac8f2 | 182 | "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS |
72f4f0c1 MJ |
183 | ;; |
184 | ||
185 | dist) | |
186 | echo "Distribution out of tree build" | |
a57a60d9 | 187 | BUILD_PATH=$(mktemp -d) |
72f4f0c1 MJ |
188 | |
189 | # Initial configure and generate tarball | |
995ac8f2 | 190 | "$SRCDIR/configure" |
72f4f0c1 MJ |
191 | $MAKE dist |
192 | ||
0a6e708b MJ |
193 | mkdir -p "$BUILD_PATH" |
194 | cp ./*.tar.* "$BUILD_PATH/" | |
195 | cd "$BUILD_PATH" | |
72f4f0c1 MJ |
196 | |
197 | # Ignore level 1 of tar | |
0a6e708b | 198 | $TAR xvf ./*.tar.* --strip 1 |
72f4f0c1 | 199 | |
995ac8f2 | 200 | "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
72f4f0c1 MJ |
201 | ;; |
202 | *) | |
6d35c326 | 203 | echo "Standard in-tree build" |
995ac8f2 | 204 | "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
72f4f0c1 | 205 | ;; |
595a34c7 JR |
206 | esac |
207 | ||
72f4f0c1 | 208 | # BUILD! |
a57a60d9 | 209 | $MAKE -j "$($NPROC)" V=1 |
7491c28d | 210 | $MAKE install |
72f4f0c1 MJ |
211 | |
212 | # Run tests | |
6827c67a | 213 | $MAKE --keep-going check |
5fd8db76 MJ |
214 | # Only run regtest for 0.9 and up |
215 | if vergte "$PACKAGE_VERSION" "0.9"; then | |
72f4f0c1 | 216 | $MAKE regtest |
5fd8db76 | 217 | fi |
72f4f0c1 MJ |
218 | |
219 | # Cleanup | |
7491c28d | 220 | $MAKE clean |
56162e2a | 221 | |
72f4f0c1 MJ |
222 | # Cleanup rpath in executables and shared libraries |
223 | #find $WORKSPACE/build/bin -type f -perm -0500 -exec chrpath --delete {} \; | |
0a6e708b | 224 | find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \; |
72f4f0c1 MJ |
225 | |
226 | # Remove libtool .la files | |
0a6e708b | 227 | find "$PREFIX/lib" -name "*.la" -exec rm -f {} \; |
595a34c7 | 228 | |
cdcf7df4 | 229 | # Cleanup temp directory of dist build |
72f4f0c1 | 230 | if [ "$build" = "dist" ]; then |
0a6e708b MJ |
231 | cd "$SRCDIR" |
232 | rm -rf "$BUILD_PATH" | |
595a34c7 | 233 | fi |
7491c28d MJ |
234 | |
235 | # EOF |