diff --git a/.gitignore b/.gitignore index 170c484..cde0d87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ third_party/pkg/ third_party/src/github.com/kr/ third_party/src/golang.org/ + +*.build.log diff --git a/cross/pkgs/build.json b/cross/pkgs/build.json index 1d42d16..dc009b1 100644 --- a/cross/pkgs/build.json +++ b/cross/pkgs/build.json @@ -1,7 +1,8 @@ { "CrossCompiledPackages": { "Pre": [ - "./newlib.sh" + "./newlib/build.sh", + "./mksh/build.sh" ] } } diff --git a/cross/pkgs/mksh/build.sh b/cross/pkgs/mksh/build.sh new file mode 100755 index 0000000..8820b71 --- /dev/null +++ b/cross/pkgs/mksh/build.sh @@ -0,0 +1,84 @@ +#!/bin/bash + +# This file is part of Jehanne. +# +# Copyright (C) 2017 Giacomo Tesio +# +# Jehanne is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 2 of the License. +# +# Jehanne is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Jehanne. If not, see . + +if [ "$JEHANNE" = "" ]; then + echo $0 requires the shell started by ./hacking/devshell.sh + exit 1 +fi + + +export CROSS_DIR=$JEHANNE/hacking/cross +export MKSH=$CROSS_DIR/pkgs/mksh/ +export MKSH_SRC=$MKSH/src/ +export MKSH_BUILD=$MKSH/out/ + +export LD_PRELOAD= + +echo -n Building mksh. +( + # Inside parentheses, and therefore a subshell . . . + while [ 1 ] # Endless loop. + do + echo -n "." + sleep 3 + done +) & +dotter=$! + +cd $MKSH + +function failOnError { + # $1 -> exit status on a previous command + # $2 -> task description + if [ $1 -ne 0 ]; then + kill $dotter + wait $dotter 2>/dev/null + + echo "ERROR $2" + if [ "$TRAVIS_BUILD_DIR" != "" ]; then + echo + cat $MKSH/mksh.build.log + echo + fi + exit $1 + fi +} + +export TARGET_OS=Jehanne +export CC=x86_64-jehanne-gcc +export MKSHRC_PATH='~/lib/mkshrc' + +( + git clean -xdf . && + mkdir $MKSH_BUILD && + cd $MKSH_BUILD && + sh ../src/Build.sh && + cp mksh $JEHANNE/arch/amd64/cmd/ && + sed -e '3,$s/\bbin\b/cmd/g' ../src/dot.mkshrc > mkshrc && + mkdir -p $JEHANNE/arch/mksh/lib && + cp mkshrc $JEHANNE/arch/mksh/lib && + cp mkshrc $JEHANNE/usr/glenda/lib +) > $MKSH/mksh.build.log 2>&1 +failOnError $? "building mksh" + + +kill $dotter +wait $dotter 2>/dev/null + +echo "done" +exit 0; diff --git a/cross/pkgs/newlib.sh b/cross/pkgs/newlib/build.sh similarity index 96% rename from cross/pkgs/newlib.sh rename to cross/pkgs/newlib/build.sh index e5fc709..5a90bb7 100755 --- a/cross/pkgs/newlib.sh +++ b/cross/pkgs/newlib/build.sh @@ -57,14 +57,14 @@ function failOnError { echo "CONFIG.LOG @ $NEWLIB_BUILD/config.log" echo cat $NEWLIB_BUILD/config.log - cat newlib.build.log + cat $NEWLIB/newlib.build.log fi exit $1 fi } if [ "$NEWLIB_OPTIMIZATION" = "" ]; then - NEWLIB_OPTIMIZATION=0 + NEWLIB_OPTIMIZATION=2 fi export CC=gcc @@ -87,7 +87,7 @@ export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION" echo "Newlib headers installed at $JEHANNE/sys/posix/newlib/" && mv $NEWLIB_PREFIX/x86_64-jehanne/lib/ $JEHANNE/arch/amd64/lib/newlib/ && echo "Newlib libraries installed at $JEHANNE/arch/amd64/lib/newlib/" -) >> newlib.build.log 2>&1 +) >> $NEWLIB/newlib.build.log 2>&1 failOnError $? "building newlib" kill $dotter