2005-11-07 12:43:46 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
# parameters <haiku sourcedir> <buildtools dir> [ <haiku output dir> ]
|
|
|
|
|
|
|
|
# get and check the parameters
|
2008-04-12 06:40:10 +04:00
|
|
|
if [ $# -lt 2 ]; then
|
2005-10-29 20:27:43 +04:00
|
|
|
echo Usage: $0 '<haiku sourcedir> <buildtools dir> [ <haiku output dir> ]' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
haikuSourceDir=$1
|
2005-11-23 02:34:51 +03:00
|
|
|
buildToolsDir=$2/legacy
|
2005-10-29 20:27:43 +04:00
|
|
|
|
2008-04-12 06:40:10 +04:00
|
|
|
if [ $# -lt 3 ]; then
|
2005-10-29 20:27:43 +04:00
|
|
|
haikuOutputDir=$haikuSourceDir/generated
|
|
|
|
else
|
|
|
|
haikuOutputDir=$3
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d $haikuSourceDir ]; then
|
|
|
|
echo "No such directory: \"$haikuSourceDir\"" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d $buildToolsDir ]; then
|
|
|
|
echo "No such directory: \"$buildToolsDir\"" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# create the output dir
|
|
|
|
mkdir -p $haikuOutputDir || exit 1
|
|
|
|
|
|
|
|
|
|
|
|
# get absolute paths
|
2008-04-12 06:40:10 +04:00
|
|
|
currentDir=`pwd`
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
cd $haikuSourceDir
|
2008-04-12 06:40:10 +04:00
|
|
|
haikuSourceDir=`pwd`
|
2005-10-29 20:27:43 +04:00
|
|
|
cd $currentDir
|
|
|
|
|
|
|
|
cd $buildToolsDir
|
2008-04-12 06:40:10 +04:00
|
|
|
buildToolsDir=`pwd`
|
2005-10-29 20:27:43 +04:00
|
|
|
cd $currentDir
|
|
|
|
|
|
|
|
cd $haikuOutputDir
|
2008-04-12 06:40:10 +04:00
|
|
|
haikuOutputDir=`pwd`
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
# create the object and installation directories for the cross compilation tools
|
2006-10-04 03:41:59 +04:00
|
|
|
installDir=$haikuOutputDir/cross-tools
|
|
|
|
objDir=$haikuOutputDir/cross-tools-build
|
2005-10-29 20:27:43 +04:00
|
|
|
binutilsObjDir=$objDir/binutils
|
|
|
|
gccObjDir=$objDir/gcc
|
|
|
|
tmpIncludeDir=$objDir/sysincludes
|
|
|
|
tmpLibDir=$objDir/syslibs
|
|
|
|
|
|
|
|
rm -rf $installDir $objDir
|
|
|
|
|
|
|
|
mkdir -p $installDir $objDir $binutilsObjDir $gccObjDir $tmpIncludeDir \
|
|
|
|
$tmpLibDir || exit 1
|
2008-03-24 02:06:23 +03:00
|
|
|
mkdir -p $installDir/lib/gcc-lib/i586-pc-haiku/$haikuRequiredLegacyGCCVersion
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
# build binutils
|
|
|
|
cd $binutilsObjDir
|
|
|
|
CFLAGS="-O2" CXXFLAGS="-O2" $buildToolsDir/binutils/configure \
|
2008-03-24 02:06:23 +03:00
|
|
|
--prefix=$installDir --target=i586-pc-haiku --disable-nls \
|
2007-02-25 10:06:43 +03:00
|
|
|
--enable-shared=yes --disable-werror || exit 1
|
2005-10-29 20:27:43 +04:00
|
|
|
make || exit 1
|
|
|
|
make install || exit 1
|
|
|
|
|
2008-04-12 06:45:21 +04:00
|
|
|
PATH=$PATH:$installDir/bin
|
|
|
|
export PATH
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
|
|
|
|
# build gcc
|
|
|
|
|
|
|
|
# prepare the include files
|
|
|
|
copy_headers()
|
|
|
|
{
|
|
|
|
sourceDir=$1
|
|
|
|
targetDir=$2
|
|
|
|
|
2008-04-12 06:40:10 +04:00
|
|
|
headers="`find $sourceDir -name \*\.h | grep -v /.svn`"
|
|
|
|
headers="`echo $headers | sed -e s@$sourceDir/@@g`"
|
2005-10-29 20:27:43 +04:00
|
|
|
for f in $headers; do
|
2008-04-12 06:40:10 +04:00
|
|
|
headerTargetDir=$targetDir/`dirname $f`
|
2005-10-29 20:27:43 +04:00
|
|
|
mkdir -p $headerTargetDir
|
|
|
|
cp $sourceDir/$f $headerTargetDir
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
copy_headers $haikuSourceDir/headers/os $tmpIncludeDir/be
|
|
|
|
copy_headers $haikuSourceDir/headers/posix $tmpIncludeDir/posix
|
|
|
|
|
|
|
|
# configure gcc
|
|
|
|
cd $gccObjDir
|
|
|
|
CFLAGS="-O2" CXXFLAGS="-O2" $buildToolsDir/gcc/configure --prefix=$installDir \
|
2008-03-24 02:06:23 +03:00
|
|
|
--target=i586-pc-haiku --disable-nls --enable-shared=yes \
|
2005-10-29 20:27:43 +04:00
|
|
|
--enable-languages=c,c++ --with-headers=$tmpIncludeDir \
|
|
|
|
--with-libs=$tmpLibDir || exit 1
|
|
|
|
|
|
|
|
# hack the Makefile to avoid trouble with stuff we don't need anyway
|
|
|
|
sedExpr=
|
|
|
|
for toRemove in libiberty libio libjava libobjc libstdc++; do
|
|
|
|
sedExpr="$sedExpr -e 's@^\(TARGET_CONFIGDIRS =.*\)$toRemove\(.*\)@\1\2@'"
|
|
|
|
done
|
|
|
|
echo sedExpr: $sedExpr
|
|
|
|
mv Makefile Makefile.bak || exit 1
|
|
|
|
eval "sed $sedExpr Makefile.bak > Makefile" || exit 1
|
|
|
|
rm Makefile.bak
|
|
|
|
|
|
|
|
# make gcc
|
|
|
|
make cross || {
|
|
|
|
echo "ERROR: Building gcc failed." >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# install gcc
|
|
|
|
make install-gcc-cross || {
|
|
|
|
echo "ERROR: Installing the cross compiler failed." >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2008-03-16 19:39:06 +03:00
|
|
|
# Remove the math.h gcc header. It has been generated by fixincludes
|
|
|
|
# (unconditional hack: math_huge_val_ifndef) from ours and it is semantically
|
|
|
|
# equivalent.
|
2008-03-24 02:06:23 +03:00
|
|
|
rm $installDir/lib/gcc-lib/i586-pc-haiku/$haikuRequiredLegacyGCCVersion/include/math.h
|
2008-03-16 19:39:06 +03:00
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
# cleanup
|
|
|
|
|
|
|
|
# remove the system headers from the installation dir
|
|
|
|
# Only the ones from the source tree should be used.
|
2008-03-24 02:06:23 +03:00
|
|
|
sysIncludeDir=$installDir/i586-pc-haiku/sys-include
|
2005-10-29 20:27:43 +04:00
|
|
|
rm -rf $sysIncludeDir/be $sysIncludeDir/posix
|
|
|
|
|
|
|
|
# remove the objects dir
|
|
|
|
rm -rf $objDir
|
|
|
|
|
|
|
|
|
|
|
|
echo "binutils and gcc for cross compilation have been built successfully!"
|
|
|
|
|