recipes: libs/libpsl: Added version 0.21.1
[dragora.git] / darkcrusade
blob958cae9deef676e99eec450664c398bc7b917ffa
1 #! /bin/sh -
3 # Deploy static cross-compilers for easy distribution
5 # Copyright (c) 2016-2020 Matias Fonzo, <selk@dragora.org>.
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
19 PROGRAM="${0##*/}"
21 # Exit immediately on any error
22 set -e
24 # Show help via option
25 if test "$1" = -h || test "$1" = --help
26 then
27 echo "Usage: $PROGRAM [TARGET]..."
28 echo "Deploy static cross-compilers for easy distribution."
29 echo ""
30 echo "Where TARGET is any target found in the \"targets/\" directory."
31 echo "If no target names are passed, all available targets will be built."
32 echo ""
33 exit 0;
36 # Override locale settings
37 LC_ALL=C
38 export LC_ALL
40 ### Default values
42 # Get physical working directory (absolute path)
43 CWD="$(CDPATH='' cd -P -- "$(dirname -- "$0")" && pwd -P)"
45 # Output directory for tarballs
46 output="${CWD}/OUTPUT.darkcrusade"
48 # Set temporary directory for compilation, exporting it
49 TMPDIR=${output}/sources
50 export TMPDIR
52 # Compose tag for tarball names using year+month+day
53 tarname=darkcrusade_"$(date +%Y%b)"
55 # Prepare to start the cross compiler process in the phase 1
57 phase_one=${output}/phase1-native-"$(uname -m)".$$
59 echo "${PROGRAM}: Creating native cross compiler on $phase_one ..."
60 "${CWD}"/bootstrap -s0 -o "$phase_one"
62 # Now will start the preparatives to use the recent native cross compiler
64 echo "${PROGRAM}: Using (existing) compiler from $phase_one ..."
66 # Set flags according to the generated compiler
67 for BTCC in "${phase_one}"/cross/*/bin/*-gcc
69 if test -x "$BTCC"
70 then
71 BTCC="$BTCC"
72 break
74 done
75 for BTCXX in "${phase_one}"/cross/*/bin/*-g++
77 if test -x "$BTCXX"
78 then
79 BTCXX="$BTCXX"
80 break
82 done
84 # Set and compose flags to be used as CC/CXX
86 BTCC="$BTCC -static -Wl,-Bstatic -static-libgcc"
87 BTCXX="$BTCXX -static -Wl,-Bstatic -static-libgcc"
89 IS_DARKCRUSADE=IS_DARKCRUSADE
91 export BTCC BTCXX IS_DARKCRUSADE
93 # Loop for create the targets, phase 2
94 for target in ${CWD}/targets/${@:-*}
96 target="${target##*/}"
97 phase_two=${output}/phase2-${target}.$$
99 echo "darkcrusade: Making target $target ..."
100 "${CWD}"/bootstrap -s0 -a "$target" -o "$phase_two" 2>&1 | \
101 tee "${output}/${tarname}-${target}.log"
103 # Provide log file, tarball plus checkum
105 lzip -9 "${output}/${tarname}-${target}.log" &
106 rm -f "${output}/${tarname}-${target}.tar" \
107 "${output}/${tarname}-${target}.tar.lz"
109 cd "$phase_two"
110 ( umask 022 ; tarlz --solid -9 -cvf - -- cross/ ) \
111 > "${output}/${tarname}-${target}.tar.lz"
114 cd -- "$output" && \
115 sha256sum "${tarname}-${target}.tar.lz" \
116 > "${tarname}-${target}.tar.lz.sha256"
119 # Back to the current working directory
120 cd -- "$CWD"
121 done