⛏️ index : buildtools.git

author Jérôme Duval <jerome.duval@gmail.com> 2012-03-18 15:31:41.0 +01:00:00
committer Jérôme Duval <jerome.duval@gmail.com> 2012-03-18 15:31:41.0 +01:00:00
commit
e9b8ca373a2f0b7a598718b3618140145554d4fb [patch]
tree
822c99ab12c6d14a3bdd6cd6f6878c5eeecd09d9
parent
a2012848e3c628083a37416cb7ccc351d42fbb1e
download
e9b8ca373a2f0b7a598718b3618140145554d4fb.tar.gz

updated optional package build script for gcc4 to make a cross compiler.

* --arch sets the target arch, defaults to x86
* --source-dir sets the Haiku root directory for headers.
* tested with ppc.

Diff

 build-gcc4-optional-package-Haiku.sh | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 66 insertions(+), 22 deletions(-)

diff --git a/build-gcc4-optional-package-Haiku.sh b/build-gcc4-optional-package-Haiku.sh
old mode 100755
new mode 100644
index bfdccaa..753b1be
--- a/build-gcc4-optional-package-Haiku.sh
+++ a/build-gcc4-optional-package-Haiku.sh
@@ -20,14 +20,40 @@
buildDir="$currentDir/gcc-objects"
binutilsBuildDir="$buildDir/binutils"
gccBuildDir="$buildDir/gcc"
targetArch=x86
gccMakeTarget=bootstrap
gccConfigureArgs="--enable-shared"
binutilsConfigureArgs="--enable-shared=true"


# parse the arguments
jobArgs=
while [ $# -gt 0 ]; do
	case "$1" in

		-h|--help)	usage; exit 0;;
		-j*)		jobArgs="$1"; shift 1;;
		--arch)
			case "$2" in

				x86)	HAIKU_GCC_MACHINE=i586-pc-haiku;;
				x86_64)	HAIKU_GCC_MACHINE=x86_64-pc-haiku; targetArch=x86_64;
						gccMakeTarget= ;;
				ppc)	HAIKU_GCC_MACHINE=powerpc-apple-haiku; targetArch=ppc;
						gccMakeTarget= gccConfigureArgs="--disable-shared --disable-multilib"
						binutilsConfigureArgs="--disable-shared --disable-multilib" ;;
				m68k)	HAIKU_GCC_MACHINE=m68k-unknown-haiku; targetArch=m68k;
						gccMakeTarget= gccConfigureArgs="--disable-shared --disable-multilib"
						binutilsConfigureArgs="--disable-shared --disable-multilib" ;;
				arm)	HAIKU_GCC_MACHINE=arm-unknown-haiku; targetArch=arm;
						gccMakeTarget= gccConfigureArgs="--disable-shared --disable-multilib"
						binutilsConfigureArgs="--disable-shared --disable-multilib" ;;
				mipsel)	HAIKU_GCC_MACHINE=mipsel-unknown-haiku; targetArch=mips;
						gccMakeTarget= gccConfigureArgs="--disable-shared --disable-multilib"
						binutilsConfigureArgs="--disable-shared --disable-multilib" ;;
				*)		echo "Unsupported target architecture: $2"
						exit 1;;
			esac
			shift 2
			targetCrossToolsMachine="--target=${HAIKU_GCC_MACHINE}";;
		--source-dir)	haikuSourceDir="$2"; shift 2;;
		*)			break;;
	esac
done
@@ -55,18 +81,10 @@
fi

gccVersionedName=gcc-${gccVersion}-haiku-${gccDate}


# get the architecture
gccArch=`uname -m`
case $gccArch in
	BePC)	gccArch=x86;;
	*)		echo "Unsupported architecture: '$gccArch'" >&2; exit 1;;
esac


# check whether the installation dir does already exit
installDir=/boot/develop/abi/$gccArch/gcc4/tools/$gccVersionedName
installDir=/boot/develop/abi/$targetArch/gcc4/tools/$gccVersionedName
if [ -e "$installDir" ]; then
	echo "The installation directory '$installDir' does already exist." >&2
	echo "Remove it first." >&2
