DEADSOFTWARE

added arm support via cpfront
[cpc.git] / make.sh
diff --git a/make.sh b/make.sh
index d466d2773aa85ecb1d7c2f6331ab7cbb6c455f21..9aa6e5247ff581ff08502098c5b2a29e5603532a 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -33,11 +33,15 @@ usage() {
   echo "    -x                Do not link"
   echo "Processors:"
   echo "    486               Intel 486+"
   echo "    -x                Do not link"
   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 "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
 }
 
   exit 2
 }
 
@@ -100,13 +104,18 @@ cpfront_link() {
     do
       _list="$_list ${_out}/CodeC/${_module}.c"
     done
     do
       _list="$_list ${_out}/CodeC/${_module}.c"
     done
-    ### !!! ADD $CC $CFLAGS $LDFLAGS ###
-    gcc -m32 -g -O0 -lm -ldl -o "$_out/$_main" \
-      -Wno-int-conversion \
-      -Wno-int-to-pointer-cast \
-      -Wno-incompatible-pointer-types \
-      -Wno-implicit-function-declaration \
-      -I "$_this/C" "$_this/C/SYSTEM.c" $_list
+    local _cc_cflags=
+    case "$CC" in
+      *gcc)  _cc_cflags="-Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-implicit-function-declaration" ;;
+      *)  _cc_cflags="" ;;
+    esac
+    local _cpu_cflags=
+    case "$_cpu" in
+      486)  _cpu_cflags="-m32" ;;
+      arm)  _cpu_cflags="" ;;
+      *)  error "cpfront_link(): unsupported cpu $_cpu" ;;
+    esac
+    "$CC" $_cc_cflags $_cpu_cflags -lm -ldl $CFLAGS -o "${_main}" -I "$_this/C" "$_this/C/SYSTEM.c" $_list
   fi
 }
 
   fi
 }
 
@@ -263,12 +272,17 @@ _cpu="$1"
 _target="$2"
 _system="$3"
 
 _target="$2"
 _system="$3"
 
+if [ -z "$CC" ]; then
+  export CC=cc
+fi
+
 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
 ### Check for supported cpu/target/os ###
 ###___________________________________###
 
 case "$_cpu" in
   386|486|586|686)  _cpu=486 ;;
 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
 ### Check for supported cpu/target/os ###
 ###___________________________________###
 
 case "$_cpu" in
   386|486|586|686)  _cpu=486 ;;
+  arm|armv6|armv7)  _cpu=arm ;;
   "")  error "cpu not specified" ;;
   *)  error "unsupported cpu $_cpu" ;;
 esac
   "")  error "cpu not specified" ;;
   *)  error "unsupported cpu $_cpu" ;;
 esac
@@ -336,7 +350,9 @@ fi
 ### Copy sources for changed system ###
 ###_________________________________###
 
 ### Copy sources for changed system ###
 ###_________________________________###
 
-$_docompile && rm -rf -- "$_out"
+if $_docompile; then
+  rm -rf -- "$_out"
+fi
 
 mkdir -p -- "$_out"
 _out="$(readlink -f "$_out")"
 
 mkdir -p -- "$_out"
 _out="$(readlink -f "$_out")"