X-Git-Url: https://deadsoftware.ru/gitweb?p=cpc.git;a=blobdiff_plain;f=make-all.sh;h=696571af89f7c3560845482592976bd84d2dac7e;hp=a8c5b943ebfa4bf8f226702a590f03749775a843;hb=e6f2dc69e5d8af2c60cf85c43fced7c370a9e427;hpb=76d1e8d98f1d80d24fa52a15e6b2c6fb0a5f44d0 diff --git a/make-all.sh b/make-all.sh index a8c5b94..696571a 100755 --- a/make-all.sh +++ b/make-all.sh @@ -13,12 +13,13 @@ _linker= _cross=false _bootstrap=false -_verify=true +_stages=2 _cpu= _target= _system= _host_cpu= +_host_target= _host_system= ###^^^^^^^^^^^### @@ -31,17 +32,22 @@ usage() { echo " -c path Path to compiler binary" echo " -l path Path to linker binary" echo " -b Bootstrap compiler (result in bootstrap/-cpfront-/)" - 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+" + echo " arm ARM 32-bit" echo "Targets:" echo " native Native" echo " cpfront Generic C" echo "Operation systems:" echo " linux GNU/Linux" + echo "Environment variables:" + echo " CC C compiler binary" + echo " CFLAGS C compiler options" exit 2 } @@ -70,24 +76,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 +122,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 +143,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