
This document describes
how to to install a cross-compiler toolchain to build XCA

--------------------------------------

export TARGET=i686-apple-darwin10
export PREFIX=/opt/mactry
export SDK=${PREFIX}/SDKs/MacOSX10.6.sdk
export PATH=$PATH:${PREFIX}/bin
export INSTALL_DIR=`pwd`/install


# Build xar from http://code.google.com/p/xar/downloads/list
##########################################

tar zxf xar-1.5.2.tar.gz
cd xar-1.5.2
./configure
make -j4
sudo make install

# install dmg2img
sudo aptitude install dmg2img hexdump pax

# Download xcode_3.2.2_and_iphone_sdk_3.2_final.dmg
# Go to developer.apple.com and create a free account for yourself,
# download Xcode 3.x.y
#
# unpack Xcode SDK
################################################

dmg2img xcode_3.2.2_and_iphone_sdk_3.2_final.dmg

mkdir mnt
sudo modprobe hfsplus

# calculate the beginning of the image
(echo ibase=16; dd if=xcode_3.2.2_and_iphone_sdk_3.2_final.img bs=1024 count=1024 2>/dev/null |hexdump -C | grep "48 2b 00 04" |sed 's/ .*/-400/') | bc

# in my case 36864
sudo losetup -o 36864 /dev/loop0 xcode_3.2.2_and_iphone_sdk_3.2_final.img
sudo mount -t hfsplus /dev/loop0 mnt

xar -xv -f mnt/Packages/MacOSX10.6.pkg Payload
zcat Payload | (cd $PREFIX; cpio -id)

sudo umount mnt/
sudo losetup -d /dev/loop0

rm -f $SDK/Library/Frameworks
ln -s $SDK/System/Library/Frameworks $SDK/Library/

# Download qt-mac-opensource-4.6.2.dmg from Nokia
#
###############################################

dmg2img qt-mac-opensource-4.6.2.dmg

# calculate the beginning of the image
(echo ibase=16; dd if=qt-mac-opensource-4.6.2.img count=1024 count=1024 2>/dev/null |hexdump -C | grep "48 2b 00 04" |sed 's/ .*/-400/') | bc
# 32768 in my case

sudo losetup -o 32768 /dev/loop0 qt-mac-opensource-4.6.2.img
sudo mount -t hfsplus /dev/loop0 mnt

zcat mnt/packages/Qt_libraries.pkg/Contents/Archive.pax.gz | (cd $SDK/System; pax -rv )
zcat mnt/packages/Qt_headers.pkg/Contents/Archive.pax.gz | (cd $SDK/System; pax -rv )
zcat mnt/packages/Qt_plugins.pkg/Contents/Archive.pax.gz | (cd $SDK; pax -rv )

sudo umount mnt/
sudo losetup -d /dev/loop0


#
# build odcctools
#
####################

svn co http://svn.macosforge.org/repository/odcctools/trunk odcctools
# Checked out revision 159.

cd odcctools
./extract.sh
cd odcctools
patch -p1 < ../../odcctools.diff

./configure \
	--prefix=${PREFIX} \
	--target=${TARGET} \
	--with-sysroot=${SDK} \
	--enable-as-targets="i386 x86_64"

make -j3 && make install

#
# install the toolchain
#
##############

tar zxf gcc-5659.tar.gz
patch -p0 <gcc-5659.patch

mkdir gcc-build-5659-new
cd $_


../gcc-5659/configure \
	--target=${TARGET} \
	--prefix=${PREFIX} \
	--with-headers=${SDK}/usr/include \
	--with-libs=${SDK}/usr/lib \
	--with-build-sysroot=${SDK} \
	--enable-languages=c,c++ \
	--with-as=${PREFIX}/bin/${TARGET}-as \
	--with-ld=${PREFIX}/bin/${TARGET}-ld \
	--disable-nls \
	--disable-multilib \
	--enable-version-specific-runtime-libs \
	--with-gxx-include-dir=${SDK}/usr/include/c++/4.2.1 \
	--without-libgloss --without-newlib

make -j3 && make install

#
# XCA
###########################

cd xca

cp misc/Local.mak.mac Local.mak
# edit Local.mak if needed

make -j3 xca.app


