devtools/cross/pkgs/mksh/build.sh

86 lines
2.2 KiB
Bash
Raw Normal View History

#!/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/
2017-12-21 07:49:37 +01:00
export MKSHRC_PATH='~/lib/mkshrc'
2018-11-26 23:29:26 +01:00
export LIBS="$JEHANNE/posix/lib/libc.a $JEHANNE/posix/lib/libm.a $JEHANNE/posix/lib/libg.a -lposix -lc"
export CPPFLAGS="'-DMKSHRC_PATH=\"$MKSHRC_PATH\"' '-DARCH=\"$ARCH\"'"
export LD_PRELOAD=
echo -n Building mksh.
(
# Inside parentheses, and therefore a subshell . . .
while [ 1 ] # Endless loop.
do
echo -n "."
sleep 3
done
) &
dotter=$!
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
}
2017-12-22 00:26:38 +01:00
rm -f $MKSH/mksh.build.log
(
2017-12-22 00:26:38 +01:00
cd $MKSH
rm -fr $MKSH_BUILD
mkdir $MKSH_BUILD &&
cd $MKSH_BUILD &&
2017-12-21 07:49:37 +01:00
TARGET_OS=Jehanne CC=x86_64-jehanne-gcc sh ../src/Build.sh &&
cp mksh $JEHANNE/arch/amd64/cmd/mksh &&
sed -e '3,$s/\bbin\b/cmd/g' ../src/dot.mkshrc > mkshrc &&
echo "mksh installed at $JEHANNE/arch/amd64/cmd/mksh"
mkdir -p $JEHANNE/arch/mksh/lib &&
cp mkshrc $JEHANNE/arch/mksh/lib &&
2017-12-21 07:49:37 +01:00
cp mkshrc $JEHANNE/usr/glenda/lib &&
echo "mkshrc installed at $JEHANNE/arch/mksh/lib and $JEHANNE/usr/glenda/lib"
2017-12-22 00:26:38 +01:00
) > $MKSH/mksh.build.log 2>&1
failOnError $? "building mksh"
kill $dotter
wait $dotter 2>/dev/null
echo "done"
exit 0;