Modular configuration

Alexander Neundorf neundorf at kde.org
Mon Oct 17 19:25:44 CEST 2005


Hi,

On Monday 17 October 2005 16:09, David Faure wrote:
> On Monday 17 October 2005 15:46, Nagy Thomas wrote:
> > What about a hashtable in SConstruct, like this:
> >
> > conftests = {
> > "lowlevel" : ["sys.h", "otherheader.h"]
> > "libxml" : ["someheader.h"]
> > }
> >
> > env=configure(config, conftests)
>
> This solves the "too much code to write for each test" problem [for header
> files], but it doesn't make the thing "modular".
>
> I want the configure checks needed by kdepim/kmail/ to be inside
> kdepim/kmail/, so that if kmail moves to another module, they would go with
> it. And it will be clear that those checks are for kmail, whereas if they
> are in the toplevel SConstruct, all apps will be mixed up there.
>
> Also, headers are only one part of the problem. We must also check
> for the presence of C functions (getmntent, mmap, etc.), but the syntax
> above only allows for header files.

Just FYI, here's how it's done with cmake (from my experience building KDE3 
kdelibs/). Maybe it can serve as input on how to implement it for scons. You 
just put the tests you need in the CMakeLists.txt file in the directory where 
you need them. The tests will be executed during the cmake run (i.e. the 
first time and everytime cmake runs again due to changes in the 
CMakeLists.txt files). The results are cached in the CMakeCache.txt file.

Write what you need in the CMakeLists.txt in the appropriate directories:

#check for the existence of headers:
#check_include_files and check_function_exists are macros devided by cmake
check_include_files(alloca.h      HAVE_ALLOCA_H)
check_include_files(sys/mnttab.h  HAVE_SYS_MNTTAB_H)
check_include_files(mntent.h      HAVE_MNTENT_H)

#check for the existence of functions:
check_function_exists(strlcpy    HAVE_STRLCPY)
check_function_exists(strlcat    HAVE_STRLCAT)
check_function_exists(volmgt     HAVE_VOLMGT)

#and write the result into a config.h:
configure_file (${CMAKE_SOURCE_DIR}/config.h.in {CMAKE_BINARY_DIR}/config.h)

whereas config.h.in looks like:

#cmakedefine HAVE_ALLOCA_H
#cmakedefine HAVE_SYS_MNTTAB_H
#cmakedefine HAVE_MNTENT_H
#cmakedefine HAVE_STRLCPY
#cmakedefine HAVE_STRLCAT
#cmakedefine HAVE_VOLMGT

Bye
Alex
-- 
Work: alexander.neundorf at jenoptik.com - http://www.jenoptik-los.de
Home: neundorf at kde.org                - http://www.kde.org
      alex at neundorf.net               - http://www.neundorf.net


More information about the Kde-buildsystem mailing list