-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure
executable file
·58 lines (51 loc) · 1.14 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
#!/bin/sh -eu
rm -f config.mk
pkg-config --print-errors 'libcmark >= 0.20'
cat >> config.mk <<-EOF
CFLAGS += $(pkg-config --cflags libcmark)
LDFLAGS += $(pkg-config --libs-only-L libcmark)
LDLIBS += $(pkg-config --libs-only-l libcmark)
EOF
compiles ()
{
stage="$(mktemp -d)"
echo "$2" > "$stage/test.c"
(cc -Werror "$1" -o "$stage/test" "$stage/test.c" >/dev/null 2>&1)
cc_success=$?
rm -rf "$stage"
return $cc_success
}
if compiles "" "
#include <stdint.h>
#include <stdlib.h>
int main(void)
{
void (*p)(void *, size_t) = arc4random_buf;
return (intptr_t)p;
}"
then
echo "CFLAGS += -DHAVE_ARC4RANDOM" >> config.mk
fi
if compiles "-D_POSIX_C_SOURCE=200112L" "
#include <stdint.h>
#include <sys/types.h>
#include <sys/random.h>
int main(void)
{
ssize_t (*p)(void *, size_t, unsigned int) = getrandom;
return (intptr_t)p;
}"
then
echo "CFLAGS += -DHAVE_GETRANDOM" >> config.mk
elif compiles "-D_GNU_SOURCE" "
#include <unistd.h>
#include <sys/syscall.h>
int main(void)
{
long n = SYS_getrandom;
long (*p)(long, ...) = syscall;
return (intptr_t)p & n;
}"
then
echo "CFLAGS += -DHAVE_GETRANDOM_SYSCALL" >> config.mk
fi