forked from phillipberndt/fakexrandr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·69 lines (61 loc) · 2.26 KB
/
configure
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
#!/bin/bash
# 1) Determine xrandr version
IFS="."
XRANDR_VERSION=( $(pkg-config --modversion xrandr) )
if ! [ $? -eq 0 ]; then
exit 1
fi
echo "XRandR version is ${XRANDR_VERSION[*]}"
unset IFS
# For convenience: Check if Xlib headers are present
pkg-config --exists x11 || exit 1
# 2) Determine path to real xrandr library
REAL_LIBRARY=$(ldd `which xrandr` | sed -nre 's/.+libXrandr.so.+=> ([^ ]+).*/\1/p')
echo "The path to the real XRandR library is ${REAL_LIBRARY}"
if echo "${REAL_LIBRARY}" | grep -q local; then
echo -e "\033[31mWARNING: \033[0m This looks as if you already have fakexrandr installed?!"
REAL_LIBRARY=$(find /usr/lib -name libXrandr.so | head -n 1)
if [ -z ${REAL_LIBRARY} ]; then
echo " Aborting: No other candidate was found in /usr/lib"
exit 1
fi
echo " Using ${REAL_LIBRARY} instead. (Found using \`file')"
fi
REAL_LIBRARY_DIR=$(dirname "${REAL_LIBRARY}")
# 3) Determine location for fake xrandr library
LIBRARY_DIRECTORIES=($(ldconfig -v 2>/dev/null | grep -oE '^/[^:]+'))
FAKE_LIBRARY_DIRECTORY=
CANDIDATES=
for DIR in ${LIBRARY_DIRECTORIES[@]}; do
if [ "$DIR" == "${REAL_LIBRARY_DIR}" ]; then
break
fi
CANDIDATES+="$DIR, "
if echo $DIR | grep -q local; then
FAKE_LIBRARY_DIRECTORY=$DIR
break
fi
done
if [ -z "${FAKE_LIBRARY_DIRECTORY}" ]; then
echo
echo -e "\033[31mERROR:\033[0m Failed to find a suitable directory for the fakeXrandr library"
echo
echo "You must place the library into the library search path, in a directory preceeding"
echo "${REAL_LIBRARY_DIR}. In your system, this leaves the following candidates:"
echo $CANDIDATES
echo "None of these contains \`local', therefore I won't autoconfigure the installation to one"
echo "of these directories. Either add a high-priority directory in /usr/local using the ldconfig"
echo "mechanism (See /etc/ld.so.conf.d/ on most systems) or manually create config.h."
echo
exit 1
fi
echo "The fake library will be installed to ${FAKE_LIBRARY_DIRECTORY}"
cat > config.h <<EOF
/* This file was automatically generated by ./configure */
#define XRANDR_MAJOR ${XRANDR_VERSION[0]}
#define XRANDR_MINOR ${XRANDR_VERSION[1]}
#define XRANDR_PATCH ${XRANDR_VERSION[2]}
#define REAL_XRANDR_LIB "${REAL_LIBRARY}"
#define FAKEXRANDR_INSTALL_DIR "${FAKE_LIBRARY_DIRECTORY}"
EOF
exit 0