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 MJ |
19 | # Version compare functions |
20 | verlte() { | |
f7bf4d7a | 21 | [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g | head -n1)" ] |
5fd8db76 MJ |
22 | } |
23 | ||
24 | verlt() { | |
f7bf4d7a | 25 | [ "$1" = "$2" ] && return 1 || verlte "$1" "$2" |
5fd8db76 MJ |
26 | } |
27 | ||
28 | vergte() { | |
f7bf4d7a | 29 | [ "$1" = "$(printf '%s\n%s' "$1" "$2" | sort -t '.' -k 1,1 -k 2,2 -k 3,3 -k 4,4 -g | tail -n1)" ] |
5fd8db76 MJ |
30 | } |
31 | ||
32 | vergt() { | |
f7bf4d7a | 33 | [ "$1" = "$2" ] && return 1 || vergte "$1" "$2" |
5fd8db76 MJ |
34 | } |
35 | ||
e3022ad9 | 36 | |
6d35c326 MJ |
37 | SRCDIR="$WORKSPACE/src/liburcu" |
38 | TMPDIR="$WORKSPACE/tmp" | |
56162e2a JRJ |
39 | PREFIX="$WORKSPACE/build" |
40 | ||
6d35c326 MJ |
41 | # Create build and tmp directories |
42 | rm -rf "$PREFIX" "$TMPDIR" | |
43 | mkdir -p "$PREFIX" "$TMPDIR" | |
44 | ||
45 | export TMPDIR | |
46 | ||
72f4f0c1 | 47 | # Set platform variables |
7491c28d MJ |
48 | case "$arch" in |
49 | solaris10) | |
50 | MAKE=gmake | |
51 | TAR=gtar | |
52 | NPROC=gnproc | |
53 | CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1" | |
54 | ;; | |
72f4f0c1 | 55 | |
7491c28d MJ |
56 | solaris11) |
57 | MAKE=gmake | |
58 | TAR=gtar | |
59 | NPROC=nproc | |
60 | CFLAGS="-D_XOPEN_SOURCE=1 -D_XOPEN_SOURCE_EXTENDED=1 -D__EXTENSIONS__=1" | |
61 | export PATH="$PATH:/usr/perl5/bin" | |
62 | ;; | |
72f4f0c1 | 63 | |
f7bf4d7a MJ |
64 | macosx) |
65 | MAKE=make | |
66 | TAR=tar | |
67 | NPROC="getconf _NPROCESSORS_ONLN" | |
68 | BISON="bison" | |
69 | YACC="$BISON -y" | |
70 | export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" | |
71 | export CFLAGS="-I/opt/local/include" | |
72 | export LDFLAGS="-L/opt/local/lib" | |
73 | ;; | |
74 | ||
7491c28d MJ |
75 | *) |
76 | MAKE=make | |
77 | TAR=tar | |
78 | NPROC=nproc | |
79 | CFLAGS="" | |
80 | ;; | |
81 | esac | |
82 | ||
72f4f0c1 MJ |
83 | # Set configure options for each build configuration |
84 | CONF_OPTS="" | |
56162e2a JRJ |
85 | case "$conf" in |
86 | static) | |
87 | echo "Static build" | |
88 | CONF_OPTS="--enable-static --disable-shared" | |
89 | ;; | |
72f4f0c1 | 90 | |
56162e2a JRJ |
91 | tls_fallback) |
92 | echo "Using pthread_getspecific() to emulate TLS" | |
93 | CONF_OPTS="--disable-compiler-tls" | |
94 | ;; | |
72f4f0c1 | 95 | |
56162e2a JRJ |
96 | *) |
97 | echo "Standard build" | |
98 | CONF_OPTS="" | |
99 | ;; | |
100 | esac | |
101 | ||
72f4f0c1 | 102 | |
6d35c326 MJ |
103 | # Enter the source directory |
104 | cd "$SRCDIR" | |
105 | ||
106 | # Run bootstrap in the source directory prior to configure | |
72f4f0c1 MJ |
107 | ./bootstrap |
108 | ||
5fd8db76 MJ |
109 | # Get source version from configure script |
110 | eval `grep '^PACKAGE_VERSION=' ./configure` | |
111 | ||
72f4f0c1 | 112 | |
595a34c7 JR |
113 | # Build type |
114 | # oot : out-of-tree build | |
115 | # dist: build via make dist | |
116 | # * : normal tree build | |
117 | # | |
118 | # Make sure to move to the build_path and configure | |
119 | # before continuing | |
6d35c326 | 120 | BUILD_PATH=$SRCDIR |
595a34c7 | 121 | case "$build" in |
72f4f0c1 MJ |
122 | oot) |
123 | echo "Out of tree build" | |
124 | BUILD_PATH=$WORKSPACE/oot | |
125 | mkdir -p $BUILD_PATH | |
126 | cd $BUILD_PATH | |
6d35c326 | 127 | MAKE=$MAKE CFLAGS="$CFLAGS" $SRCDIR/configure --prefix=$PREFIX $CONF_OPTS |
72f4f0c1 MJ |
128 | ;; |
129 | ||
130 | dist) | |
131 | echo "Distribution out of tree build" | |
132 | BUILD_PATH=`mktemp -d` | |
133 | ||
134 | # Initial configure and generate tarball | |
6d35c326 | 135 | MAKE=$MAKE $SRCDIR/configure |
72f4f0c1 MJ |
136 | $MAKE dist |
137 | ||
138 | mkdir -p $BUILD_PATH | |
139 | cp *.tar.* $BUILD_PATH/ | |
140 | cd $BUILD_PATH | |
141 | ||
142 | # Ignore level 1 of tar | |
143 | $TAR xvf *.tar.* --strip 1 | |
144 | ||
145 | MAKE=$MAKE CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS | |
146 | ;; | |
147 | *) | |
6d35c326 MJ |
148 | echo "Standard in-tree build" |
149 | MAKE=$MAKE CFLAGS="$CFLAGS" $BUILD_PATH/configure --prefix=$PREFIX $CONF_OPTS | |
72f4f0c1 | 150 | ;; |
595a34c7 JR |
151 | esac |
152 | ||
72f4f0c1 | 153 | # BUILD! |
fe584a39 | 154 | $MAKE -j `$NPROC` V=1 |
7491c28d | 155 | $MAKE install |
72f4f0c1 MJ |
156 | |
157 | # Run tests | |
7491c28d | 158 | $MAKE check |
5fd8db76 MJ |
159 | # Only run regtest for 0.9 and up |
160 | if vergte "$PACKAGE_VERSION" "0.9"; then | |
72f4f0c1 | 161 | $MAKE regtest |
5fd8db76 | 162 | fi |
72f4f0c1 MJ |
163 | |
164 | # Cleanup | |
7491c28d | 165 | $MAKE clean |
56162e2a | 166 | |
72f4f0c1 MJ |
167 | # Cleanup rpath in executables and shared libraries |
168 | #find $WORKSPACE/build/bin -type f -perm -0500 -exec chrpath --delete {} \; | |
6d35c326 | 169 | find $PREFIX/lib -name "*.so" -exec chrpath --delete {} \; |
72f4f0c1 MJ |
170 | |
171 | # Remove libtool .la files | |
6d35c326 | 172 | find $PREFIX/lib -name "*.la" -exec rm -f {} \; |
595a34c7 | 173 | |
cdcf7df4 | 174 | # Cleanup temp directory of dist build |
72f4f0c1 | 175 | if [ "$build" = "dist" ]; then |
6d35c326 | 176 | cd $SRCDIR |
72f4f0c1 | 177 | rm -rf $BUILD_PATH |
595a34c7 | 178 | fi |
7491c28d MJ |
179 | |
180 | # EOF |