@@ -78,6 +96,7 @@
echo "Building binutils and gcc optional packages from the source."
echo "sources:     $buildtoolsDir"
echo "build dir:   $buildDir"
echo "target arch: $targetArch"
echo "GCC date:    $gccDate"
echo "GCC version: $gccVersion"
echo "install dir: $installDir"
@@ -98,19 +117,44 @@
# build and install the binutils
cd "$binutilsBuildDir"
CFLAGS="-O2" CXXFLAGS="-O2" "$binutilsSources/configure" \
	--prefix="$installDir" --disable-nls --enable-shared=yes \
	--with-htmldir=html-docs
	--prefix="$installDir" $targetCrossToolsMachine --disable-nls \
	$binutilsConfigureArgs --with-htmldir=html-docs
make $jobArgs
make install install-html

# prepare the include files
copy_headers()
{
	sourceDir=$1
	targetDir=$2

	headers="$(find $sourceDir -name \*\.h | grep -v /.svn)"
	headers="$(echo $headers | sed -e s@$sourceDir/@@g)"
	for f in $headers; do
		headerTargetDir=$targetDir/$(dirname $f)
		mkdir -p $headerTargetDir
		cp $sourceDir/$f $headerTargetDir
	done
}

if [ -n "$haikuSourceDir" ]; then
	tmpIncludeDir=$currentDir/sysincludes
	tmpLibDir=$currentDir/syslibs
	mkdir -p $tmpIncludeDir $tmpLibDir
	copy_headers $haikuSourceDir/headers/config $tmpIncludeDir/config
	copy_headers $haikuSourceDir/headers/os $tmpIncludeDir/os
	copy_headers $haikuSourceDir/headers/posix $tmpIncludeDir/posix
	headersLibsArgs="--with-headers=$tmpIncludeDir --with-libs=$tmpLibDir"
fi

# build and install gcc
cd "$gccBuildDir"
CFLAGS="-O2" CXXFLAGS="-O2" "$gccSources/configure" \
	--prefix="$installDir" --enable-shared --enable-languages=c,c++ \
	--disable-nls --without-libiconv-prefix --disable-libstdcxx-pch \
	--with-htmldir=html-docs --enable-frame-pointer
make $jobArgs bootstrap
	--prefix="$installDir" $gccConfigureArgs --enable-languages=c,c++ \
	$targetCrossToolsMachine --disable-nls --without-libiconv-prefix \
	--disable-libstdcxx-pch --with-htmldir=html-docs --enable-lto \
	--enable-frame-pointer $headersLibsArgs
make $jobArgs $gccMakeTarget
make install-strip install-html


@@ -134,7 +178,7 @@
gccVersionYear=20$(echo $gccDate | cut -c1-2)
gccVersionMonth=$(echo $gccDate | cut -c3-4)
gccVersionDay=$(echo $gccDate | cut -c5-6)
packageFile="$currentDir/gcc-${gccVersion}-${gccArch}-gcc4-${gccVersionYear}-${gccVersionMonth}-${gccVersionDay}.zip"
packageFile="$currentDir/gcc-${gccVersion}-${targetArch}-gcc4-${gccVersionYear}-${gccVersionMonth}-${gccVersionDay}.zip"

cd /boot
zip -ry "$packageFile" `echo $installDir | cut -d/ -f3-`
@@ -142,16 +186,16 @@

# add the "current" version symlink
cd "$buildDir"
mkdir -p develop/abi/x86/gcc4/tools/
ln -s $gccVersionedName develop/abi/x86/gcc4/tools/current
zip -y "$packageFile" develop/abi/x86/gcc4/tools/current
mkdir -p develop/abi/$targetArch/gcc4/tools/
ln -s $gccVersionedName develop/abi/$targetArch/gcc4/tools/current
zip -y "$packageFile" develop/abi/$targetArch/gcc4/tools/current


# add the optional package description
cd "$buildDir"
echo "Package:		GCC
Version:		${gccVersion}-haiku-${gccDate}
Copyright:		1988-2011 Free Software Foundation, Inc.
Version:		${gccVersion}-${targetArch}-haiku-${gccDate}
Copyright:		1988-2012 Free Software Foundation, Inc.
License:		GNU GPL v3
License:		GNU LGPL v3
URL:			http://www.gnu.org/software/gcc/