index 8b98cb2290c7c370ea65a318b22d1ee17cba86f1..0cd0960b2c308f9b724d2acb7e667d4f595493cf 100755 (executable)
--- a/make.sh
+++ b/make.sh
-#! /bin/sh
+#! /bin/bash
set -e
set -e
+abspath() {
+ [[ "$1" == /* ]] && echo "$1" || echo "$(pwd)/$1"
+}
+
###^^^^^^^^^^^^^^^^^^###
### Global variables ###
###__________________###
_exec="make.sh"
###^^^^^^^^^^^^^^^^^^###
### Global variables ###
###__________________###
_exec="make.sh"
-_this="$(dirname "$(readlink -f "$0")")"
+_this="$(dirname "$(abspath "$0")")"
_cpu=
_target=
_system=
_cpu=
_target=
_system=
echo "Processors:"
echo " 486 Intel 486+"
echo " arm ARM 32-bit"
echo "Processors:"
echo " 486 Intel 486+"
echo " arm ARM 32-bit"
+ echo " powerpc PowerPC 32-bit"
echo "Targets:"
echo " native Native"
echo " cpfront Generic C"
echo "Operation systems:"
echo " linux GNU/Linux"
echo " cygwin Cygwin"
echo "Targets:"
echo " native Native"
echo " cpfront Generic C"
echo "Operation systems:"
echo " linux GNU/Linux"
echo " cygwin Cygwin"
+ echo " osx Mac OS X"
echo "Environment variables:"
echo " CC C compiler binary"
echo " CFLAGS C compiler options"
echo "Environment variables:"
echo " CC C compiler binary"
echo " CFLAGS C compiler options"
for _src
do
if test -d "$_this/src/$_src"; then
for _src
do
if test -d "$_this/src/$_src"; then
- find "$_this/src/$_src" -mindepth 1 -maxdepth 1 -exec cp -rt "$_out" -- {} +
+ find "$_this/src/$_src" -mindepth 1 -maxdepth 1 -exec cp -r {} "$_out" \;
fi
done
}
fi
done
}
if [ "$_system" = "cygwin" ]; then
_outexe="${_outexe}.exe"
_outsystem="win32"
if [ "$_system" = "cygwin" ]; then
_outexe="${_outexe}.exe"
_outsystem="win32"
+ elif [ "$_system" = "osx" ]; then
+ _outexe="${_outexe}.out"
fi
shift
"$_linker" $CPLFALGS -os "$_outsystem" -kernel Kernel -main Kernel -legacycodedir . -o "$_outexe" "$@"
fi
shift
"$_linker" $CPLFALGS -os "$_outsystem" -kernel Kernel -main Kernel -legacycodedir . -o "$_outexe" "$@"
local _cc_cflags=
case "$CC" in
*gcc) _cc_cflags="-std=c89 -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-implicit-function-declaration" ;;
local _cc_cflags=
case "$CC" in
*gcc) _cc_cflags="-std=c89 -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -Wno-implicit-function-declaration" ;;
+ *gcc-4.2) _cc_cflags="-std=c89 -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -Wno-implicit-function-declaration" ;;
clang|clang-*) _cc_cflags="-std=c89 -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses -Wno-pointer-sign -Wno-unused-value -Wno-return-type" ;;
*tcc) _cc_cflags="-std=c89 -w -fsigned-char" ;;
*) _cc_cflags="" ;;
clang|clang-*) _cc_cflags="-std=c89 -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses -Wno-pointer-sign -Wno-unused-value -Wno-return-type" ;;
*tcc) _cc_cflags="-std=c89 -w -fsigned-char" ;;
*) _cc_cflags="" ;;
case "$_cpu" in
486) _cpu_cflags="-m32" ;;
arm) _cpu_cflags="" ;;
case "$_cpu" in
486) _cpu_cflags="-m32" ;;
arm) _cpu_cflags="" ;;
+ powerpc) _cpu_cflags="-m32" ;;
*) error "cpfront_link(): unsupported cpu $_cpu" ;;
esac
local _system_cflags=
case "$_system" in
cygwin) _system_cflags="-liconv" ;;
*) error "cpfront_link(): unsupported cpu $_cpu" ;;
esac
local _system_cflags=
case "$_system" in
cygwin) _system_cflags="-liconv" ;;
+ osx) _system_cflags="-D_DARWIN_C_SOURCE -liconv" ;;
*) _system_cflags="" ;;
esac
*) _system_cflags="" ;;
esac
- "$CC" -g -D_XOPEN_SOURCE=700 $_cc_cflags $_cpu_cflags $CFLAGS -o "${_main}" -I "$_this/C" "$_this/C/SYSTEM.c" $_list -lm -ldl -lffi $_system_cflags
+ local _out_exe="${_main}"
+ case "$_system" in
+ cygwin) _out_exe="${_main}.exe" ;;
+ osx) _out_exe="${_main}.out" ;;
+ *) ;;
+ esac
+ "$CC" -g -D_XOPEN_SOURCE=700 $_cc_cflags $_cpu_cflags $CFLAGS -o "${_out_exe}" -I "$_this/C" "$_this/C/SYSTEM.c" $_list -lm -ldl -lffi $_system_cflags
fi
}
fi
}
case "$_cpu" in
386|486|586|686) _cpu=486 ;;
arm|armv6|armv7) _cpu=arm ;;
case "$_cpu" in
386|486|586|686) _cpu=486 ;;
arm|armv6|armv7) _cpu=arm ;;
+ powerpc|ppc|ppc32) _cpu=powerpc ;;
"") error "cpu not specified" ;;
*) error "unsupported cpu $_cpu" ;;
esac
"") error "cpu not specified" ;;
*) error "unsupported cpu $_cpu" ;;
esac
case "$_system" in
linux) _useposix=true ;;
cygwin) _useposix=true ;;
case "$_system" in
linux) _useposix=true ;;
cygwin) _useposix=true ;;
+ osx) _useposix=true ;;
"") error "operation system not specified" ;;
*) error "unsuported operation system $_system" ;;
esac
"") error "operation system not specified" ;;
*) error "unsuported operation system $_system" ;;
esac
fi
mkdir -p -- "$_out"
fi
mkdir -p -- "$_out"
-_out="$(readlink -f "$_out")"
+_out="$(abspath "$_out")"
copy_source "generic" "$_cpu"
if $_useposix; then
copy_source "posix/generic" "posix/$_cpu"
copy_source "generic" "$_cpu"
if $_useposix; then
copy_source "posix/generic" "posix/$_cpu"