Set _X_OPEN_SOURCE and default compiler in build script

This commit is contained in:
Lassi Kortela 2019-08-10 01:43:47 +03:00
parent 86ebfb7a12
commit 2950e6ae5b
4 changed files with 37 additions and 12 deletions

View File

@ -2,8 +2,6 @@
string functions
*/
#define _XOPEN_SOURCE
#include <sys/types.h>
#include <sys/time.h>

View File

@ -1,5 +1,3 @@
#define _XOPEN_SOURCE
#include <sys/poll.h>
#include <sys/time.h>

View File

@ -13,8 +13,6 @@
A UTF-8 validation routine is included.
*/
#define _XOPEN_SOURCE
#include <assert.h>
#include <stdarg.h>
#include <stddef.h>

View File

@ -1,11 +1,42 @@
#!/bin/sh
set -eu
CC="${CC:-clang}"
CFLAGS="-Wall -Wextra -Wno-strict-aliasing -std=gnu99"
CFLAGS="$CFLAGS -O2" # -falign-functions
CFLAGS="$CFLAGS -I ../c -D NDEBUG -D USE_COMPUTED_GOTO"
LFLAGS="-lm"
os="$(uname | tr A-Z- a-z_)"
case "$os" in
darwin)
default_cc="clang"
;;
dragonfly)
default_cc="gcc"
;;
freebsd)
default_cc="clang"
;;
haiku)
default_cc="gcc"
;;
linux)
default_cc="gcc"
CFLAGS="$CFLAGS -D _XOPEN_SOURCE"
;;
netbsd)
default_cc="gcc"
;;
openbsd)
default_cc="clang"
;;
sunos)
default_cc="gcc"
;;
*)
echo "Unknown operating system: $os" >&2
exit 1
;;
esac
CC="${CC:-$default_cc}"
builddir="build-$os-$(uname -m | tr A-Z- a-z_)"
cd "$(dirname "$0")"/..
echo "Entering directory '$PWD'"