2018-11-26 00:57:13 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
echo "Cross compiling GCC and dependencies"
|
|
|
|
|
|
|
|
export WORKING_DIR="$JEHANNE/hacking/cross/pkgs/gcc"
|
|
|
|
|
|
|
|
# include x86_64-jehanne-pkg-config in PATH
|
|
|
|
export PATH="$JEHANNE/hacking/cross/:$PATH"
|
|
|
|
|
|
|
|
function failOnError {
|
|
|
|
# $1 -> exit status on a previous command
|
|
|
|
# $2 -> task description
|
|
|
|
if [ $1 -ne 0 ]; then
|
|
|
|
echo "ERROR $2"
|
|
|
|
echo
|
|
|
|
echo BUILD LOG:
|
|
|
|
echo
|
2018-11-27 18:53:32 +01:00
|
|
|
cat $WORKING_DIR/gcc.build.log
|
2018-11-26 00:57:13 +01:00
|
|
|
exit $1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-03-28 01:00:16 +01:00
|
|
|
function dynpatch {
|
|
|
|
# $1 -> path from $WORKING_DIR/src
|
|
|
|
# $2 -> string to search
|
|
|
|
( cd $WORKING_DIR/src &&
|
|
|
|
grep -q jehanne $1 ||
|
|
|
|
sed -n -i -e "/$2/r ../patch/$1" -e '1x' -e '2,${x;p}' -e '${x;p}' $1
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-11-26 00:57:13 +01:00
|
|
|
date > $WORKING_DIR/gcc.build.log
|
|
|
|
|
2018-11-29 02:38:34 +01:00
|
|
|
# verify libtool is installed
|
2018-11-29 18:13:48 +01:00
|
|
|
libtool --version >> /dev/null
|
|
|
|
failOnError $? "libtool installation check"
|
2018-11-28 11:47:24 +01:00
|
|
|
|
2018-11-26 00:57:13 +01:00
|
|
|
(cd src && fetch) >> $WORKING_DIR/gcc.build.log
|
|
|
|
failOnError $? "fetching sources"
|
|
|
|
|
2018-11-28 18:32:39 +01:00
|
|
|
echo -n Building libgmp... | tee -a $WORKING_DIR/gcc.build.log
|
2018-11-26 00:57:13 +01:00
|
|
|
(
|
2018-11-27 18:53:32 +01:00
|
|
|
cd src/libgmp &&
|
2018-11-29 02:38:34 +01:00
|
|
|
( grep -q jehanne configfsf.sub || patch -p0 < $WORKING_DIR/patch/libgmp.patch ) &&
|
2018-11-27 00:28:08 +01:00
|
|
|
./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE &&
|
2018-11-26 01:52:25 +01:00
|
|
|
make &&
|
2018-11-29 02:38:34 +01:00
|
|
|
make DESTDIR=$JEHANNE/pkgs/libgmp/6.1.2/ install &&
|
|
|
|
libtool --mode=finish $JEHANNE/posix/lib
|
|
|
|
) >> $WORKING_DIR/gcc.build.log 2>&1
|
2018-11-26 00:57:13 +01:00
|
|
|
failOnError $? "Building libgmp"
|
|
|
|
echo done.
|
2018-11-26 01:52:25 +01:00
|
|
|
|
2018-11-29 02:38:34 +01:00
|
|
|
#2 Copy to /posix (to emulate bind during cross compilation)
|
2018-11-28 11:47:24 +01:00
|
|
|
cp -pfr $JEHANNE/pkgs/libgmp/6.1.2/posix/* $JEHANNE/posix
|
2018-11-26 01:52:25 +01:00
|
|
|
|
2018-11-28 18:32:39 +01:00
|
|
|
echo -n Building libmpfr... | tee -a $WORKING_DIR/gcc.build.log
|
2018-11-26 01:52:25 +01:00
|
|
|
(
|
2018-11-27 18:53:32 +01:00
|
|
|
cd src/libmpfr &&
|
2018-11-29 02:38:34 +01:00
|
|
|
( grep -q jehanne config.sub || patch -p0 < $WORKING_DIR/patch/libmpfr.patch ) &&
|
2018-11-27 00:28:08 +01:00
|
|
|
./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ &&
|
|
|
|
cp ../../../../patch/MakeNothing.in doc/Makefile &&
|
|
|
|
make &&
|
2018-11-29 02:38:34 +01:00
|
|
|
make DESTDIR=$JEHANNE/pkgs/libmpfr/4.0.1/ install &&
|
|
|
|
libtool --mode=finish $JEHANNE/posix/lib
|
|
|
|
) >> $WORKING_DIR/gcc.build.log 2>&1
|
2018-11-26 01:52:25 +01:00
|
|
|
failOnError $? "Building libmpfr"
|
|
|
|
echo done.
|
2018-11-27 01:46:03 +01:00
|
|
|
|
|
|
|
# Copy to /posix (to emulate bind during cross compilation)
|
2018-11-28 11:47:24 +01:00
|
|
|
cp -pfr $JEHANNE/pkgs/libmpfr/4.0.1/posix/* $JEHANNE/posix
|
2018-11-27 01:46:03 +01:00
|
|
|
|
2018-11-28 18:32:39 +01:00
|
|
|
echo -n Building libmpc... | tee -a $WORKING_DIR/gcc.build.log
|
|
|
|
(
|
|
|
|
cd src/libmpc &&
|
2018-11-29 02:38:34 +01:00
|
|
|
( grep -q jehanne config.sub || ( chmod u+w config.sub &&
|
2018-11-28 18:32:39 +01:00
|
|
|
patch -p0 < $WORKING_DIR/patch/libmpc.patch &&
|
2018-11-29 02:38:34 +01:00
|
|
|
chmod u-w config.sub ) ) &&
|
2018-11-28 18:32:39 +01:00
|
|
|
./configure --host=x86_64-jehanne --prefix=/posix/ --with-sysroot=$JEHANNE --with-gmp=$JEHANNE/pkgs/libgmp/6.1.2/posix/ --with-mpfr=$JEHANNE/pkgs/libmpfr/4.0.1/posix/ &&
|
|
|
|
cp ../../../../patch/MakeNothing.in doc/Makefile &&
|
|
|
|
make &&
|
2018-11-29 02:38:34 +01:00
|
|
|
make DESTDIR=$JEHANNE/pkgs/libmpc/1.1.0/ install &&
|
|
|
|
libtool --mode=finish $JEHANNE/posix/lib
|
|
|
|
) >> $WORKING_DIR/gcc.build.log 2>&1
|
2018-11-28 18:32:39 +01:00
|
|
|
failOnError $? "Building libmpc"
|
|
|
|
echo done.
|
|
|
|
|
|
|
|
# Copy to /posix (to emulate bind during cross compilation)
|
|
|
|
cp -pfr $JEHANNE/pkgs/libmpc/1.1.0/posix/* $JEHANNE/posix
|
|
|
|
|
2018-11-29 18:13:48 +01:00
|
|
|
echo -n Building binutils... | tee -a $WORKING_DIR/gcc.build.log
|
|
|
|
# Patch and build binutils
|
|
|
|
if [ "$BINUTILS_BUILD_DIR" = "" ]; then
|
|
|
|
export BINUTILS_BUILD_DIR=$WORKING_DIR/build-binutils
|
|
|
|
fi
|
2019-11-05 00:19:53 +01:00
|
|
|
( ( grep -q jehanne src/binutils/config.sub || (
|
2018-11-29 18:13:48 +01:00
|
|
|
sed -i '/jehanne/b; /ELF_TARGET_ID/,/elf_backend_can_gc_sections/s/0x200000/0x1000 \/\/ jehanne hack/g' src/binutils/bfd/elf64-x86-64.c &&
|
2019-11-05 00:22:29 +01:00
|
|
|
sed -i '/jehanne/b; s/| midnightbsd\*/| midnightbsd* | jehanne*/g' src/binutils/config.sub &&
|
2018-11-29 18:13:48 +01:00
|
|
|
dynpatch 'binutils/bfd/config.bfd' '\# END OF targmatch.h' &&
|
2019-11-05 00:22:29 +01:00
|
|
|
dynpatch 'binutils/gas/configure.tgt' ' i386-\*-darwin\*)' &&
|
2018-11-29 18:13:48 +01:00
|
|
|
( grep -q jehanne src/binutils/ld/configure.tgt || patch -p1 < patch/binutils/ld/configure.tgt ) &&
|
|
|
|
cp patch/binutils/ld/emulparams/elf_x86_64_jehanne.sh src/binutils/ld/emulparams/ &&
|
|
|
|
cp patch/binutils/ld/emulparams/elf_i386_jehanne.sh src/binutils/ld/emulparams/ &&
|
|
|
|
dynpatch 'binutils/ld/Makefile.am' 'eelf_x86_64.c: ' &&
|
|
|
|
(grep 'eelf_i386_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_EMULATION_SOURCES = \\.*/&\n\teelf_i386_jehanne.c \\/' src/binutils/ld/Makefile.am) &&
|
|
|
|
(grep 'eelf_x86_64_jehanne.c \\' src/binutils/ld/Makefile.am || sed -i 's/.*ALL_64_EMULATION_SOURCES = \\.*/&\n\teelf_x86_64_jehanne.c \\/' src/binutils/ld/Makefile.am) &&
|
|
|
|
cd src/binutils/ld && automake && cd ../ ) ) &&
|
2019-11-05 00:22:29 +01:00
|
|
|
mkdir -p $BINUTILS_BUILD_DIR && cd $BINUTILS_BUILD_DIR &&
|
2019-03-28 01:00:16 +01:00
|
|
|
$WORKING_DIR/src/binutils/configure --prefix=/posix --with-sysroot=$JEHANNE --target=x86_64-jehanne --enable-interwork --enable-multilib --disable-nls --disable-werror &&
|
2019-11-05 00:22:29 +01:00
|
|
|
cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/doc/Makefile &&
|
|
|
|
cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/bfd/po/Makefile &&
|
|
|
|
cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/gas/doc/Makefile &&
|
|
|
|
cp $WORKING_DIR/../../patch/MakeNothing.in $WORKING_DIR/src/binutils/binutils/doc/Makefile &&
|
2018-11-29 18:13:48 +01:00
|
|
|
make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true &&
|
2019-03-28 01:00:16 +01:00
|
|
|
make MAKEINFO=true MAKEINFOHTML=true TEXI2DVI=true TEXI2PDF=true DVIPS=true DESTDIR=$JEHANNE/pkgs/binutils/2.31/ install
|
2018-11-29 18:13:48 +01:00
|
|
|
) >> $WORKING_DIR/gcc.build.log 2>&1
|
|
|
|
failOnError $? "Building binutils"
|
|
|
|
fi
|
|
|
|
echo done.
|
|
|
|
|
|
|
|
# Copy to /posix (to emulate bind during cross compilation)
|
|
|
|
cp -pfr $JEHANNE/pkgs/binutils/2.31/posix/* $JEHANNE/posix
|