forked from MaartenBaert/ssr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-build-and-install
executable file
·139 lines (121 loc) · 4.07 KB
/
simple-build-and-install
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
# Run this if you just want to build and install the program and you don't care about all the details.
# Any additional arguments will be passed on to 'cmake'.
# The following environment variables can be set to TRUE or FALSE to override the auto-detected values:
# - ENABLE_32BIT_GLINJECT
# - ENABLE_X86_ASM
# - ENABLE_FFMPEG_VERSIONS
# - WITH_QT5
# - WITH_GLINJECT
set -e
cd "$( dirname "${BASH_SOURCE[0]}" )"
if [ x"$( whoami )" = x"root" ]; then
echo "Error: don't run this script as root, this will mess up file permissions"
exit 1
fi
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig"
if [ -z "$ENABLE_32BIT_GLINJECT" ] || [ -z "$ENABLE_X86_ASM" ] || [ -z "$WITH_GLINJECT" ]; then
echo "Detecting architecture ..."
case "$( uname -m )" in
"i386"|"i486"|"i586"|"i686")
: ${ENABLE_32BIT_GLINJECT:="FALSE"}
: ${ENABLE_X86_ASM:="TRUE"}
: ${WITH_GLINJECT:="TRUE"}
;;
"x86_64")
: ${ENABLE_32BIT_GLINJECT:="TRUE"}
: ${ENABLE_X86_ASM:="TRUE"}
: ${WITH_GLINJECT:="TRUE"}
;;
*)
: ${ENABLE_32BIT_GLINJECT:="FALSE"}
: ${ENABLE_X86_ASM:="FALSE"}
: ${WITH_GLINJECT:="FALSE"}
;;
esac
fi
if [ -z "$ENABLE_FFMPEG_VERSIONS" ]; then
echo "Detecting ffmpeg/libav ..."
if ! pkg-config --exists libavcodec; then
echo " Error: libavcodec development package not found, make sure ffmpeg or libav development packages are installed."
exit 1
fi
LIBAVCODEC_INCLUDE_DIR="$( pkg-config --variable=includedir libavcodec )"
HAS_FFMPEG=$( grep -c "This file is part of FFmpeg." $LIBAVCODEC_INCLUDE_DIR/libavcodec/avcodec.h || true )
HAS_LIBAV=$( grep -c "This file is part of Libav." $LIBAVCODEC_INCLUDE_DIR/libavcodec/avcodec.h || true )
if [ $HAS_FFMPEG -gt 0 ]; then
if [ $HAS_LIBAV -gt 0 ]; then
echo " Error: Detected ffmpeg AND libav, this should not happen!"
exit 1
else
echo " Detected ffmpeg."
ENABLE_FFMPEG_VERSIONS="TRUE"
fi
else
if [ $HAS_LIBAV -gt 0 ]; then
echo " Detected libav."
ENABLE_FFMPEG_VERSIONS="FALSE"
else
echo " Error: Detection failed."
exit 1
fi
fi
fi
if [ -z "$WITH_QT5" ]; then
echo "Detecting Qt version ..."
if pkg-config --exists "Qt5Gui >= 5.7"; then
echo " Detected Qt5 (version $( pkg-config --modversion Qt5Gui ))."
WITH_QT5="TRUE"
elif pkg-config --exists "QtGui >= 4.8"; then
echo " Detected Qt4 (version $( pkg-config --modversion QtGui ))."
WITH_QT5="FALSE"
else
echo " Error: Qt development package not found, make sure that either Qt4 (4.8 or newer) or Qt5 (5.7 or newer) is installed."
exit 1
fi
fi
echo "Auto-detected options:"
echo " ENABLE_32BIT_GLINJECT = $ENABLE_32BIT_GLINJECT"
echo " ENABLE_X86_ASM = $ENABLE_X86_ASM"
echo " ENABLE_FFMPEG_VERSIONS = $ENABLE_FFMPEG_VERSIONS"
echo " WITH_QT5 = $WITH_QT5"
echo " WITH_GLINJECT = $WITH_GLINJECT"
PREFIX="/usr"
OPTIONS=()
OPTIONS+=("-DENABLE_32BIT_GLINJECT=$ENABLE_32BIT_GLINJECT")
OPTIONS+=("-DENABLE_X86_ASM=$ENABLE_X86_ASM")
OPTIONS+=("-DENABLE_FFMPEG_VERSIONS=$ENABLE_FFMPEG_VERSIONS")
OPTIONS+=("-DWITH_QT5=$WITH_QT5")
OPTIONS+=("-DWITH_GLINJECT=$WITH_GLINJECT")
if [ x"$WITH_QT5" == x"TRUE" ]; then
export QT_SELECT="qt5"
else
export QT_SELECT="qt4"
OPTIONS+=("-DCMAKE_AUTOMOC_MOC_OPTIONS=-D_SYS_SYSMACROS_H_OUTER")
fi
echo "Entering build-release directory ..."
rm -rf build-release
mkdir build-release
cd build-release
echo "Running cmake ..."
cmake -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_BUILD_TYPE=Release "${OPTIONS[@]}" "$@" ..
echo "Compiling ..."
make -j "$( nproc )"
if [ x"$WITH_GLINJECT" == x"TRUE" ]; then
echo "Removing old GLInject libraries ..."
sudo rm -f "/usr/lib/libssr-glinject."*
sudo rm -f "/usr/lib64/libssr-glinject."*
sudo rm -f "/usr/lib/x86_64-linux-gnu/libssr-glinject."*
if [ x"$ENABLE_32BIT_GLINJECT" == x"TRUE" ]; then
sudo rm -f "/usr/lib32/libssr-glinject."*
sudo rm -f "/usr/lib/i386-linux-gnu/libssr-glinject."*
sudo rm -f "/usr/lib/i686-linux-gnu/libssr-glinject."*
fi
fi
echo "Installing ..."
sudo make install
echo "Leaving build-release directory ..."
cd ..
echo "Running post-install script ..."
sudo ./postinstall
echo "Done."