Friday 10 October 2008

Compiling lighttpd for iphone

After writing my own ftp server for my app, I decided that webdav was a way better solution as so many have found out.  Using the instructions at http://latenitesoft.blogspot.com/2008/10/iphone-programming-tips-building-unix.html
and with the help of Alice at http://gothcandy.com/alice/2007/09/05/81/porting-lighttpd-to-the-iphone/   I think I have it compiling, but after all that, I wonder if its actually useful to me....
doh!
anyway here's the shell script to compile..
you also need to copy in 2 header files from the simulator to let it compile..
these are 

/bzlib.h and crt_externs.h

If anyone has some advice how I could incorporate this into an app, do let me know.
cheers


#/bin/bash

export DEVROOT=/Developer/Platforms/iPhoneOS.platform/Developer
export SDKROOT=$DEVROOT/SDKs/iPhoneOS2.1.sdk
export SIMROOT=/Developer/Platforms/iPhoneSimulator.platform

# Save relevant environment
U_CC=$CC
U_CFLAGS=$CFLAGS
U_LD=$LD
U_LDFLAGS=$LDFLAGS
U_CPP=$CPP
U_CPPFLAGS=$CPPFLAGS

export CPPFLAGS="-I$SDKROOT/usr/lib/gcc/arm-apple-darwin9/4.0.1/include/ -I$SDKROOT/usr/include/"
# -I$SIMROOT/Developer/SDKs/iPhoneSimulator2.1.sdk/usr/include/"
export CFLAGS="$CPPFLAGS -arch armv6 -pipe -no-cpp-precomp -isysroot $SDKROOT"
export CPP="/usr/bin/cpp $CPPFLAGS"

# dynamic library location generated by the Unix package
#LIBPATH=src/.libs/.dylib
#LIBNAME=`basename $LIBPATH`
#,-dylib_install_name,@executable_path/$LIBNAME"
export LDFLAGS="-L$SDKROOT/usr/lib/ -Wl,-dylib_install_name,@executable_path/$LIBNAME"


echo $CPPFLAGS
echo $LDFLAGS
read -p "Press a key"

# static library that will be generated
LIBPATH_static=src/.libs/lighttpd.a
LIBNAME_static=`basename $LIBPATH_static`

./configure CC=$DEVROOT/usr/bin/arm-apple-darwin9-gcc-4.0.1 LD=$DEVROOT/usr/bin/ld --host=arm-apple-darwin -without-pcre

# --libdir=$SDKROOT/usr/lib/ --includedir=$SDKROOTk/usr/include/
make



#mkdir -p lnsout
#cp $LIBPATH_static lnsout/$LIBNAME_static.arm
exit



4 comments:

Unknown said...

You'll need to remove the .a from LIBPATH_static=src/.libs/lighttpd.a as lighttpd doesn't compile as a library, but as an executable. Which will need to be launched using NSTask. Also, all the modules (e.g. mod_webdav) will need to be run through lipo in order to create fat binaries for use in the simulator and on the iPhone/iPod touch.

Anonymous said...

NSTask doesnt exist on the phone as far as i know.

Unknown said...

I've heard that if you just copy the NSTask.h from the simulator, it will work. Plus, Air Sharing uses lighttpd with webdav, so it must be possible to start it up somehow.

Anonymous said...

it wont compile to static fully, so it still ends up with dylib. I think the work of incorporating it into an app is a little more involved.