diff options
Diffstat (limited to 'configure.sh')
| -rwxr-xr-x | configure.sh | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/configure.sh b/configure.sh index b9779c2..e4a142d 100755 --- a/configure.sh +++ b/configure.sh | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | detect() { cc -march=native -dM -E - < /dev/null | grep "$1"; } | 3 | detectarch() { cc -march=native -dM -E - </dev/null | grep "$1"; } |
| 4 | detectsan() { cc -fsanitize=$1 -dM -E -x c - </dev/null | grep "SANITIZE"; } | ||
| 4 | 5 | ||
| 5 | [ -n "$(detect __AVX2__)" ] && detected="AVX2" | 6 | [ -n "$(detectarch __AVX2__)" ] && detected="AVX2" |
| 6 | 7 | ||
| 7 | TYPE=${TYPE-"$detected"} | 8 | TYPE=${TYPE-"$detected"} |
| 8 | 9 | ||
| @@ -11,7 +12,10 @@ echo "Using CUBE_$TYPE" | |||
| 11 | STD="-std=c99" | 12 | STD="-std=c99" |
| 12 | WFLAGS="-pedantic -Wall -Wextra -Wno-unused-parameter -Wno-unused-function" | 13 | WFLAGS="-pedantic -Wall -Wextra -Wno-unused-parameter -Wno-unused-function" |
| 13 | [ "$TYPE" = "AVX2" ] && AVX="-mavx2" | 14 | [ "$TYPE" = "AVX2" ] && AVX="-mavx2" |
| 14 | [ "$(uname)" = "Linux" ] && SAN="-fsanitize=address -fsanitize=undefined" | 15 | |
| 16 | [ -n "$(detectsan address)" ] && ADDR="-fsanitize=address" | ||
| 17 | [ -n "$(detectsan undefined)" ] && UNDEF="-fsanitize=undefined" | ||
| 18 | SAN="$ADDR $UNDEF" | ||
| 15 | 19 | ||
| 16 | CFLAGS="$STD $WFLAGS $AVX -O3" | 20 | CFLAGS="$STD $WFLAGS $AVX -O3" |
| 17 | DBGFLAGS="$STD $WFLAGS $AVX -g3 -DDEBUG" | 21 | DBGFLAGS="$STD $WFLAGS $AVX -g3 -DDEBUG" |
