1.5.0 goes cmake 5

Posted by jan Mon, 25 Dec 2006 20:37:00 GMT

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 goes scons 2

Posted by jan Tue, 27 Sep 2005 10:31:00 GMT

In my daily work at MySQL I added scons as the build-system for a cross-platform, multi-language project and am very satisfied with the results. We have Unix, Windows and MacOS X as build-platforms and Java, C, PHP and Perl as programming languages and all works nicely together in a Python written build-system.

lighttpd goes now the same way, solving the nasty autotools dependencies.

Autotools are a pain for two reasons:

  1. version incompatibilities
  2. it takes ages to rebuild the Makefiles and configure script
  3. the installation of modules via libtool takes ages too
  4. using m4 and sh as the lowest dominator

and waiting for a installation process to finish is lost time.

What is good at autotools ?
  1. make distcheck is great
  2. perfect integration into rpm building
  3. cross-compiling
  4. self-contained for a non-devs

As long as we don’t have a replacement for the ‘pro’ arguments in scons we will not drop autotools. They do there job in packaging and testing very well. But for building and developing lighttpd I’ll use scons.

The scons build-system is already in the SVN tree. It replaced autotools (automake, autoconf, libtool) and (g)make by one central tool.

You need

  1. python 2.2.x or higher
  2. scons 0.96.1 or higher
$ cp config.py config.py-sample
(adjust the features and paths)
$ scons install
  1. the checks for libraries, headers and functions are executed as ./configure did before
  2. the main binary is built
  3. the modules are created
  4. everything is installed
What else should you know about scons ?
$ scons -c  [for a 'make clean']
$ scons check  [for a 'make check']
$ cd src; scons -u [for a 'make' in the 'src/' directory]

In the near future autotools won’t be dropped in lighttpd. Up to now it was only tested with gcc and linux. It will need some time until everything is ported to scons, but it is worth it. Especially for the new devs struggling with autotools and there syntax and the old-devs who spend days just with waiting.