builds_bloody-base/build-raw.sh

39 lines
817 B
Bash
Raw Normal View History

2020-09-14 22:58:51 +00:00
#! /usr/bin/env bash
# Configs
if [ -z "$CC" ]
then
CC="gcc"
fi
# URL
TCC_URL='https://download.savannah.gnu.org/releases/tinycc/tcc-0.9.27.tar.bz2'
TCC_SHA256='de23af78fca90ce32dff2dd45b3432b2334740bb9bb7b05bf60fdbfc396ceb9c'
TCC_FILE='tcc.tar.bz2'
# Download
cd "$(dirname "$0")" &&
mkdir -p 'files/raw' &&
cd 'files/raw' &&
(
if [ ! -f "$TCC_FILE" ]; then
wget -O "$TCC_FILE" "$TCC_URL"
else
echo Use cache
fi
) &&
( TMP="$(sha256sum "$TCC_FILE")" &&
if [ "${TMP:0:64}" != "$TCC_SHA256" ]
then
rm -rf "$TCC_FILE" &&
echo 'Hash miss matches!' &&
exit 1
fi ) &&
# Build tcc
ls | grep -v "$TCC_FILE" | xargs rm -rf &&
tar -xf "$TCC_FILE" &&
cd tcc-* &&
echo '#define TCC_VERSION "0.9.27"' > config.h &&
echo '#undef TCC_IS_NATIVE' >> tcc.h &&
"$CC" -static -o ../tcc -DCONFIG_TCCBOOT tcc.c