5 ###^^^^^^^^^^^^^^^^^^###
6 ### Global variables ###
7 ###__________________###
9 _this
="$(dirname "$(readlink -f "$0")")"
30 echo "Usage
: make-all.sh
[options
] cpu target os
"
32 echo " -c path Path to compiler binary
"
33 echo " -l path Path to linker binary
"
34 echo " -b Bootstrap compiler
(result
in bootstrap
/<cpu
>-cpfront-<os
>/)"
35 echo " -g num Set max verify stages
(0.
.2)"
36 # echo " -e Cross compile
(result
in stage
-cross)"
37 # echo " -u cpu Host cpu
"
38 # echo " -t target Host compiler
"
39 # echo " -s os Host operaion system
"
41 echo " 486 Intel
486+"
42 echo " arm ARM
32-bit"
45 echo " cpfront Generic C
"
46 echo "Operation systems
:"
47 echo " linux GNU
/Linux
"
48 echo "Environment variables
:"
49 echo " CC C compiler binary
"
50 echo " CFLAGS C compiler options
"
62 local _this_target="$3"
63 local _this_system="$4"
65 "$_this/make.sh
" -o "$_dir" -c "$_compiler" -l "$_linker" "$@
" "$_this_cpu" "$_this_target" "$_this_system"
66 if [ "$_target" = "cpfront
" ]; then
67 _compiler="$_dir/cpfront
"
70 if [ "$_cpu" = "486" ]; then
71 _compiler="$_dir/cpc486
"
72 _linker="$_dir/cpl486
"
74 error "unsupported cpu
$_cpu"
83 make_stage "$_this/stage
$_N" "$@
" "$_host_cpu" "$_host_target" "$_host_system"
85 make_stage "$_this/stage
$_N" "$@
" "$_cpu" "$_target" "$_system"
89 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
90 ### Parse arguments and options ###
91 ###_____________________________###
93 while getopts c:l:u:t:s:g:beh _name
96 c) _compiler="$OPTARG" ;;
97 l) _linker="$OPTARG" ;;
98 u) _host_cpu="$OPTARG" ;;
99 t) _host_target="$OPTARG" ;;
100 s) _host_system="$OPTARG" ;;
101 g) _stages="$OPTARG" ;;
102 b) _bootstrap=true ;;
108 if [ "$_stages" -lt "0" -o "$_stages" -gt "2" ]; then
112 if [ "$(expr $# - $OPTIND + 1)" != "3" ]; then
116 shift $(($OPTIND - 1))
121 if [ -z "$_host_cpu" ]; then
125 if [ -z "$_host_target" ]; then
126 _host_target="$_target"
129 if [ -z "$_host_system" ]; then
130 _host_system="$_system"
133 ###^^^^^^^^^^^^^^^^^^^^###
134 ### Bootstrap compiler ###
135 ###____________________###
142 make_stage "$_this/bootstrap
/$_host_cpu-cpfront-$_host_system" "$_host_cpu" "cpfront
" "$_host_system" -b
144 make_stage "$_this/bootstrap
/$_host_cpu-cpfront-$_host_system" "$_cpu" "cpfront
" "$_system" -b
151 ###^^^^^^^^^^^^^^^^^^###
152 ### Recompile itself ###
153 ###__________________###
155 for _N in $(seq 1 "$_stages")
158 make_verify_stage "$_N"
162 ###^^^^^^^^^^^^^^^###
163 ### Cross compile ###
164 ###_______________###
167 echo "==> Cross compile
"
168 make_stage "$_this/stage
-cross/$_cpu-$_target-$_system" "$_cpu" "$_target" "$_system"