DEADSOFTWARE

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