2017-04-19 23:08:16 +02:00
|
|
|
#!/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
|
|
|
|
|
2017-04-22 12:05:27 +02:00
|
|
|
export CROSS_DIR=$JEHANNE/hacking/cross
|
|
|
|
export NEWLIB=$CROSS_DIR/pkgs/newlib/
|
|
|
|
export NEWLIB_SRC=$NEWLIB/src/
|
|
|
|
export NEWLIB_BUILD=$NEWLIB/build/
|
|
|
|
export NEWLIB_PREFIX=$NEWLIB/output/
|
|
|
|
|
2017-09-01 00:50:43 +02:00
|
|
|
export LD_PRELOAD=
|
|
|
|
|
2017-05-18 03:27:20 +02:00
|
|
|
echo -n Building newlib.
|
|
|
|
(
|
|
|
|
# Inside parentheses, and therefore a subshell . . .
|
|
|
|
while [ 1 ] # Endless loop.
|
|
|
|
do
|
|
|
|
echo -n "."
|
|
|
|
sleep 3
|
|
|
|
done
|
|
|
|
) &
|
|
|
|
dotter=$!
|
|
|
|
|
2017-04-19 23:08:16 +02:00
|
|
|
function failOnError {
|
|
|
|
# $1 -> exit status on a previous command
|
|
|
|
# $2 -> task description
|
|
|
|
if [ $1 -ne 0 ]; then
|
2017-05-18 19:11:33 +02:00
|
|
|
kill $dotter
|
|
|
|
wait $dotter 2>/dev/null
|
|
|
|
|
2017-04-19 23:08:16 +02:00
|
|
|
echo "ERROR $2"
|
2017-04-22 17:45:40 +02:00
|
|
|
if [ "$TRAVIS_BUILD_DIR" != "" ]; then
|
|
|
|
echo
|
|
|
|
echo "CONFIG.LOG @ $NEWLIB_BUILD/config.log"
|
|
|
|
echo
|
|
|
|
cat $NEWLIB_BUILD/config.log
|
2017-12-18 00:16:35 +01:00
|
|
|
cat $NEWLIB/newlib.build.log
|
2017-04-22 17:45:40 +02:00
|
|
|
fi
|
2017-04-19 23:08:16 +02:00
|
|
|
exit $1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-01-17 01:21:40 +01:00
|
|
|
function mergeLibPOSIX {
|
|
|
|
TARGET_LIB=$1
|
2020-09-10 22:39:10 +02:00
|
|
|
# echo "Merging $JEHANNE/arch/$ARCH/lib/libposix.a into $TARGET_LIB." &&
|
|
|
|
|
|
|
|
# x86_64-jehanne-ar -M <<EOF
|
|
|
|
#open $TARGET_LIB
|
|
|
|
#addlib $JEHANNE/arch/$ARCH/lib/libposix.a
|
|
|
|
#save
|
|
|
|
#end
|
|
|
|
#EOF
|
|
|
|
|
2020-01-17 01:21:40 +01:00
|
|
|
}
|
|
|
|
|
2017-04-21 23:52:18 +02:00
|
|
|
if [ "$NEWLIB_OPTIMIZATION" = "" ]; then
|
2017-12-18 00:16:35 +01:00
|
|
|
NEWLIB_OPTIMIZATION=2
|
2017-04-21 23:52:18 +02:00
|
|
|
fi
|
|
|
|
|
2017-04-23 13:35:01 +02:00
|
|
|
export CC=gcc
|
2019-12-27 17:34:51 +01:00
|
|
|
export CFLAGS_FOR_TARGET="-g -gdwarf-2 -ggdb -O$NEWLIB_OPTIMIZATION -std=gnu11 -isystem$JEHANNE_TOOLCHAIN/cross/posix/lib/gcc/x86_64-jehanne/9.2.0/include -lposix"
|
2017-04-21 23:52:18 +02:00
|
|
|
|
2017-04-20 00:53:47 +02:00
|
|
|
(
|
2017-04-21 23:52:18 +02:00
|
|
|
rm -fr $NEWLIB_BUILD &&
|
|
|
|
rm -fr $NEWLIB_PREFIX &&
|
2017-04-20 00:53:47 +02:00
|
|
|
mkdir $NEWLIB_BUILD &&
|
|
|
|
mkdir $NEWLIB_PREFIX &&
|
|
|
|
cd $NEWLIB_BUILD &&
|
2020-08-29 01:23:19 +02:00
|
|
|
$NEWLIB_SRC/configure --enable-newlib-mb --disable-newlib-fvwrite-in-streamio --disable-newlib-unbuf-stream-opt --prefix=/pkgs/newlib --target=x86_64-jehanne &&
|
2019-12-16 00:15:12 +01:00
|
|
|
make all &&
|
|
|
|
make DESTDIR=$NEWLIB_PREFIX install &&
|
2020-01-17 01:21:40 +01:00
|
|
|
cd $NEWLIB_PREFIX/pkgs/newlib/x86_64-jehanne/lib &&
|
|
|
|
mergeLibPOSIX libc.a &&
|
|
|
|
( cmp --silent libc.a libg.a || mergeLibPOSIX libg.a ) &&
|
2018-11-26 04:02:20 +01:00
|
|
|
cp -fr $NEWLIB_PREFIX/pkgs/newlib/ $JEHANNE/pkgs/ &&
|
|
|
|
echo "Newlib headers installed at $JEHANNE/pkgs/newlib/"
|
2017-12-18 00:16:35 +01:00
|
|
|
) >> $NEWLIB/newlib.build.log 2>&1
|
2017-04-21 23:52:18 +02:00
|
|
|
failOnError $? "building newlib"
|
2017-05-18 03:27:20 +02:00
|
|
|
|
2020-01-17 01:21:40 +01:00
|
|
|
|
|
|
|
|
2019-11-19 00:24:34 +01:00
|
|
|
# emultate bind for the cross compiler
|
2019-11-28 01:11:43 +01:00
|
|
|
mkdir -p $JEHANNE/posix
|
2019-11-19 00:24:34 +01:00
|
|
|
cp -fr $JEHANNE/pkgs/newlib/x86_64-jehanne/* $JEHANNE/posix
|
|
|
|
|
2017-05-18 03:27:20 +02:00
|
|
|
kill $dotter
|
|
|
|
wait $dotter 2>/dev/null
|
2017-05-18 22:46:08 +02:00
|
|
|
|
2017-08-23 05:31:00 +02:00
|
|
|
echo "done"
|
2017-05-18 22:46:08 +02:00
|
|
|
exit 0;
|