Libcurl

1. Get the source
Get libcurl from http://curl.haxx.se/ (I got curl-7.19.5.tar.gz)
Need libssh2 see libssh2 cross compilation tutorial
Get gnutls http://www.gnu.org/software/gnutls/ (need to use version prior to 2.8 so I used 2.6.6)
Get also libtasn1
(optional openssl support : http://www.openssl.org/ (I used openssl-0.9.8k)

2. Extract sources

3. Build libtasn1
My compilation environnement:
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS3.0.sdk
export CC=$DEVROOT/usr/bin/gcc
export LD=$DEVROOT/usr/bin/ld
export CPP=$DEVROOT/usr/bin/cpp
export CXX=$DEVROOT/usr/bin/g++
export AR=$DEVROOT/usr/bin/ar
export AS=$DEVROOT/usr/bin/as
export NM=$DEVROOT/usr/bin/nm
export CXXCPP=$DEVROOT/usr/bin/cpp
export RANLIB=$DEVROOT/usr/bin/ranlib
export LDFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -L/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/lib"
export CFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/include"
export CXXFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/include/"

Configure:
./configure --host=arm-apple-darwin9 --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --enable-shared=no

Make and make install

4. Build gnutls
I first try with a recent version of gnutls (2.8.1) but I is not properly detected by curl (because it uses libgnutls-config, removed by version >= 2.8)

My compilation environnement (same as previous)

Configure:
./configure --host=arm-apple-darwin9 --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --enable-shared=no --with-libgcrypt-prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os

When I tried to do 'make', I got one error in 'ld' step.
I googled the missing symbol and got to this page:
http://forum.filezilla-project.org/viewtopic.php?f=3&t=9417
I tried the following patch:
http://filezilla-project.org/codesquid/gnutls.patch
but it did not work.

So I edit lib/gnutls_global.c and I change the following line
LOG_FUNC _gnutls_log_func;
to :
LOG_FUNC _gnutls_log_func = NULL;

Then make and make install


2 bis : Build openssl if needed
My compilation environnement:
export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS3.0.sdk
export CC=$DEVROOT/usr/bin/gcc
export LD=$DEVROOT/usr/bin/ld
export CPP=$DEVROOT/usr/bin/cpp
export CXX=$DEVROOT/usr/bin/g++
export AR=$DEVROOT/usr/bin/ar
export AS=$DEVROOT/usr/bin/as
export NM=$DEVROOT/usr/bin/nm
export CXXCPP=$DEVROOT/usr/bin/cpp
export RANLIB=$DEVROOT/usr/bin/ranlib
export LDFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -L/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/lib"
export CFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/include"
export CXXFLAGS="-arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT -I/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/include/"

Openssl is a little bit different so I first try to do the configure with:
./config --openssldir=/Users/olivier/Documents/IphoneDevProjects/3rdParty/build-os/ --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/build-os/

And then, i edit the Makefile.
If first remove the "CC= cc" because CC is now defined in environment variable)
I replace "-arch i386" by "$(CFLAGS)" in CFLAG definition
I replace "-arch i386" by "$(LDFLAGS") in SHARED_LDFLAGS definition

Try the make
It should fail so edit the file "crypto/ui/ui_openssl.c" ; go to line 403 and replace
static volatile sig_atomic_t intr_signal;
by
static volatile int intr_signal;

Now, you can build it with make and make install.

3. Build libcurl
My compilation environnement (same as previous)

Then the configure:
./configure --host=arm-apple-darwin9 --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --enable-shared=no --with-libssh2=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --with-gnutls=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --without-ssl

If you want OPENSSL support, please use the following :
./configure --host=arm-apple-darwin9 --prefix=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --enable-shared=no --with-libssh2=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --with-gnutls=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --with-libssh2=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --with-ssl=/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os --with-random=/dev/urandom

Like this, it does not work !
I don't know why but libgnutls-config --libs does not include -ltasn1 so I manually add it.
I modify the scripts to add "-ltasn1" to gnutls_libs variable.
In my configuration, this script is at:
/Users/olivier/Documents/IphoneDevProjects/3rdParty/iphone-os/bin/

Now, you can execute the same configure and you will be able to use gnutls !!

Make and make install