-
Notifications
You must be signed in to change notification settings - Fork 15
/
configure
executable file
·170 lines (150 loc) · 3.72 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/sh
enable_doc=auto
help() {
cat <<EOF
usage: ./configure [options]
options:
--help show this help message
--prefix=DIR installation prefix
--bindir=DIR binary dir (PREFIX/bin)
--datarootdir=DIR data root directory (PREFIX/share)
--mandir=DIR manual page root directory (DATAROOTDIR/man)
--man1dir=DIR section 1 manual page directory (MANDIR/man1)
--enable-doc enable documentation (default: if rst2man is found)
--disable-doc disable documentation
EOF
}
die() {
echo "$@" >&2
exit 1
}
logmsg() {
echo "$@"
echo "$@" >&4
}
logrun() {
echo "$@" >&4
"$@" >&4 2>&4
logrun_res="$?"
echo "---" >&4
echo >&4
return "$logrun_res"
}
for opt; do
case "$opt" in
-h|--h|--help) help; exit 0 ;;
--prefix=*) PREFIX="${opt#--prefix=}" ;;
--bindir=*) BINDIR="${opt#--bindir=}" ;;
--datarootdir=*) DATAROOTDIR="${opt#--datarootdir=}" ;;
--mandir=*) MANDIR="${opt#--mandir=}" ;;
--man1dir=*) MAN1DIR="${opt#--man1dir=}" ;;
--enable-doc=*) enable_doc="${doc#--enable-doc=}" ;;
--enable-doc) enable_doc=yes ;;
--disable-doc) enable_doc=no ;;
*) die "Unknown option: $opt" ;;
esac
done
rm -f config.log
exec 4>config.log
absdirname()
(cd `dirname $1`; pwd)
SOURCEDIR=`absdirname $0`
NETEVENT_VERSION="$(sed -ne '/^# Release/{s/^# Release\s*//;p;q}' "$SOURCEDIR/ChangeLog.md")"
PREFIX="${PREFIX:-/usr/local}"
BINDIR="${BINDIR:-${PREFIX}/bin}"
DATAROOTDIR="${DATAROOTDIR:-${PREFIX}/share}"
MANDIR="${MANDIR:-${DATAROOTDIR}/man}"
MAN1DIR="${MAN1DIR:-${MANDIR}/man1}"
isautoyes() {
case "$1" in
auto|[Yy][Ee][Ss]|1|[Oo][Nn]|[Tt][Rr][Uu][Ee])
return 0 ;;
*)
return 1 ;;
esac
}
if test -z "$CXX"; then
if which clang++ >/dev/null 2>&1; then
CXX=clang++
elif which g++ >/dev/null 2>&1; then
CXX=g++
else
echo
echo "failed to find a compiler, please set \$CXX" >&2
exit 1
fi
fi
echo -n 'Checking for rst2man...'
if isautoyes "$enable_doc"; then
ENABLE_DOC=y
if test -z "$RST2MAN"; then
RST2MAN="$(which rst2man 2>/dev/null)"
if [ $? -ne 0 ]; then
ENABLE_DOC=
RST2MAN=
if [ "x$enable_doc" != "xauto" ]; then
echo "failed to find rst2man" >&2
exit 1
fi
fi
fi
else
ENABLE_DOC=
RST2MAN=
fi
if [ "x$ENABLE_DOC" = x ]; then
echo 'no, disabling documentation building'
else
echo "$RST2MAN"
fi
trycc() {
echo "$1" >.cfgtest.cpp
logrun $CXX $CPPFLAGS $CXXFLAGS -c -o .cfgtest.o .cfgtest.cpp
try_compile_result="$?"
rm -f .cfgtest.o .cfgtest.cpp
return $try_compile_result
}
UI_DEV_CKPROG="#include <sys/ioctl.h>
#include <linux/uinput.h>
int main() {
struct uinput_setup setup;
ioctl(0, UI_DEV_SETUP);
ioctl(0, UI_ABS_SETUP);
return 0;
}
"
echo -n 'Checking for UI_DEV_SETUP (kernel >= 4.4)...'
if trycc "$UI_DEV_CKPROG"; then
HAS_UI_DEV_SETUP='#define HAS_UI_DEV_SETUP'
echo "ok"
else
HAS_UI_DEV_SETUP='/* #undef HAS_UI_DEV_SETUP */'
echo "no (disabling)"
fi
rm -f config.h
echo '#ifndef NETEVENT_2_CONFIG_H' >>config.h
echo '#define NETEVENT_2_CONFIG_H' >>config.h
echo >>config.h
echo "#define NETEVENT_VERSION \"$NETEVENT_VERSION\"" >>config.h
echo "$HAS_UI_DEV_SETUP" >>config.h
echo >>config.h
echo '#endif' >>config.h
rm -f config.mak
cat >config.mak <<EOF
PREFIX = ${PREFIX}
BINDIR = ${BINDIR}
DATAROOTDIR = ${DATAROOTDIR}
MANDIR = ${MANDIR}
MAN1DIR = ${MAN1DIR}
ENABLE_DOC = ${ENABLE_DOC}
RST2MAN = ${RST2MAN}
CXX = ${CXX}
SOURCEDIR = ${SOURCEDIR}
EOF
if [ "${SOURCEDIR}" != "${PWD}" ]; then
# Only use VPATH for out-of-tree builds; it can be problematic for some
# variants of `make` and users of these variants will be limited to in-tree
# builds only.
echo >>config.mak "VPATH = ${SOURCEDIR}"
cp "${SOURCEDIR}/Makefile" ./
fi