]> begriffs open source - libnonstd/blob - configure
Avoid the peril of signed integer promotion
[libnonstd] / configure
1 #!/bin/sh
2 set -eu
3
4 echo > config.mk
5
6 compiles ()
7 {
8         stage="$(mktemp -d)"
9         echo "$2" > "$stage/test.c"
10         (cc -Werror "$1" -o "$stage/test" "$stage/test.c" >/dev/null 2>&1)
11         cc_success=$?
12         rm -rf "$stage"
13         return $cc_success
14 }
15
16 if compiles "-D_POSIX_C_SOURCE=200112L" "
17         #include <sys/types.h>
18         int main(void)
19         {
20                 return (ssize_t)0;
21         }"
22 then
23         echo "CFLAGS += -DHAVE_SSIZE_T" >> config.mk
24 fi