#!/bin/sh : "${CC:=cc}" ARGS="${CFLAGS} ${LDFLAGS} -x c -o /dev/null -" printf "" > config.mk $CC $ARGS </dev/null #define _GNU_SOURCE /* program_invocation_short_name */ #include int main() { const char *p = program_invocation_short_name; } EOF [ $? -eq 0 ] && HAVE_PROG_INVOCATION=yes $CC $ARGS </dev/null #include 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 </dev/null #include #include 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 </dev/null #define _GNU_SOURCE /* pipe2 */ #include 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