6 [[ "$1" == /* ]] && echo "$1" ||
echo "$(pwd)/$1"
9 ###^^^^^^^^^^^^^^^^^^###
10 ### Global variables ###
11 ###__________________###
13 _this
="$(dirname "$
(abspath
"$0")")"
29 export CPCFLAGS
="$CPCFLAGS"
30 export CPLFLAGS
="$CPLFLAGS"
37 echo "Usage: make-all.sh [options] cpu target os"
39 echo " -c path Path to compiler binary"
40 echo " -l path Path to linker binary"
41 echo " -b Bootstrap compiler (result in bootstrap/<cpu>-cpfront-<os>/)"
42 echo " -g num Set max verify stages (0..2)"
43 # echo " -e Cross compile (result in stage-cross)"
44 # echo " -u cpu Host cpu"
45 # echo " -t target Host compiler"
46 # echo " -s os Host operaion system"
48 echo " 486 Intel 486+"
49 echo " arm ARM 32-bit"
50 echo " powerpc PowerPC 32-bit"
53 echo " cpfront Generic C"
54 echo "Operation systems:"
55 echo " linux GNU/Linux"
58 echo "Environment variables:"
59 echo " CC C compiler binary"
60 echo " CFLAGS C compiler options"
61 echo " CPCFLAGS CPC compiler options"
62 echo " CPLFLAGS CPL linker options"
74 local _this_target
="$3"
75 local _this_system
="$4"
77 "$_this/make.sh" -o "$_dir" -c "$_compiler" -l "$_linker" "$@" "$_this_cpu" "$_this_target" "$_this_system"
79 if [ "$_host_system" = "cygwin" ]; then
81 elif [ "$_host_system" = "osx" ]; then
84 if [ "$_target" = "cpfront" ]; then
85 _compiler
="$_dir/cpfront${_ext}"
88 if [ "$_cpu" = "486" ]; then
89 _compiler
="$_dir/cpc486${_ext}"
90 _linker
="$_dir/cpl486${_ext}"
92 error
"unsupported cpu $_cpu"
101 make_stage
"$_this/stage$_N" "$@" "$_host_cpu" "$_host_target" "$_host_system"
103 make_stage
"$_this/stage$_N" "$@" "$_cpu" "$_target" "$_system"
107 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
108 ### Parse arguments and options ###
109 ###_____________________________###
111 while getopts c
:l
:u
:t
:s
:g
:beh _name
114 c
) _compiler
="$OPTARG" ;;
115 l
) _linker
="$OPTARG" ;;
116 u
) _host_cpu
="$OPTARG" ;;
117 t
) _host_target
="$OPTARG" ;;
118 s
) _host_system
="$OPTARG" ;;
119 g
) _stages
="$OPTARG" ;;
120 b
) _bootstrap
=true
;;
126 if [ "$_stages" -lt "0" -o "$_stages" -gt "2" ]; then
130 if [ "$(expr $# - $OPTIND + 1)" != "3" ]; then
134 shift $
(($OPTIND - 1))
139 if [ -z "$_host_cpu" ]; then
143 if [ -z "$_host_target" ]; then
144 _host_target
="$_target"
147 if [ -z "$_host_system" ]; then
148 _host_system
="$_system"
151 ###^^^^^^^^^^^^^^^^^^^^###
152 ### Bootstrap compiler ###
153 ###____________________###
160 make_stage
"$_this/bootstrap/$_host_cpu-cpfront-$_host_system" "$_host_cpu" "cpfront" "$_host_system" -b
162 make_stage
"$_this/bootstrap/$_host_cpu-cpfront-$_host_system" "$_cpu" "cpfront" "$_system" -b
169 ###^^^^^^^^^^^^^^^^^^###
170 ### Recompile itself ###
171 ###__________________###
173 if [ "1" -le "$_stages" ]; then
178 if [ "2" -le "$_stages" ]; then
183 ###^^^^^^^^^^^^^^^###
184 ### Cross compile ###
185 ###_______________###
188 echo "==> Cross compile"
189 make_stage
"$_this/stage-cross/$_cpu-$_target-$_system" "$_cpu" "$_target" "$_system"