devtools: simplify newlib's build; add mksh build

This commit is contained in:
Giacomo Tesio 2017-12-18 00:16:35 +01:00
parent 171be01bc5
commit 86c2386c1c
4 changed files with 91 additions and 4 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
third_party/pkg/ third_party/pkg/
third_party/src/github.com/kr/ third_party/src/github.com/kr/
third_party/src/golang.org/ third_party/src/golang.org/
*.build.log

View File

@ -1,7 +1,8 @@
{ {
"CrossCompiledPackages": { "CrossCompiledPackages": {
"Pre": [ "Pre": [
"./newlib.sh" "./newlib/build.sh",
"./mksh/build.sh"
] ]
} }
} }

84
cross/pkgs/mksh/build.sh Executable file
View File

@ -0,0 +1,84 @@
#!/bin/bash
# This file is part of Jehanne.
#
# Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
#
# 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 <http://www.gnu.org/licenses/>.
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;

View File

@ -57,14 +57,14 @@ function failOnError {
echo "CONFIG.LOG @ $NEWLIB_BUILD/config.log" echo "CONFIG.LOG @ $NEWLIB_BUILD/config.log"
echo echo
cat $NEWLIB_BUILD/config.log cat $NEWLIB_BUILD/config.log
cat newlib.build.log cat $NEWLIB/newlib.build.log
fi fi
exit $1 exit $1
fi fi
} }
if [ "$NEWLIB_OPTIMIZATION" = "" ]; then if [ "$NEWLIB_OPTIMIZATION" = "" ]; then
NEWLIB_OPTIMIZATION=0 NEWLIB_OPTIMIZATION=2
fi fi
export CC=gcc 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/" && echo "Newlib headers installed at $JEHANNE/sys/posix/newlib/" &&
mv $NEWLIB_PREFIX/x86_64-jehanne/lib/ $JEHANNE/arch/amd64/lib/newlib/ && mv $NEWLIB_PREFIX/x86_64-jehanne/lib/ $JEHANNE/arch/amd64/lib/newlib/ &&
echo "Newlib libraries installed at $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" failOnError $? "building newlib"
kill $dotter kill $dotter