X-Git-Url: https://deadsoftware.ru/gitweb?p=cpc.git;a=blobdiff_plain;f=make.sh;h=4551cab106ef4fa6eef1a657cb240806f43fc25e;hp=ecd46c387609acb68e4b8ca1f9101d04454a88d9;hb=b97962cb490f66c92f11336003d9007c0b0c867f;hpb=76d1e8d98f1d80d24fa52a15e6b2c6fb0a5f44d0 diff --git a/make.sh b/make.sh index ecd46c3..4551cab 100755 --- a/make.sh +++ b/make.sh @@ -19,6 +19,9 @@ _out="$_this/bin" _useposix=false +export CPCFLAGS="$CPCFLAGS" +export CPLFLAGS="$CPLFLAGS" + ###^^^^^^^^^^^### ### Functions ### ###___________### @@ -33,11 +36,18 @@ usage() { 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 " cygwin Cygwin" + echo "Environment variables:" + echo " CC C compiler binary" + echo " CFLAGS C compiler options" + echo " CPCFLAGS CPC compiler options" + echo " CPLFLAGS CPL linker options" exit 2 } @@ -56,13 +66,20 @@ copy_source() { } native_compile() { - "$_compiler" -legacy "$@" + "$_compiler" $CPCFLAGS -legacy "$@" } native_link() { if $_dolink; then - "$_linker" -os "$_system" -kernel Kernel -main Kernel -legacycodedir . -o "$@" - fi + local _outexe="$1"; + local _outsystem="$_system" + if [ "$_system" = "cygwin" ]; then + _outexe="${_outexe}.exe" + _outsystem="win32" + fi + shift + "$_linker" $CPLFALGS -os "$_outsystem" -kernel Kernel -main Kernel -legacycodedir . -o "$_outexe" "$@" + fi } cpfront_import_list() { @@ -80,18 +97,22 @@ cpfront_import_list() { cpfront_main_module() { local _name="$1" shift - echo "MODULE ${_name};\n\n IMPORT $(cpfront_import_list "$@");\n\nEND ${_name}." + echo "MODULE ${_name};" + echo + echo " IMPORT $(cpfront_import_list "$@");" + echo + echo "END ${_name}." } cpfront_compile() { - "$_compiler" -outcode CodeC -outsym SymC "$@" + "$_compiler" $CPCFLAGS -outcode CodeC -outsym SymC "$@" } cpfront_link() { local _main="$1" if $_docompile; then cpfront_main_module "$@" > "${_main}.cp" - "$_compiler" -outcode CodeC -outsym SymC -main "${_main}.cp" + "$_compiler" $CPCFLAGS -outcode CodeC -outsym SymC -main "${_main}.cp" fi shift if $_dolink; then @@ -100,13 +121,24 @@ cpfront_link() { 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="-std=c89 -Wno-int-conversion -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types -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" ;; + *) _cc_cflags="" ;; + esac + local _cpu_cflags= + case "$_cpu" in + 486) _cpu_cflags="-m32" ;; + arm) _cpu_cflags="" ;; + *) error "cpfront_link(): unsupported cpu $_cpu" ;; + esac + local _system_cflags= + case "$_system" in + cygwin) _system_cflags="-liconv" ;; + *) _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 fi } @@ -131,19 +163,20 @@ compile_all() { ### Compile POSIX bindings ### ###________________________### - case "$_system" in - linux) - compile C99/Mod/types.cp \ - C99/Mod/sys_types.cp \ - C99/Mod/stdlib.cp C99/Mod/stdio.cp C99/Mod/unistd.cp \ - C99/Mod/dirent.cp C99/Mod/locale.cp C99/Mod/time.cp \ - C99/Mod/sys_stat.cp C99/Mod/fcntl.cp C99/Mod/errno.cp \ - C99/Mod/iconv.cp C99/Mod/wctype.cp C99/Mod/sys_mman.cp \ - C99/Mod/dlfcn.cp C99/Mod/signal.cp C99/Mod/setjmp.cp \ - C99/Mod/libgen.cp \ - C99/Mod/macro.cp - ;; - esac + if $_useposix; then + compile Posix/Mod/Ctypes.cp \ + Posix/Mod/Csys_types.cp \ + Posix/Mod/Cstdlib.cp Posix/Mod/Cstdio.cp Posix/Mod/Cunistd.cp \ + Posix/Mod/Cdirent.cp Posix/Mod/Clocale.cp Posix/Mod/Ctime.cp \ + Posix/Mod/Csys_stat.cp Posix/Mod/Cfcntl.cp Posix/Mod/Cerrno.cp \ + Posix/Mod/Ciconv.cp Posix/Mod/Cwctype.cp Posix/Mod/Csys_mman.cp \ + Posix/Mod/Cdlfcn.cp Posix/Mod/Csignal.cp Posix/Mod/Csetjmp.cp \ + Posix/Mod/Clibgen.cp \ + Posix/Mod/Cmacro.cp + if [ "$_target" = "cpfront" ]; then + compile Lib/Mod/FFI.cp + fi + fi ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^### ### Compile BlackBox Framework ### @@ -158,8 +191,8 @@ compile_all() { fi compile System/Mod/Kernel.cp \ System/Mod/Console.odc System/Mod/Files.odc System/Mod/Dates.odc \ - System/Mod/Log.odc System/Mod/Strings.odc System/Mod/Services.odc \ - System/Mod/Integers.odc + System/Mod/Log.odc System/Mod/Strings.odc System/Mod/Meta.odc \ + System/Mod/Services.odc System/Mod/Integers.odc if [ "$_target" = "native" ]; then mv -t System Code Sym @@ -212,7 +245,7 @@ link_all() { fi link cpc486 \ - C99types C99macro \ + PosixCtypes PosixCmacro \ Kernel Console Files Dates Math Strings Services Log \ HostLang HostConsole HostFiles HostDates DswLog $_debug_module \ DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \ @@ -220,7 +253,7 @@ link_all() { DswDocuments DswCompiler486Main link cpl486 \ - C99types C99macro \ + PosixCtypes PosixCmacro \ Kernel Console Files Math Strings Services Log \ HostLang HostConsole HostFiles DswLog $_debug_module \ Dev2LnkBase Dev2LnkChmod Dev2LnkLoad Dev2LnkWriteElf \ @@ -228,7 +261,7 @@ link_all() { DswLinker486Main link cpfront \ - C99types C99macro \ + PosixCtypes PosixCmacro \ Kernel Console Files Dates Math Strings Services Log \ HostLang HostConsole HostFiles HostDates DswLog $_debug_module \ DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \ @@ -265,12 +298,17 @@ _cpu="$1" _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 ;; + arm|armv6|armv7) _cpu=arm ;; "") error "cpu not specified" ;; *) error "unsupported cpu $_cpu" ;; esac @@ -284,6 +322,7 @@ esac case "$_system" in linux) _useposix=true ;; + cygwin) _useposix=true ;; "") error "operation system not specified" ;; *) error "unsuported operation system $_system" ;; esac @@ -338,7 +377,9 @@ fi ### Copy sources for changed system ### ###_________________________________### -$_docompile && rm -rf -- "$_out" +if $_docompile; then + rm -rf -- "$_out" +fi mkdir -p -- "$_out" _out="$(readlink -f "$_out")"