add F_GETOWNER_UIDS fcntl flag
[trinity.git] / configure.sh
blob91916ba8afd5a092510b8cdda4df9bcede854dad
1 #!/bin/bash
3 DEVEL=0
5 if [ -t 1 ]; then
6 RED="\e[1;31m"
7 GREEN="\e[1;32m"
8 COL_RESET="\e[0;m"
9 fi
11 MISSING_DEFS=0
13 [ -z "$CC" ] && CC=gcc
15 # expand tilde
16 CC="$(eval echo ${CROSS_COMPILE}${CC})"
18 CFLAGS=""
19 if [ "${SYSROOT}xx" != "xx" ]; then
20 CFLAGS="$(eval echo --sysroot=${SYSROOT} )"
23 echo "/* This file is auto-generated by configure.sh */" > config.h
25 TMP=$(mktemp)
27 check_header()
29 echo -n "[*] Checking header $1 ... "
31 rm -f "$TMP" || exit 1
32 echo "#include <$1>" >"$TMP.c"
34 ${CC} ${CFLAGS} "$TMP.c" -E &>"$TMP.log"
35 if [ $? -eq 0 ]; then
36 echo $GREEN "[YES]" $COL_RESET
37 echo "#define $2 1" >> config.h
38 else
39 echo $RED "[NO]" $COL_RESET
40 MISSING_DEFS=1
44 #############################################################################################
46 echo -n "#define " >> config.h
47 grep VERSION= Makefile | sed 's/=/ /' >> config.h
49 #############################################################################################
51 echo "[*] Checking system headers."
53 #############################################################################################
54 # is /usr/include/linux/if_pppox.h new enough to feature pppol2tpin6/pppol2tpv3in6
56 echo -n "[*] Checking if pppox can use pppol2tpin6.. "
57 rm -f "$TMP" || exit 1
59 cat >"$TMP.c" << EOF
60 #include <stdio.h>
61 #include <netinet/in.h>
62 #include <linux/if.h>
63 #include <linux/if_pppox.h>
65 void main()
67 struct sockaddr_pppol2tpin6 *pppox;
68 printf("%d\n", pppox->sa_family);
70 EOF
72 ${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
73 if [ ! -x "$TMP" ]; then
74 echo $RED "[NO]" $COL_RESET
75 MISSING_DEFS=1
76 else
77 echo $GREEN "[YES]" $COL_RESET
78 echo "#define USE_PPPOL2TPIN6 1" >> config.h
81 #############################################################################################
82 # is /usr/include/linux/if_pppox.h new enough to feature pppol2tpv3
84 echo -n "[*] Checking if pppox can use pppol2tv3.. "
85 rm -f "$TMP" || exit 1
87 cat >"$TMP.c" << EOF
88 #include <stdio.h>
89 #include <netinet/in.h>
90 #include <linux/if.h>
91 #include <linux/if_pppox.h>
93 void main()
95 struct sockaddr_pppol2tpv3 *pppox;
96 printf("%d\n", pppox->sa_family);
98 EOF
100 ${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
101 if [ ! -x "$TMP" ]; then
102 echo $RED "[NO]" $COL_RESET
103 MISSING_DEFS=1
104 else
105 echo $GREEN "[YES]" $COL_RESET
106 echo "#define USE_PPPOL2TPV3 1" >> config.h
109 #############################################################################################
110 # is /usr/include/linux/if_pppox.h new enough to feature pptp
112 echo -n "[*] Checking if pppox can use pptp.. "
113 rm -f "$TMP" || exit 1
115 cat >"$TMP.c" << EOF
116 #include <stdio.h>
117 #include <netinet/in.h>
118 #include <linux/if.h>
119 #include <linux/if_pppox.h>
121 void main()
123 struct sockaddr_pppox *pppox;
124 printf("%d\n", pppox->sa_addr.pptp.call_id);
128 ${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
129 if [ ! -x "$TMP" ]; then
130 echo $RED "[NO]" $COL_RESET
131 MISSING_DEFS=1
132 else
133 echo $GREEN "[YES]" $COL_RESET
134 echo "#define USE_PPPOX_PPTP 1" >> config.h
137 #############################################################################################
138 # is /usr/include/linux/llc.h new enough to feature LLC_OPT_PKTINFO
140 echo -n "[*] Checking if llc can use LLC_OPT_PKTINFO.. "
141 rm -f "$TMP" || exit 1
143 cat >"$TMP.c" << EOF
144 #include <stdio.h>
145 #include <net/if.h>
146 #include <linux/llc.h>
148 void main()
150 printf("%d\n", LLC_OPT_PKTINFO);
154 ${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
155 if [ ! -x "$TMP" ]; then
156 echo $RED "[NO]" $COL_RESET
157 MISSING_DEFS=1
158 else
159 echo $GREEN "[YES]" $COL_RESET
160 echo "#define USE_LLC_OPT_PKTINFO 1" >> config.h
163 #############################################################################################
164 # Do glibc headers provides struct termios2
166 echo -n "[*] Checking if glibc headers provide termios2.. "
167 rm -f "$TMP" || exit 1
169 cat >"$TMP.c" << EOF
170 #include <sys/ioctl.h>
171 #include <sys/vt.h>
172 #include <termios.h>
174 int main()
176 struct termios2 test;
180 ${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
181 if [ ! -x "$TMP" ]; then
182 echo $RED "[NO]" $COL_RESET
183 MISSING_DEFS=1
184 else
185 echo $GREEN "[YES]" $COL_RESET
186 echo "#define HAVE_TERMIOS2 1" >> config.h
189 #############################################################################################
191 check_header linux/caif/caif_socket.h USE_CAIF
192 check_header linux/if_alg.h USE_IF_ALG
193 check_header linux/rds.h USE_RDS
194 check_header linux/vfio.h USE_VFIO
195 check_header linux/btrfs.h USE_BTRFS
196 check_header drm/drm.h USE_DRM
197 check_header drm/exynos_drm.h USE_DRM_EXYNOS
198 check_header sound/compress_offload.h USE_SNDDRV_COMPRESS_OFFLOAD
199 check_header linux/kvm.h USE_KVM
200 check_header linux/seccomp.h USE_SECCOMP
201 check_header linux/vhost.h USE_VHOST
203 rm -f "$TMP" "$TMP.log" "$TMP.c"
205 #############################################################################################
206 if [ "$DEVEL" == "1" ]; then
207 VER=$(git describe --always)
208 echo "#define GITVERSION \""$VER\" >> config.h
211 #############################################################################################
213 if [ "$MISSING_DEFS" == "1" ]; then
214 echo "[-] Some header definitions were missing. This is not fatal."
215 echo " It usually means you're building on an older distribution which doesn't"
216 echo " have header files describing newer kernel features."
217 echo " Trinity will still compile and run, it just won't use those new features."
218 echo " Go ahead, and run 'make'"
221 exit 0