forked from MaartenBaert/ssr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-build-and-install
executable file
·122 lines (103 loc) · 3.48 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
#!/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 'configure'.
# If you want to modify configure.ac or Makefile.am, you will need the correct version of autotools, and you should
# run configure (or this script) with --enable-maintainer-mode.
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
echo "Detecting x86/x64 ..."
case "$( uname -m )" in
"i386" ) ENABLE_X86_ASM="--enable-x86-asm" ;;
"i486" ) ENABLE_X86_ASM="--enable-x86-asm" ;;
"i586" ) ENABLE_X86_ASM="--enable-x86-asm" ;;
"i686" ) ENABLE_X86_ASM="--enable-x86-asm" ;;
"x86_64" ) ENABLE_X86_ASM="--enable-x86-asm" ;;
* ) ENABLE_X86_ASM="--disable-x86-asm --disable-glinjectlib" ;;
esac
echo "x86/x64 = $ENABLE_X86_ASM"
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig
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 "Fatal: Detected ffmpeg AND libav, this should not happen!"
exit 1
else
echo "Detected ffmpeg."
ENABLE_FFMPEG_VERSIONS="--enable-ffmpeg-versions"
fi
else
if [ $HAS_LIBAV -gt 0 ]; then
echo "Detected libav."
ENABLE_FFMPEG_VERSIONS="--disable-ffmpeg-versions"
else
echo "Fatal: Detection failed."
exit 1
fi
fi
CONFIGURE_OPTIONS="--disable-assert $ENABLE_X86_ASM $ENABLE_FFMPEG_VERSIONS"
export CPPFLAGS=""
export CFLAGS="-Wall -O2 -pipe"
export CXXFLAGS="-Wall -O2 -pipe"
export LDFLAGS=""
export CPPFLAGS="$CPPFLAGS `pkg-config --cflags-only-I libavformat libavcodec libavutil libswscale`"
export LDFLAGS="$LDFLAGS `pkg-config --libs-only-L libavformat libavcodec libavutil libswscale`"
mkdir -p build
cd build
echo "Configuring ..."
if [ x"$( uname -m )" = x"x86_64" ]; then
if [ -d "/usr/lib32" ]; then
LIB32DIR=/usr/lib32
else
LIB32DIR=/usr/lib
fi
if [ -d "/usr/lib64" ]; then
LIB64DIR=/usr/lib64
else
LIB64DIR=/usr/lib
fi
if [ x"$LIB32DIR" == x"$LIB64DIR" ]; then
echo "Fatal: Same lib directories found for 32-bit and 64-bit. This should not happen!"
exit 1
fi
PKG_CONFIG_PATH="$LIB64DIR/pkgconfig" \
../configure --prefix=/usr --libdir=$LIB64DIR $CONFIGURE_OPTIONS "$@"
else
../configure --prefix=/usr $CONFIGURE_OPTIONS "$@"
fi
echo "Compiling ..."
make -j "$( nproc )"
cd ..
if [ x"$( uname -m )" = x"x86_64" ]; then
mkdir -p build32
cd build32
echo "Configuring 32-bit GLInject library ..."
CC="gcc -m32" CXX="g++ -m32" PKG_CONFIG_PATH="$LIB32DIR/pkgconfig" \
../configure --prefix=/usr --libdir=$LIB32DIR --disable-ssrprogram $CONFIGURE_OPTIONS "$@"
echo "Compiling 32-bit GLInject library ..."
make -j "$( nproc )"
cd ..
fi
cd build
echo "Installing ..."
sudo make install
cd ..
if [ x$( uname -m ) = x"x86_64" ]; then
cd build32
echo "Installing 32-bit GLInject library ..."
sudo make install
cd ..
fi
echo "Running post-install script ..."
sudo ./postinstall
echo "Done."