libk  Diff

Differences From Artifact [b2a27b403b]:

To Artifact [3df2029917]:


   114    114   	local output=$2
   115    115   	local flags=$3
   116    116   	if test -e "$output"; then
   117    117   		if test ! "$output" -ot "$src"; then
   118    118   			return
   119    119   		fi 
   120    120   	fi
   121         -	          $m4 $macro_compile_env -I "$gen" $flags "$src"  > "$output"
   122         -	announce  $m4 $macro_compile_env -I "$gen" $flags "$src" \> "$output"
          121  +	if test "$debug" = yes; then
          122  +		local dflag=-Dcompile_debug=yes
          123  +	fi
          124  +	         $m4 $macro_compile_env $dflag -I "$gen" $flags "$src"  > "$output"
          125  +	announce $m4 $macro_compile_env $dflag -I "$gen" $flags "$src" \> "$output"
   123    126   	# yes, this is incredibly stupid. if you know a better way, feel
   124    127   	# free to submit a fix. the problem is there's no way to pass >
   125    128   	# to report in such a way that it'll do the right thing, and if
   126    129   	# you just write > it redirects *report's* output, instead of
   127    130   	# m4's. piece of shit that it is, m4 doesn't have any way to emit
   128    131   	# output into a fille - stdout only apparently. tl;dr i hate bash.
   129    132   }
................................................................................
   132    135   	local output=$2
   133    136   	local flags=$3
   134    137   	if test -e "$output"; then
   135    138   		if test ! "$output" -ot "$src"; then
   136    139   			return
   137    140   		fi
   138    141   	fi
   139         -	report $asm $flags "-f$bin_fmt" -i "$gen" "$src" -o "$output";
          142  +	if test "$debug" = yes; then
          143  +		local dflag="-g dwarf2"
          144  +	fi
          145  +	report $asm $flags $dflag "-f$bin_fmt" -i "$gen" "$src" -o "$output";
   140    146   }
   141    147   comp_co()  { comp_c $1 $2 "-c -fPIC"; }
   142    148   comp_c(){
   143    149   	local src=$1
   144    150   	local output=$2
   145    151   	local flags=$3
   146    152   	if test -e "$output"; then
   147    153   		if test ! "$output" -ot "$src"; then
   148    154   			return
   149    155   		fi
   150    156   	fi
   151    157   	# only rebuild the file if the source file is newer
   152         -	report $cc $src $3 -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/" -nostdlib "-L$to" "-o$output"
          158  +	if test "$debug" = yes; then
          159  +		local dflag="-g"
          160  +	else
          161  +		local dflag="-O4"
          162  +	fi
          163  +	report $cc $src $3 $dflag -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/" -ffreestanding -nostdlib "-L$to" "-o$output"
   153    164   }
   154    165   
   155    166   say "commencing libk build $build at $(timestamp)"
   156    167   # set -x
   157    168   
   158    169   # get type data
   159    170   mkdir -p $gen