summaryrefslogtreecommitdiff
path: root/build_cross.sh
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2018-01-26 18:19:55 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2018-01-26 18:19:55 +0100
commit76952ff1721daa8531e481b076a5672cef30d7e5 (patch)
tree03cfb7620e002ce96511dd847dc12b54b52512b9 /build_cross.sh
downloadbootstrap32-76952ff1721daa8531e481b076a5672cef30d7e5.tar.xz
initial checkin, building crosstool-ng
Diffstat (limited to 'build_cross.sh')
-rwxr-xr-xbuild_cross.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/build_cross.sh b/build_cross.sh
new file mode 100755
index 0000000..997d68e
--- /dev/null
+++ b/build_cross.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# Prepare the cross-compiler for the destination platform, in our
+# case i486.
+
+if test ! "$(getent group cross)"; then
+ groupadd cross
+fi
+
+if test ! "$(getent passwd cross)"; then
+ useradd -m -g cross cross
+fi
+
+# add 'cross' user as sudoer without password
+if test ! -f /etc/sudoers.d/cross; then
+ echo "cross ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/cross
+fi
+
+if test ! -x /usr/local/bin/ct-ng; then
+ su - cross <<EOF
+mkdir cross
+cd cross
+git clone https://github.com/crosstool-ng/crosstool-ng.git
+cd crosstool-ng
+./bootstrap
+./configure --prefix=/usr/local
+make
+sudo make install
+cd ..
+EOF
+fi
+
+if test ! -x /home/cross/x-tools/i486-unknown-linux-gnu/bin/i486-unknown-linux-gnu-gcc; then
+ rm -rf /home/cross/{x-tools,.build,build.log,.wget-hsts,.config,.config.old}
+ cp ct-ng.config /home/cross/.config
+ CPUS=$(nproc)
+ sed -i "s/^CT_PARALLEL_JOBS=.*/CT_PARALLEL_JOBS=$CPUS/" /home/cross/.config
+ chown cross:cross /home/cross/.config
+ su - cross <<EOF
+ct-ng build
+EOF
+fi