SEP
28
2004

So long autotools!

So I am fed up with autotools. Its possibly the worst possible build system I have ever had the displeasure of being abused by. Its probably because I never got into m4 macros, or testing the size of an int of my machine every time I try to build a project. So finally with the arrival of Package Config and QMake I can rid myself of this horrible mess.


Anyone looking at the QMake documentation might discount it immediately as a serious build system. Since its VERY simple.
SOURCE += main.cpp
CONFIG += application debug thread

Is a very simple case. Even the "CONFIG" portion is optional though because it will use the current Qt configuration if none is specified.


"So okay I can build Qt apps, what about KDE apps?" you might ask. Well this is where a neat application kde-config comes into play.
This application will tell us all sorts of things about kde as long as the binary is in our path.
kde-config --expandvars --install lib will return location of the KDE libraries live. To get a full list of all the path elements kde-config returns just issue a kde-config --types.


Now with this handy program we can use the system( ) directive in QMake to populate things like our include paths.
QMAKE_LIBDIR+=$$system(kde-config --expandvars --install lib)
LIBS += -lkdecore -lkdeui
# For KDE 3.3
KDEPREFIX=$$system(kde-config --prefix)
INCLUDES += $$KDEPREFIX/include $$KDEPREFIX/include/kde
# For KDE 3.4
INCLUDES += $$system(kde-config --expandvars --install headers)
CONFIG += debug
SOURCE += main.cpp kdeapp.cpp
HEADERS += kdeapp.h

One other thing to note, since we don't have the brain damages of autotools to deal with anymore, the #include "kdeapp.moc" is no longer needed to get the appropriate moc files generated.


I have imported one template into KDevelop cvs for those who are on the bleeding edge. If you dig into QMake you can find tons of neat helper functions, custom compiler directives, libtool and package config support. It's really a worth while thing for developers to look at. If for nothing else than the ability to remove almost 2mb of useless crap from your source project, or the issue of new versions of autotools trashing your precious admin directory thats deprecated long before you get it... Build systems are evil, but some are less evil than others.

Comments

how is using QMake and established tool for some years reinventing?

besides autotools runs under mingw/cygwin already and can be told to use non-gcc compilers (export CC=cl.exe && export CXX=cl.exe ) its neat try it.

really this isn't that hard, it just takes a minor bit of talent at reading. we where using autotools here under mingw to build Qt/C++ stuff back when we still thought TMake was junk. The problem with autotools is it just bogs down the build system terribly.


By Ian Reinhart Geiser at Tue, 09/28/2004 - 23:13

Pages