-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·60 lines (50 loc) · 1.25 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
#!/bin/sh
: "${CC:=cc}"
ARGS="${CFLAGS} ${LDFLAGS} -x c -o /dev/null -"
printf "" > config.mk
$CC $ARGS <<EOF 2>/dev/null
#define _GNU_SOURCE /* program_invocation_short_name */
#include <errno.h>
int main() {
const char *p = program_invocation_short_name;
}
EOF
[ $? -eq 0 ] && HAVE_PROG_INVOCATION=yes
$CC $ARGS <<EOF 2>/dev/null
#include <stdlib.h>
int main() {
const char (*p)(void) = getprogname;
}
EOF
[ $? -eq 0 ] && HAVE_GETPROGNAME=yes
echo "HAVE_PROG_INVOCATION:$HAVE_PROG_INVOCATION"
echo "HAVE_GETPROGNAME:$HAVE_GETPROGNAME"
if [ "$HAVE_GETPROGNAME" ]; then
echo "DEFS += -DHAVE_GETPROGNAME" >> config.mk
elif [ "$HAVE_PROG_INVOCATION" ]; then
echo "DEFS += -DHAVE_PROG_INVOCATION" >> config.mk
fi
$CC $ARGS <<EOF 2>/dev/null
#include <sys/types.h>
#include <sys/socket.h>
int main() {
int flag = SOCK_CLOEXEC;
}
EOF
[ $? -eq 0 ] && HAVE_SOCK_CLOEXEC=yes
echo "HAVE_SOCK_CLOEXEC:$HAVE_SOCK_CLOEXEC"
if [ "$HAVE_SOCK_CLOEXEC" ]; then
echo "DEFS += -DHAVE_SOCK_CLOEXEC_H" >> config.mk
fi
$CC $ARGS <<EOF 2>/dev/null
#define _GNU_SOURCE /* pipe2 */
#include <unistd.h>
int main() {
int (*p)(int [2], int) = pipe2;
}
EOF
[ $? -eq 0 ] && HAVE_PIPE2=yes
echo "HAVE_PIPE2:$HAVE_PIPE2"
if [ "$HAVE_PIPE2" ]; then
echo "DEFS += -DHAVE_PIPE2" >> config.mk
fi