-
Notifications
You must be signed in to change notification settings - Fork 153
/
dependencies.sh
executable file
·84 lines (71 loc) · 2.46 KB
/
dependencies.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
#!/bin/sh
#### This function emulates readlink -f, not available on osx ####
readlink2()
{
MYWD=`pwd`
TARGET_FILE=$1
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=`readlink $TARGET_FILE`
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
PHYS_DIR=`pwd -P`
RESULT=$PHYS_DIR/$TARGET_FILE
# restore working directory
cd "$MYWD"
echo $RESULT
}
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=$(readlink2 "$0")
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=$(dirname "$SCRIPT")
CURDIR="$PWD"
if [ "x${WORKDIR}" = "x" ]; then
WORKDIR="$PWD/build"
fi
mkdir -p "$WORKDIR" || exit 1
if [ "x${PKG_CONFIG}" = "x" ]; then
PKG_CONFIG=`which pkg-config`
fi
which "$PKG_CONFIG" ||(echo "Please install pkg-config"; exit 1)
"$PKG_CONFIG" --exists libpcre2-8 && HAVE_PCRE2="yes" || HAVE_PCRE2="no"
echo "Have PCRE2? [${HAVE_PCRE2}]"
if [ "x${HAVE_PCRE2}" = "xno" ]; then
# Prepare pcre2-10.23 source:
(mkdir -p "${WORKDIR}/thirdparty/" && \
cd "${WORKDIR}/thirdparty" && \
wget "https://master.dl.sourceforge.net/project/pcre/pcre2/10.23/pcre2-10.23.zip"
echo "56c07f59ccd052ccdbdedadf24574a63 pcre2-10.23.zip" | md5sum -c || exit 1
unzip "pcre2-10.23.zip" && \
cd "pcre2-10.23" && \
patch -p1 < "${SCRIPTPATH}/thirdparty/pcre2.patch" && \
autoreconf -fi ) || exit 1
# Build pcre2-10.23:
mkdir -p "${WORKDIR}/thirdparty/build_pcre2" || exit 1
cd "${WORKDIR}/thirdparty/build_pcre2" || exit 1
${WORKDIR}/thirdparty/pcre2-10.23/configure --disable-option-checking $@ || exit 1
make || exit 1
make install && echo "PCRE2 installation succeeded" || (
cat << EOF
PCRE was successfully compiled. However, it could not be installed.
The most likely cause is a lack of permissions. This script will try to run
the installation with sudo asking your password.
EOF
sudo make install && echo "PCRE2 installation succeeded" || (
cat << EOF
The installation failed. Please run this or check other possible errors:
cd "${WORKDIR}/thirdparty/build_pcre2"
sudo make install
In case you do not have admin permissions you can install everything to a custom
directory by running dependencies.sh with --prefix="/a/writable/directory"
EOF
exit 1)
exit 1 )
fi
cd "${CURDIR}"