aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2024-07-21 22:55:49 +0200
committerMiquel Sabaté Solà <mikisabate@gmail.com>2024-07-21 22:55:49 +0200
commit94d19520195810695a12780b24a9510ca1324b66 (patch)
tree6998ec4c34ebd56addfa79afaf28d00b53ce7472 /bin
parent79f8e8225b7cc62e9b66efe69863646002e328ac (diff)
downloaddotfiles-94d19520195810695a12780b24a9510ca1324b66.tar.gz
dotfiles-94d19520195810695a12780b24a9510ca1324b66.zip
bin: added a simple script for cross compilation
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cross18
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/cross b/bin/cross
new file mode 100755
index 0000000..7ef26b6
--- /dev/null
+++ b/bin/cross
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+arch=$(uname -m)
+if [ "${arch}" != "x86_64" ]; then
+ echo "This tool is only meant to be used on x86_64!"
+ exit 1
+fi
+
+count=$(find /usr/bin/riscv64-*-gcc -printf "%f\n" | grep -v elf -c)
+if [ "$count" -lt 1 ]; then
+ echo "There are too many options for the compiler, not even trying... Bail!"
+ exit 1
+fi
+
+bin=$(find /usr/bin/riscv64-*-gcc -printf "%f\n" | grep -v elf | rev | cut -c4- | rev)
+
+export ARCH="riscv"
+export CROSS_COMPILE="${bin}"