From 6e71909c6e0c6fa18c3cd0754c551f122b323d7c Mon Sep 17 00:00:00 2001 From: Jeremy Baxter Date: Fri, 29 Sep 2023 10:08:47 +1300 Subject: [PATCH] Improve configure script --- configure | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 8d03e11..ae27905 100755 --- a/configure +++ b/configure @@ -66,13 +66,13 @@ gen_DC () { fi if present ldc2; then dc=ldc2 - using ldc2 elif present dmd; then dc=dmd - using dmd else error "D compiler not found; install ldc or dmd" fi + + using "$dc" } ## flags used in the compilation step @@ -82,24 +82,17 @@ gen_CFLAGS () { ldc2) cflags="-Oz";; dmd) cflags="-O";; esac - using "$cflags" else - fdebugsymbols="-g" - using "$fdebugsymbols" + cflags="-g" case "$dc" in - ldc2) - fdebug="-d-debug" - using "$fdebug" - foptimisation="-O0" - using "$foptimisation" - ;; - dmd) fdebug="-debug";; + ldc2) cflags="$cflags -O0 -d-debug";; + dmd) cflags="$cflags -debug";; esac - cflags="$fdebugsymbols $fdebug" - unset fdebug - unset fdebugsymbols - unset foptimisation fi + + for flag in $cflags; do + using "$flag" + done } ## flags used in the linking step @@ -107,12 +100,18 @@ gen_LDFLAGS () { if [ "$dc" = ldc2 ]; then if present ld.lld; then ldflags="-linker=lld" - using "$ldflags" elif present ld.gold; then ldflags="-linker=gold" - using "$ldflags" fi fi + if [ -z "$debug" ]; then + if ! [ -z "$ldflags" ]; then ldflags="$ldflags "; fi + ldflags="$ldflags-L--gc-sections" + fi + + for flag in $ldflags; do + using "$flag" + done } # command line interface