Index: build.sh ================================================================== --- build.sh +++ build.sh @@ -116,12 +116,15 @@ if test -e "$output"; then if test ! "$output" -ot "$src"; then return fi fi - $m4 $macro_compile_env -I "$gen" $flags "$src" > "$output" - announce $m4 $macro_compile_env -I "$gen" $flags "$src" \> "$output" + if test "$debug" = yes; then + local dflag=-Dcompile_debug=yes + fi + $m4 $macro_compile_env $dflag -I "$gen" $flags "$src" > "$output" + announce $m4 $macro_compile_env $dflag -I "$gen" $flags "$src" \> "$output" # yes, this is incredibly stupid. if you know a better way, feel # free to submit a fix. the problem is there's no way to pass > # to report in such a way that it'll do the right thing, and if # you just write > it redirects *report's* output, instead of # m4's. piece of shit that it is, m4 doesn't have any way to emit @@ -134,11 +137,14 @@ if test -e "$output"; then if test ! "$output" -ot "$src"; then return fi fi - report $asm $flags "-f$bin_fmt" -i "$gen" "$src" -o "$output"; + if test "$debug" = yes; then + local dflag="-g dwarf2" + fi + report $asm $flags $dflag "-f$bin_fmt" -i "$gen" "$src" -o "$output"; } comp_co() { comp_c $1 $2 "-c -fPIC"; } comp_c(){ local src=$1 local output=$2 @@ -147,11 +153,16 @@ if test ! "$output" -ot "$src"; then return fi fi # only rebuild the file if the source file is newer - report $cc $src $3 -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/" -nostdlib "-L$to" "-o$output" + if test "$debug" = yes; then + local dflag="-g" + else + local dflag="-O4" + fi + report $cc $src $3 $dflag -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/" -ffreestanding -nostdlib "-L$to" "-o$output" } say "commencing libk build $build at $(timestamp)" # set -x