Dragora - an independent GNU/Linux-Libre distribution based on concepts of simplicity
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

122 lines
3.2 KiB

#! /bin/sh -
#
# Deploy static cross-compilers for easy distribution
#
# Copyright (c) 2016-2020 Matias Fonzo, <selk@dragora.org>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
PROGRAM="${0##*/}"
# Exit immediately on any error
set -e
# Show help via option
if test "$1" = -h || test "$1" = --help
then
echo "Usage: $PROGRAM [TARGET]..."
echo "Deploy static cross-compilers for easy distribution."
echo ""
echo "Where TARGET is any target found in the \"targets/\" directory."
echo "If no target names are passed, all available targets will be built."
echo ""
exit 0;
fi
# Override locale settings
LC_ALL=C
export LC_ALL
### Default values
# Get physical working directory (absolute path)
CWD="$(CDPATH='' cd -P -- "$(dirname -- "$0")" && pwd -P)"
# Output directory for tarballs
output="${CWD}/OUTPUT.darkcrusade"
# Set temporary directory for compilation, exporting it
TMPDIR=${output}/sources
export TMPDIR
# Compose tag for tarball names using year+month+day
tarname=darkcrusade_"$(date +%Y%b)"
# Prepare to start the cross compiler process in the phase 1
phase_one=${output}/phase1-native-"$(uname -m)".$$
echo "${PROGRAM}: Creating native cross compiler on $phase_one ..."
"${CWD}"/bootstrap -s0 -o "$phase_one"
# Now will start the preparatives to use the recent native cross compiler
echo "${PROGRAM}: Using (existing) compiler from $phase_one ..."
# Set flags according to the generated compiler
for BTCC in "${phase_one}"/cross/*/bin/*-gcc
do
if test -x "$BTCC"
then
BTCC="$BTCC"
break
fi
done
for BTCXX in "${phase_one}"/cross/*/bin/*-g++
do
if test -x "$BTCXX"
then
BTCXX="$BTCXX"
break
fi
done
# Set and compose flags to be used as CC/CXX
BTCC="$BTCC -static -Wl,-Bstatic -static-libgcc"
BTCXX="$BTCXX -static -Wl,-Bstatic -static-libgcc"
IS_DARKCRUSADE=IS_DARKCRUSADE
export BTCC BTCXX IS_DARKCRUSADE
# Loop for create the targets, phase 2
for target in ${CWD}/targets/${@:-*}
do
target="${target##*/}"
phase_two=${output}/phase2-${target}.$$
echo "darkcrusade: Making target $target ..."
"${CWD}"/bootstrap -s0 -a "$target" -o "$phase_two" 2>&1 | \
tee "${output}/${tarname}-${target}.log"
# Provide log file, tarball plus checkum
lzip -9 "${output}/${tarname}-${target}.log" &
rm -f "${output}/${tarname}-${target}.tar" \
"${output}/${tarname}-${target}.tar.lz"
cd "$phase_two"
( umask 022 ; tarlz --solid -9 -cvf - -- cross/ ) \
> "${output}/${tarname}-${target}.tar.lz"
(
cd -- "$output" && \
sha256sum "${tarname}-${target}.tar.lz" \
> "${tarname}-${target}.tar.lz.sha256"
)
# Back to the current working directory
cd -- "$CWD"
done