aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/bootstrap.sh
blob: 64b71865d18517fff8b1ac6146611ac5da0c3699 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

cd $(dirname "$0")

if [ x"$CC" == x ]; then
   export CC=cc
fi

if command -v ccache > /dev/null; then
   export CC="ccache $CC"
fi

./build.sh || exit 1

export CFLAGS="-Wno-builtin-declaration-mismatch -Wno-discarded-qualifiers -g"

set -euo pipefail

echo "extern static host_target_triple const *const u8 = \"`clang -print-target-triple`\";" > ../src/host-target-triple.cff

mkdir -p obj1/
for f in $(find ../src/ -name '*.cff'); do
   out=obj1/$(basename "$f").o
   (set -x ; ./cff0 "$f" | $CC $CFLAGS -xc - -c -o $out)
done
for f in $(find ../src/ -name '*.c'); do
   out=obj1/$(basename "$f").o
   (set -x ; $CC $CFLAGS "$f" -c -o $out)
done
set -x
$CC $CFLAGS -ocff1 obj1/*.o

CFFC=$(dirname "$0")/cff1 make -C ../