-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-gnur.sh
executable file
·112 lines (94 loc) · 2.48 KB
/
build-gnur.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
set -Eeuo pipefail
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
BASE_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
R_DIR=""
if [ ! -d "$BASE_DIR" ]; then
echo "Could not determine absolute dir of $0"
echo "Maybe accessed with symlink"
exit 1
fi
function usage() {
echo "$0 [-d] <R sources path>"
}
while [[ $# -gt 0 ]]; do
case $1 in
-d | --debug)
export CFLAGS="-ggdb3 -O0"
export CXXFLAGS="-ggdb3 -O0"
export CPPFLAGS="-ggdb3 -O0"
echo "Building a debug version of R"
shift
;;
-*)
echo "Unknown option $1"
exit 1
;;
*)
if [[ -z "$R_DIR" ]]; then
R_DIR="$1"
shift
else
echo "Unknown options $*"
exit 1
fi
;;
esac
done
if [[ -z "$R_DIR" ]]; then
usage
exit 1
fi
echo "Building in $R_DIR"
if [[ "$OSTYPE" == "darwin"* ]]; then
USING_OSX=1
else
USING_OSX=0
fi
if [[ ! -f ${R_DIR}/.git ]]; then
echo "-> update submodules"
git submodule update --init
fi
function build {
cd "$R_DIR"
if [[ $(git diff --shortstat 2>/dev/null | tail -n1) != "" ]]; then
echo "** warning: $R_DIR repo is dirty"
sleep 1
fi
tools/rsync-recommended
if [[ ! -f Makefile ]]; then
echo "-> configure"
if [ $USING_OSX -eq 1 ]; then
./configure --enable-R-shlib --with-internal-tzcode --with-ICU=no --with-x=no || cat config.log
else
./configure
fi
fi
if [ ! -f doc/FAQ ]; then
touch doc/FAQ
fi
if [ ! -f "$R_DIR/SVN-REVISION" ]; then
# R must either be built from a svn checkout, or from the tarball generated by make dist
# this is a workaround to build it from a git mirror
# see https://github.com/wch/r-source/wiki/Home/6d35777dcb772f86371bf221c194ca0aa7874016#building-r-from-source
echo -n 'Revision: ' >SVN-REVISION
# get the latest revision that is not a rir patch
REV=$(git log --grep "git-svn-id" -1 --format=%B | grep "^git-svn-id" | sed -E 's/^git-svn-id: https:\/\/svn.r-project.org\/R\/[^@]*@([0-9]+).*$/\1/')
# can fail on shallow checkouts, so let's put the last known there
if [ "$REV" == "" ]; then
REV='74948'
fi
echo "$REV" >>SVN-REVISION
echo -n 'Last Changed Date: ' >>SVN-REVISION
REV_DATE=$(git log --grep "git-svn-id" -1 --pretty=format:"%ad" --date=iso | cut -d' ' -f1)
# can fail on shallow checkouts, so let's put the last known there
if [ "$REV_DATE" == "" ]; then
REV_DATE='2018-07-02'
fi
echo "$REV_DATE" >>SVN-REVISION
rm -f non-tarball
fi
echo "-> make"
make -j8
}
build