purr-c/configure

61 lines
1.2 KiB
Bash
Executable File

#!/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