lighty's life

lighty developer blog

1.5.0 Goes Cmake

It is a tradition now to change the build-system from lighttpd on each major release
For now we have the autotools as the user-visible build-system and scons as the system for the developers.

Currently we are testing cmake as a replacement for the scons part.

Build Systems

Before you can build a C-program you first have to find out which functions the system you compile on supports. Not only that UNIX has various flavours, no, there is also Windows.

The natural way on UNIX is using autotools (autoconf, automake, …) which creates a shell script (configure) which generates the Makefiles which are process by make to build the application.

Using automake reduced the pain of autoconf when it was released, but it none the less is still enough pain to look for something else. Not to forget that win32 and shell-scripts aren’t real friends.

scons

SCons going another route. It replaces make and the autotools by a python based build-system. You can do everything with just a few lines of python code. Very neat.

The bad side: its development is more or less sleeping. The unstable 0.96.9x branch which fixes various nasty bugs is unstable since 2004-08-22, the release of 0.96.1.

cmake

cmake is more relaxed and doesn’t want to solve the whole problem. It does the configure checks and leaves the building to the native build-system. On Unix it is either make or kdevelop3, on MacOSX it is XCode and on windows it is nmake.

As extra cmake supports basic packaging and has very nice integration with test-tools like Dart.

Cross-Compiling

As a proof-of-concept I’ve added cmake support to trunk used the openwrt SDK to build lighttpd with openwrt.

$ cmake .
$ rm CMakeCache.txt
$ OPENWRT=.../OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/ \
CC=$OPENWRT/bin/mipsel-linux-gcc \
LD=$OPENWRT/bin/mipsel-linux-uclibc-ld make

Command Line Options

$ cmake -L .
...
CMAKE_INSTALL_PREFIX:PATH=
...
WITH_BZIP:BOOL=OFF
WITH_MYSQL:BOOL=OFF
WITH_OPENSSL:BOOL=OFF
WITH_PCRE:BOOL=ON
WITH_SQLITE3:BOOL=OFF
WITH_WEBPAV_PROPS:BOOL=OFF
WITH_XATTR:BOOL=OFF
WITH_ZLIB:BOOL=ON
$ cmake -DWITH_BZIP:BOOL=ON \
-DCMAKE_INSTALL_PREFIX:PATH=/home/jan/l-1.5.0-cmake/

Static Linking

To make it easier for embedded systems which don’t have support for dlopen() I added the option:

$ cmake -DBUILD_STATIC:BOOL=ON .

It will build all the modules as static libraries which are linked into the server at build-time. server.modules is used to initialized the modules as before.

lighttpd

Enable javascript to load comments.

Please note that we won't accept comments for posts older than 3 months! Also please use our bug tracker to report bugs, and our irc channel #lighttpd@freenode to chat.

« Faster Web 2.0 Voy a Buenos Aires »