summaryrefslogtreecommitdiff
path: root/build_helpers/compile.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build_helpers/compile.sh')
-rwxr-xr-xbuild_helpers/compile.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/build_helpers/compile.sh b/build_helpers/compile.sh
new file mode 100755
index 0000000..8f4f376
--- /dev/null
+++ b/build_helpers/compile.sh
@@ -0,0 +1,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
+