diff --git a/make-bootstrap.sh b/make-bootstrap.sh
index 8fdb3fdc4d3904db0fa7bf201f58fa7a09b5f377..c3a36e66e3e699c3e28dc0cdec84ab8d4e5f6a3d 100755 (executable)
--- a/make-bootstrap.sh
+++ b/make-bootstrap.sh
-#! /bin/sh
+#! /bin/bash
set -e
set -e
-THIS="$(dirname "$(readlink -f "$0")")"
-OUT="$THIS/bootstrap/i486"
-
-cpc() {
- "$THIS/stage2/i486/cpfront" -outcode CodeC -outsym SymC "$@"
+abspath() {
+ [[ "$1" == /* ]] && echo "$1" || echo "$(pwd)/$1"
}
}
-importlist() {
- echo
- while [ "$1" != "" ]; do
- echo -n "\t\t$1"
- shift
- if [ "$1" != "" ]; then
- echo ","
- fi
- done
+###^^^^^^^^^^^^^^^^^^###
+### Global variables ###
+###__________________###
+
+_exec="make-bootstrap.sh"
+_this="$(dirname "$(abspath "$0")")"
+_version="v0.3"
+_sign=false
+
+export CPCFLAGS="-no-use-time $CPCFLAGS"
+export CPLFLAGS="$CPLFLAGS"
+
+###^^^^^^^^^^^###
+### Functions ###
+###___________###
+
+usage() {
+ echo "Usage: make-bootstrap.sh [options]"
+ echo "Options:"
+ echo " -v version Set build version"
+ echo " -S Sign build"
+ 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
}
}
-mainmodule() {
-local name="$1"
-shift
-cat <<!
-MODULE ${name};
-
- IMPORT $(importlist "$@");
-
-END ${name}.
-!
+make_bootstrap() {
+ local _cpu="$1"
+ local _target="$2"
+ local _system="$3"
+ "$_this/make.sh" -x -o "$_this/bootstrap/$_cpu-$_target-$_system" \
+ "$_cpu" "$_target" "$_system"
+ find "$_this/bootstrap/$_cpu-$_target-$_system" -mindepth 1 -maxdepth 1 \
+ -type d -name 'CodeC' -prune -o -exec rm -rf {} +
}
}
-linkall() {
- local name="$1";
- mainmodule "$@" > "$name.cp"
- shift
-
- cpc -main "$name.cp"
-
- local list=""
- for mod in "$@" "$name"; do
- list="$list CodeC/$mod.c"
- done
+error() {
+ echo "$_exec:" "$@"
+ exit 1
}
}
-###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
-### Prepare bbdsw sources for LINUX/i486 ###
-###______________________________________###
-
-rm -rf "$OUT"
-mkdir -p "$OUT"
-cp -r -- \
- "$THIS/src/generic/"* \
- "$THIS/src/posix/"* \
- "$THIS/src/cpfront/posix/"* \
- "$THIS/src/cpfront/linux/"* \
- "$OUT"
-cd "$OUT"
-
-###^^^^^^^^^^^^^^^^^^^^^^^^###
-### Compile POSIX bindings ###
-###________________________###
-
-cpc 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
-
-###^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
-### Compile BlackBox Framework ###
-###____________________________###
-
-cpc System/Mod/Math.cp System/Mod/SMath.cp 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/Int.odc System/Mod/Integers.odc
-
-###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
-### Compile Linux Host subsystem ###
-###______________________________###
-
-cpc Host/Mod/Lang.cp Host/Mod/Dates.cp Host/Mod/Console.cp Host/Mod/Files.cp
-
-###^^^^^^^^^^^^^^^^^^^^^^^###
-### Compile Dev subsystem ###
-###_______________________###
-
-cpc Dev/Mod/CPM.cp Dev/Mod/CPT.odc Dev/Mod/CPS.odc Dev/Mod/CPB.odc \
- Dev/Mod/CPP.odc Dev/Mod/CPE.odc Dev/Mod/CPH.odc Dev/Mod/CPL486.odc \
- Dev/Mod/CPC486.odc Dev/Mod/CPV486.odc
-
-###^^^^^^^^^^^^^^^^^^^^^^^^###
-### Compile Dev2 subsystem ###
-###________________________###
-
-cpc Dev2/Mod/LnkBase.odc Dev2/Mod/LnkChmod.odc Dev2/Mod/LnkLoad.odc \
- Dev2/Mod/LnkWriteElf.odc Dev2/Mod/LnkWriteElfStatic.odc \
- Dev2/Mod/LnkWritePe.odc
-
-###^^^^^^^^^^^^^^^^^^^^^^^^^^^###
-### Compile CPfront subsystem ###
-###___________________________###
-
-cpc CPfront/Mod/CPG.odc CPfront/Mod/CPC.odc CPfront/Mod/CPV.odc
-
-###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
-### Compile bbdsw-specific modules ###
-###________________________________###
-
-cpc Dsw/Mod/Documents.cp Dsw/Mod/Log.odc Dsw/Mod/Compiler486Main.cp \
- Dsw/Mod/CompilerCPfrontMain.cp Dsw/Mod/Linker486Main.cp
-
-###^^^^^^^^^^^^^^^^^^^^^^^^^###
-### Compile other utilities ###
-###_________________________###
-
-cpc Dsw/Mod/ListMain.cp Dsw/Mod/EchoMain.cp Dsw/Mod/LoopMain.cp
-
-###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
-### Link Standalone Component Pascl Compiler & Dev2 Linker ###
-###________________________________________________________###
-
-linkall cpfront \
- C99types C99macro \
- Kernel Console Files Dates Math Strings Services Log \
- HostLang HostConsole HostFiles HostDates DswLog \
- DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
- CPfrontCPG CPfrontCPC CPfrontCPV\
- DswDocuments DswCompilerCPfrontMain
-
-linkall cpc486 \
- C99types C99macro \
- Kernel Console Files Dates Math Strings Services Log \
- HostLang HostConsole HostFiles HostDates DswLog \
- DevCPM DevCPT DevCPS DevCPB DevCPP DevCPE DevCPH \
- DevCPL486 DevCPC486 DevCPV486 \
- DswDocuments DswCompiler486Main
-
-linkall cpl486 \
- C99types C99macro \
- Kernel Console Files Math Strings Services Log \
- HostLang HostConsole HostFiles DswLog \
- Dev2LnkBase Dev2LnkChmod Dev2LnkLoad Dev2LnkWriteElf \
- Dev2LnkWriteElfStatic Dev2LnkWritePe \
- DswLinker486Main
-
-#linkall cplist \
-# C99types C99macro \
-# Kernel Console Files Math Strings Services Log \
-# HostLang HostConsole HostFiles DswLog \
-# DswListMain
-
-#linkall cpecho \
-# C99types C99macro \
-# Kernel Console Files Math Strings Services Log \
-# HostLang HostConsole HostFiles DswLog \
-# DswEchoMain
-
-#linkall cploop \
-# C99types C99macro \
-# Kernel Console Files Math Strings Services Log \
-# HostLang HostConsole HostFiles DswLog \
-# DswLoopMain
-
-rm -rf "$THIS/bootstrap-src"
-mkdir -p "$THIS/bootstrap-src"
-cp -r -t "$THIS/bootstrap-src" -- \
- "$THIS/CHANGELOG" \
- "$THIS/LICENSE" \
- "$THIS/README" \
- "$THIS/man" \
- "$THIS/crux" \
- "$THIS/make-bootstrap.sh" \
- "$THIS/make-stage0.sh" \
- "$THIS/make-stage0c.sh" \
- "$THIS/make-stage1.sh" \
- "$THIS/make-stage2.sh" \
- "$THIS/src" \
- "$THIS/C" \
- CodeC
-
-cd "$THIS"
-tar czf cpc-v0.1.src.tar.gz bootstrap-src
+###^^^^^^^^^^^^^^^###
+### Parse options ###
+###_______________###
+
+while getopts v:Sh _name
+do
+ case "$_name" in
+ v) _version="$OPTARG" ;;
+ S) _sign=true ;;
+ h|?) usage ;;
+ esac
+done
+
+if [ -z "$_version" ] || echo "$_version" | grep " " > /dev/null; then
+ error "version not specified or contain spaces"
+fi
+
+###^^^^^^^^^^^^^^^^^^^^###
+### Prebuild C sources ###
+###____________________###
+
+rm -rf "$_this/bootstrap"
+mkdir -p "$_this/bootstrap"
+make_bootstrap 486 cpfront linux
+#make_bootstrap 486 cpfront cygwin
+#make_bootstrap arm cpfront linux
+#make_bootstrap powerpc cpfront osx
+
+###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
+### Hack: remove temp files from v0.1 ###
+###___________________________________###
+
+find "$_this/bootstrap" -type f -name '.new*' -delete
+
+###^^^^^^^^^^^^^^^^^^^^^^###
+### Package dist sources ###
+###______________________###
+
+rm -rf "$_this/cpc-$_version"
+mkdir -p "$_this/cpc-$_version"
+cp -r \
+ "$_this/CHANGELOG" \
+ "$_this/LICENSE" \
+ "$_this/README" \
+ "$_this/man" \
+ "$_this/crux" \
+ "$_this/make.sh" \
+ "$_this/make-all.sh" \
+ "$_this/make-bootstrap.sh" \
+ "$_this/bootstrap" \
+ "$_this/src" \
+ "$_this/C" \
+ "$_this/cpc-$_version"
+tar czf "cpc-$_version.src.tar.gz" "cpc-$_version"
+
+###^^^^^^^^^^^^^^^^###
+### Make signature ###
+###________________###
+
+if $_sign; then
+ gpg --yes --armor --detach-sig "cpc-$_version.src.tar.gz"
+fi