summaryrefslogtreecommitdiff
path: root/build_helpers/compile.sh
blob: 8f4f376f7bec688362cff6440d1dc9bbbb4164af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#! /bin/sh
set -u
set -e

INPATH="$1"
INBASEPATH="${INPATH%.*}"
#       mangle such that no two names conflict (a/b/c and a/b.c conflicting would be no fun)
OUTNAME="$(echo "$INBASEPATH" | sed 's/\./../g' | sed 's/\//._/g')"
echo -n "[*] Building '$INPATH' to 'tmp/$OUTNAME'... "
gcc -T linker.ld -m32 -nostartfiles -nostdlib -ffreestanding "$INPATH" -o "tmp/$OUTNAME".o
echo " OK!"
echo -n "[+] Stripping unnecessary sections... "
objcopy -R .note.gnu.build-id -R .comment -O binary "tmp/$OUTNAME".o "bin/$OUTNAME".bin
echo " OK!"
rm "tmp/$OUTNAME".o