new configure flags and options

This commit is contained in:
2025-09-06 14:02:42 -04:00
parent a3fecebfb7
commit 15e05d8db3

9
configure vendored
View File

@@ -12,6 +12,7 @@ VAR=VALUE.
LDFLAGS C linker flags LDFLAGS C linker flags
--prefix=<path> Set the install path --prefix=<path> Set the install path
--debug Flags for debug build
EOF EOF
exit 0 exit 0
@@ -22,7 +23,7 @@ cmdexists () { type "$1" >/dev/null 2>&1 ; }
trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; } trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; }
prefix=/usr/bin/ prefix=/usr/bin/
CFLAGS="-Wall -Wextra -O2 --std=c23 -Wpedantic -Wformat=2" CFLAGS="-std=c23 -O2 -pipe -Wall -Wextra -Wpedantic -Wformat=2 -Wshadow -Wcast-qual -Wcast-align=strict -Wconversion -Wsign-conversion -Wnull-dereference -Wstrict-overflow=5 -Wstrict-aliasing=2 -Wswitch-enum -Wundef -fstack-protector-strong -D_FORTIFY_SOURCE=3 -fPIE -pie -fno-plt -Wl,-z,relro,-z,now" # release flags
LDFLAGS= LDFLAGS=
CC= CC=
@@ -32,10 +33,12 @@ trycc cc
trycc clang trycc clang
printf "%s\n" "$CC" printf "%s\n" "$CC"
DEBUG=false
for arg ; do for arg ; do
case "$arg" in case "$arg" in
--help|h) usage ;; --help|h) usage ;;
--prefix=*) prefix=${arg#*=} ;; --prefix=*) prefix=${arg#*=} ;;
--debug=*) DEBUG=true ;;
CFLAGS=*) CFLAGS=${arg#*=} ;; CFLAGS=*) CFLAGS=${arg#*=} ;;
LDFLAGS=*) LDFLAGS=${arg#*=} ;; LDFLAGS=*) LDFLAGS=${arg#*=} ;;
CC=*) CC=${arg#*=} ;; CC=*) CC=${arg#*=} ;;
@@ -54,6 +57,10 @@ printf "no; %s\n" "$output"
exit 1 exit 1
fi fi
if [ -z "$DEBUG" ]; then
CFLAGS="-std=c23 -O0 -g3 -Wall -Wextra -Wpedantic -Werror -Wshadow -Wdouble-promotion -Wformat=2 -Wnull-dereference -Wconversion -Wsign-conversion -Wcast-qual -Wcast-align=strict -Wpointer-arith -Wstrict-overflow=5 -Wstrict-aliasing=2 -Wundef -Wunreachable-code -Wswitch-enum -fanalyzer -fsanitize=undefined,address -fstack-protector-strong -D_FORTIFY_SOURCE=3"
fi
printf "creating config.mak... " printf "creating config.mak... "
printf "PREFIX=%s\n" "$prefix" > config.mak printf "PREFIX=%s\n" "$prefix" > config.mak
printf "CFLAGS=%s\n" "$CFLAGS" >> config.mak printf "CFLAGS=%s\n" "$CFLAGS" >> config.mak