DEADSOFTWARE

extend NEW syntax
[cpc.git] / make-bootstrap.sh
1 #! /bin/bash
3 set -e
5 abspath() {
6 [[ "$1" == /* ]] && echo "$1" || echo "$(pwd)/$1"
7 }
9 ###^^^^^^^^^^^^^^^^^^###
10 ### Global variables ###
11 ###__________________###
13 _exec="make-bootstrap.sh"
14 _this="$(dirname "$(abspath "$0")")"
15 _version="v0.3"
16 _sign=false
18 export CPCFLAGS="-no-use-time $CPCFLAGS"
19 export CPLFLAGS="$CPLFLAGS"
21 ###^^^^^^^^^^^###
22 ### Functions ###
23 ###___________###
25 usage() {
26 echo "Usage: make-bootstrap.sh [options]"
27 echo "Options:"
28 echo " -v version Set build version"
29 echo " -S Sign build"
30 echo "Environment variables:"
31 echo " CC C compiler binary"
32 echo " CFLAGS C compiler options"
33 echo " CPCFLAGS CPC compiler options"
34 echo " CPLFLAGS CPL linker options"
35 exit 2
36 }
38 make_bootstrap() {
39 local _cpu="$1"
40 local _target="$2"
41 local _system="$3"
42 "$_this/make.sh" -x -o "$_this/bootstrap/$_cpu-$_target-$_system" \
43 "$_cpu" "$_target" "$_system"
44 find "$_this/bootstrap/$_cpu-$_target-$_system" -mindepth 1 -maxdepth 1 \
45 -type d -name 'CodeC' -prune -o -exec rm -rf {} +
46 }
48 error() {
49 echo "$_exec:" "$@"
50 exit 1
51 }
53 ###^^^^^^^^^^^^^^^###
54 ### Parse options ###
55 ###_______________###
57 while getopts v:Sh _name
58 do
59 case "$_name" in
60 v) _version="$OPTARG" ;;
61 S) _sign=true ;;
62 h|?) usage ;;
63 esac
64 done
66 if [ -z "$_version" ] || echo "$_version" | grep " " > /dev/null; then
67 error "version not specified or contain spaces"
68 fi
70 ###^^^^^^^^^^^^^^^^^^^^###
71 ### Prebuild C sources ###
72 ###____________________###
74 rm -rf "$_this/bootstrap"
75 mkdir -p "$_this/bootstrap"
76 make_bootstrap 486 cpfront linux
77 #make_bootstrap 486 cpfront cygwin
78 #make_bootstrap arm cpfront linux
79 #make_bootstrap powerpc cpfront osx
81 ###^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^###
82 ### Hack: remove temp files from v0.1 ###
83 ###___________________________________###
85 find "$_this/bootstrap" -type f -name '.new*' -delete
87 ###^^^^^^^^^^^^^^^^^^^^^^###
88 ### Package dist sources ###
89 ###______________________###
91 rm -rf "$_this/cpc-$_version"
92 mkdir -p "$_this/cpc-$_version"
93 cp -r \
94 "$_this/CHANGELOG" \
95 "$_this/LICENSE" \
96 "$_this/README" \
97 "$_this/man" \
98 "$_this/crux" \
99 "$_this/make.sh" \
100 "$_this/make-all.sh" \
101 "$_this/make-bootstrap.sh" \
102 "$_this/bootstrap" \
103 "$_this/src" \
104 "$_this/C" \
105 "$_this/cpc-$_version"
106 tar czf "cpc-$_version.src.tar.gz" "cpc-$_version"
108 ###^^^^^^^^^^^^^^^^###
109 ### Make signature ###
110 ###________________###
112 if $_sign; then
113 gpg --yes --armor --detach-sig "cpc-$_version.src.tar.gz"
114 fi