DEADSOFTWARE

updated make-all.sh
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Sun, 16 Jun 2019 11:47:10 +0000 (14:47 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Sun, 16 Jun 2019 11:47:10 +0000 (14:47 +0300)
make-all.sh

index a8c5b943ebfa4bf8f226702a590f03749775a843..eef57f20346373649e0464d36ec9ec1c69fe8f36 100755 (executable)
@@ -13,12 +13,13 @@ _linker=
 
 _cross=false
 _bootstrap=false
-_verify=true
+_stages=2
 
 _cpu=
 _target=
 _system=
 _host_cpu=
+_host_target=
 _host_system=
 
 ###^^^^^^^^^^^###
@@ -31,9 +32,10 @@ usage() {
   echo "    -c path           Path to compiler binary"
   echo "    -l path           Path to linker binary"
   echo "    -b                Bootstrap compiler (result in bootstrap/<cpu>-cpfront-<os>/)"
-  echo "    -v                Do not recompile itself (result in stage2/)"
+  echo "    -g num            Set max verify stages (0..2)"
 #  echo "    -e                Cross compile (result in stage-cross)"
 #  echo "    -u cpu            Host cpu"
+#  echo "    -t target         Host compiler"
 #  echo "    -s os             Host operaion system"
   echo "Processors:"
   echo "    486               Intel 486+"
@@ -70,24 +72,39 @@ make_stage() {
   fi
 }
 
+make_verify_stage() {
+  local _N="$1"
+  shift
+  if $_cross; then
+    make_stage "$_this/stage$_N" "$@" "$_host_cpu" "$_host_target" "$_host_system"
+  else
+    make_stage "$_this/stage$_N" "$@" "$_cpu" "$_target" "$_system"
+  fi
+}
+
 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
 ### Parse arguments and options ###
 ###_____________________________###
 
-while getopts c:l:u:s:bveh _name
+while getopts c:l:u:t:s:g:beh _name
 do
   case "$_name" in
     c)  _compiler="$OPTARG" ;;
     l)  _linker="$OPTARG" ;;
     u)  _host_cpu="$OPTARG" ;;
+    t)  _host_target="$OPTARG" ;;
     s)  _host_system="$OPTARG" ;;
+    g)  _stages="$OPTARG" ;;
     b)  _bootstrap=true ;;
-    v)  _verify=false ;;
     e)  _cross=true ;;
     h|?)  usage ;;
   esac
 done
 
+if [ "$_stages" -lt "0" -o "$_stages" -gt "2" ]; then
+  usage
+fi
+
 if [ "$(expr $# - $OPTIND + 1)" != "3" ]; then
   usage
 fi
@@ -101,16 +118,20 @@ if [ -z "$_host_cpu" ]; then
   _host_cpu="$_cpu"
 fi
 
+if [ -z "$_host_target" ]; then
+  _host_target="$_target"
+fi
+
 if [ -z "$_host_system" ]; then
   _host_system="$_system"
 fi
 
-###^^^^^^^^^^^^^^^^^^^^^^^^^###
-### Link bootstrap compiler ###
-###_________________________###
+###^^^^^^^^^^^^^^^^^^^^###
+### Bootstrap compiler ###
+###____________________###
 
 if $_bootstrap; then
-  echo "==> Bootstrap from C"
+  echo "==> Bootstrap"
   _compiler=
   _linker=
   if $_cross; then
@@ -118,36 +139,28 @@ if $_bootstrap; then
   else
     make_stage "$_this/bootstrap/$_host_cpu-cpfront-$_host_system" "$_cpu" "cpfront" "$_system" -b
   fi
+else
+  echo "==> Stage 0"
+  make_verify_stage 0
 fi
 
-###^^^^^^^^^^^^^^^^###
-### Compile stages ###
-###________________###
+###^^^^^^^^^^^^^^^^^^###
+### Recompile itself ###
+###__________________###
 
-if $_verify; then
-  if $_cross; then
-    echo "==> Stage 0"
-    make_stage "$_this/stage0" "$_host_cpu" "native" "$_host_system"
-    echo "==> Stage 1"
-    make_stage "$_this/stage1" "$_host_cpu" "native" "$_host_system"
-    echo "==> Stage 2"
-    make_stage "$_this/stage2" "$_host_cpu" "native" "$_host_system"
-  else
-    echo "==> Stage 0"
-    make_stage "$_this/stage0" "$_cpu" "$_target" "$_system"
-    echo "==> Stage 1"
-    make_stage "$_this/stage1" "$_cpu" "$_target" "$_system"
-    echo "==> Stage 2"
-    make_stage "$_this/stage2" "$_cpu" "$_target" "$_system"
-  fi
-fi
+for _N in $(seq 1 "$_stages")
+do
+  echo "==> Stage $_N"
+  make_verify_stage "$_N"
+done
+_N=
 
 ###^^^^^^^^^^^^^^^###
 ### Cross compile ###
 ###_______________###
 
 if $_cross; then
-  echo "==> Build for target machine"
+  echo "==> Cross compile"
   make_stage "$_this/stage-cross/$_cpu-$_target-$_system" "$_cpu" "$_target" "$_system"
 fi