aboutsummaryrefslogtreecommitdiff
path: root/fe
blob: f6d92705759419bea832bf2403b8c178bf982d65 (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
#! /bin/sh

set -e
test $# -ne 1 && (echo "$0 <file>"; exit 1)

musl=${musl:-$HOME/musl}
qbeo=$(mktemp).qbe
tmp=$(mktemp).s
obj=$(basename $1 .uc).o

if [ -f ./build/prc ]
then
	./build/prc $1 > $qbeo
elif [ -f ./prc ]
then
	./prc $1 > $qbeo
else
	echo "cannot find prc executable in either $PWD/prc or $PWD/build/prc" >&2
	exit 1
fi

# uncomment to print out qbe IL output
cat $qbeo
qbe -o $tmp $qbeo
as -o $obj $tmp
ld -static -z nodefaultlib --gc-sections -o a.out -L $musl/lib/ $musl/lib/crt* $obj -lc
rm $tmp $qbeo