-
Notifications
You must be signed in to change notification settings - Fork 8
/
configure
executable file
·41 lines (34 loc) · 1.47 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
#!/bin/bash
true ${CC="gcc"}
rm -f config.mak2
rm -f config.h
echo > config.h
echo > config.mak2
for i in "$@"; do
if [ "${i/FLAGS=//}" != "$i" ]; then
echo "$i" >> config.mak2
fi
done
"$CC" -E -o /dev/null -x c - <<< '#include <linux/securebits.h>' || echo "#define SECUREBITS_WORKAROUND" >> config.h
"$CC" -E -o /dev/null -x c - <<< '#include <sys/signalfd.h>' || echo "#define SIGNALFD_WORKAROUND" >> config.h
"$CC" -E -o /dev/null -x c - <<< '#include <sys/capability.h>' || (
echo 'NO_CAPABILITIES=1' >> config.mak2
echo "#define NO_CAPABILITIES" >> config.h
echo
)
if [[ "$(printf '#define _GNU_SOURCE\n#include <sched.h>\nCLONE_NEWUSER\n' | "$CC" -E -x c - | tail -n 1)" == "CLONE_NEWUSER" ]]; then
echo "#define CLONE_PARAMETERS_WORKAROUND" >> config.h
fi
if ! printf '#define _GNU_SOURCE\n#include <sched.h>\n' | "$CC" -E -x c - | grep '\<setns\>'; then
echo "#define NO_SETNS" >> config.h
fi
if ! printf '#define _GNU_SOURCE\n#include <unistd.h>\n' | "$CC" -E -x c - | grep '\<execvpe\>'; then
echo "#define NO_EXECVPE" >> config.h
fi
if ! printf '#define _GNU_SOURCE\n#include <sched.h>\n' | "$CC" -E -x c - | grep '\<unshare\>'; then
echo "#define NO_UNSHARE" >> config.h
fi
if ! printf '#define _GNU_SOURCE 1\n#include <sys/syscall.h>\nSYS_pivot_root' | "$CC" -E -x c - | tail -n 1 | grep '^\s*0\?x\?[0-9]'; then
echo "#define NO_PIVOTROOT" >> config.h
fi
echo "Configuration finished, wrote necessary workarounds to config.h"