-
Notifications
You must be signed in to change notification settings - Fork 241
/
configure
executable file
·407 lines (338 loc) · 9.63 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
#!/bin/bash
CONFIGH="config.h"
if [ -t 1 ]; then
RED="[1;31m"
GREEN="[1;32m"
COL_RESET="[0;m"
fi
MISSING_DEFS=0
[ -z "$CC" ] && CC=gcc
# expand tilde
CC="$(eval echo ${CROSS_COMPILE}${CC})"
CFLAGS="${CFLAGS}"
if [ "${SYSROOT}xx" != "xx" ]; then
CFLAGS="${CFLAGS} $(eval echo --sysroot=${SYSROOT} )"
fi
echo "#pragma once" > $CONFIGH
echo "/* This file is auto-generated by configure.sh */" >> $CONFIGH
TMP=$(mktemp)
check_header()
{
echo -n "[*] Checking header $1 ... "
rm -f "$TMP" || exit 1
echo "#include <$1>" >"$TMP.c"
${CC} ${CFLAGS} "$TMP.c" -E &>"$TMP.log"
if [ $? -eq 0 ]; then
echo $GREEN "[YES]" $COL_RESET
echo "#define $2 1" >> $CONFIGH
else
echo $RED "[NO]" $COL_RESET
MISSING_DEFS=1
fi
}
#############################################################################################
echo "[*] Checking system headers."
#############################################################################################
# Are ipv6 headers usable ?
[ -z "$IPV6" ] && IPV6=yes
if [[ "$IPV6" == "yes" ]]; then
echo -n "[*] Checking ipv6 headers ... "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#include <netinet/in.h>
#include <netinet/ip6.h>
#include <linux/in6.h>
#include <linux/ipv6.h>
int main()
{
struct in6_addr test;
}
EOF
${CC} ${CFLAGS} -D_GNU_SOURCE "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[BROKEN]" $COL_RESET "See https://patchwork.ozlabs.org/patch/425881/"
else
echo $GREEN "[OK]" $COL_RESET
echo "#define USE_IPV6 1" >> $CONFIGH
fi
fi
#############################################################################################
# is /usr/include/linux/if_pppox.h new enough to feature pppol2tpin6/pppol2tpv3in6
#
echo -n "[*] Checking if pppox can use pppol2tpin6.. "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#include <stdio.h>
#include <netinet/in.h>
#include <linux/if.h>
#include <linux/if_pppox.h>
void main()
{
struct sockaddr_pppol2tpin6 *pppox;
printf("%d\n", pppox->sa_family);
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
MISSING_DEFS=1
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_PPPOL2TPIN6 1" >> $CONFIGH
fi
#############################################################################################
# is /usr/include/linux/if_pppox.h new enough to feature pppol2tpv3
#
echo -n "[*] Checking if pppox can use pppol2tv3.. "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#include <stdio.h>
#include <netinet/in.h>
#include <linux/if.h>
#include <linux/if_pppox.h>
void main()
{
struct sockaddr_pppol2tpv3 *pppox;
printf("%d\n", pppox->sa_family);
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
MISSING_DEFS=1
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_PPPOL2TPV3 1" >> $CONFIGH
fi
#############################################################################################
# is /usr/include/linux/if_pppox.h new enough to feature pptp
#
echo -n "[*] Checking if pppox can use pptp.. "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#include <stdio.h>
#include <netinet/in.h>
#include <linux/if.h>
#include <linux/if_pppox.h>
void main()
{
struct sockaddr_pppox *pppox;
printf("%d\n", pppox->sa_addr.pptp.call_id);
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
MISSING_DEFS=1
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_PPPOX_PPTP 1" >> $CONFIGH
fi
#############################################################################################
# is /usr/include/linux/llc.h new enough to feature LLC_OPT_PKTINFO
#
echo -n "[*] Checking if llc can use LLC_OPT_PKTINFO.. "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#include <stdio.h>
#include <net/if.h>
#include <linux/llc.h>
void main()
{
printf("%d\n", LLC_OPT_PKTINFO);
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
MISSING_DEFS=1
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_LLC_OPT_PKTINFO 1" >> $CONFIGH
fi
#############################################################################################
# Do glibc headers provides struct termios2
echo -n "[*] Checking if glibc headers provide termios2.. "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#include <sys/ioctl.h>
#include <sys/vt.h>
#include <termios.h>
int main()
{
struct termios2 test;
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
MISSING_DEFS=1
else
echo $GREEN "[YES]" $COL_RESET
echo "#define HAVE_TERMIOS2 1" >> $CONFIGH
fi
#############################################################################################
# Do glibc headers provides nvme ioctls
echo -n "[*] Checking if glibc headers provide nvme ioctls.. "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#include <sys/ioctl.h>
#include <linux/nvme_ioctl.h>
int main(int argc, char* argv[])
{
unsigned int foo = NVME_IOCTL_IO_CMD;
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
MISSING_DEFS=1
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_NVME 1" >> $CONFIGH
fi
#############################################################################################
# is /usr/include/linux/bpf.h new enough to feature bpf
#
echo -n "[*] Checking if bpf_attr can use map_flags.. "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#include <stdio.h>
#include <linux/bpf.h>
void main()
{
union bpf_attr attr = {
.map_flags = 0,
};
enum bpf_prog_type type = BPF_PROG_TYPE_PERF_EVENT;
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
MISSING_DEFS=1
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_BPF 1" >> $CONFIGH
fi
#############################################################################################
# is /usr/include/linux/btrfs.h new enough to feature btrfs
#
echo -n "[*] Checking if btrfs can use btrfs_ioctl_defrag_range_args.. "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#include <stdio.h>
#include <linux/btrfs.h>
void main()
{
struct btrfs_ioctl_defrag_range_args args;
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
MISSING_DEFS=1
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_BTRFS 1" >> $CONFIGH
fi
#############################################################################################
# Does glibc provide memfd_create() syscall wrapper
#
echo -n "[*] Checking if glibc provides memfd_create.. "
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#define _GNU_SOURCE
#include <sys/mman.h>
void main()
{
memfd_create("", 0);
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_MEMFD_CREATE 1" >> $CONFIGH
fi
#############################################################################################
# Does header define struct drm_nouveau_notifierobj_alloc
#
echo -n "[*] Checking if struct drm_nouveau_notifierobj_alloc is defined"
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#define _GNU_SOURCE
#include <drm/nouveau_drm.h>
#include <stdio.h>
void main()
{
struct drm_nouveau_notifierobj_alloc dnna = {0,0,0,0};
dnna.size = 64;
printf("size=%d\n", dnna.size);
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_DEFAULT_STRUCT_DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 1" >> $CONFIGH
fi
#############################################################################################
# Does header define struct drm_nouveau_notifierobj_alloc
#
echo -n "[*] Checking if struct drm_nouveau_gpuobj_free is defined"
rm -f "$TMP" || exit 1
cat >"$TMP.c" << EOF
#define _GNU_SOURCE
#include <drm/nouveau_drm.h>
#include <stdio.h>
void main()
{
struct drm_nouveau_gpuobj_free dngf = {0,0};
dngf.channel = 64;
printf("channel=%d\n", dngf.channel);
}
EOF
${CC} ${CFLAGS} "$TMP.c" -o "$TMP" &>"$TMP.log"
if [ ! -x "$TMP" ]; then
echo $RED "[NO]" $COL_RESET
else
echo $GREEN "[YES]" $COL_RESET
echo "#define USE_DEFAULT_STRUCT_DRM_NOUVEAU_GPUOBJ_FREE 1" >> $CONFIGH
fi
#############################################################################################
check_header linux/caif/caif_socket.h USE_CAIF
check_header linux/fsmap.h USE_FSMAP
check_header linux/if_alg.h USE_IF_ALG
check_header linux/irda.h USE_IRDA
check_header linux/rds.h USE_RDS
check_header linux/vfio.h USE_VFIO
check_header drm/drm.h USE_DRM
check_header drm/i810_drm.h USE_DRM_I810
check_header drm/mga_drm.h USE_DRM_MGA
check_header drm/r128_drm.h USE_DRM_R128
check_header drm/savage_drm.h USE_DRM_SAVAGE
check_header drm/exynos_drm.h USE_DRM_EXYNOS
check_header sound/compress_offload.h USE_SNDDRV_COMPRESS_OFFLOAD
check_header linux/kvm.h USE_KVM
check_header linux/seccomp.h USE_SECCOMP
check_header linux/vhost.h USE_VHOST
check_header execinfo.h USE_BACKTRACE
check_header netatalk/at.h USE_APPLETALK
check_header netrom/netrom.h USE_NETROM
check_header netrose/rose.h USE_ROSE
check_header neteconet/ec.h USE_NETECONET
check_header netax25/ax25.h USE_NETAX25
check_header netipx/ipx.h USE_IPX
rm -f "$TMP" "$TMP.log" "$TMP.c"
#############################################################################################
if [ "$MISSING_DEFS" == "1" ]; then
echo "[-] Some header definitions were missing. This is not fatal."
echo " It usually means you're building on an older distribution which doesn't"
echo " have header files describing newer kernel features."
echo " Trinity will still compile and run, it just won't use those new features."
echo " Go ahead, and run 'make'"
fi
exit 0