Table of Contents
Buildtool can be configured on a host basis by using system wide configuration files, all of them placed in the configuration directory choosed at installation time[6]. The following files will be recognized and used if placed inside it:
File read by the bt_config module before starting the configuration process of a source package. This file is specially useful to add system wide default values for variables (like the installation prefix or directories, location of programs, etc.) and to store check results, to avoid checking for the same thing over and over again (i.e., the C compiler). This file is a shell script.
File read by the bt_logic module before applying any stage to a source package. This file may be useful to add system wide hooks to stages (like emailing the administrator after a program has been installed, registering it in a database, etc.). This file is a shell script.
Both configuration files are plain text files that can be modified with any text editor. Even though, it may become a very tedious task to keep bt_config.conf up to date, according to check results if you are interested in caching them. The bt_swcgen module included in Buildtool will help you in the generation of such file, and will take care to keep it up to date with a simple command.
This chapter describes how to use the bt_swcgen utility to automatically generate a system wide bt_config.conf configuration file.
buildtool swcgen [ -h | --help ] [ -i file | --input=file ] [ -o file | --output=file ]
The bt_swcgen module is used to automatically generate a configuration file for bt_config, including cached results for common checks usually issued in your system. The output file is generated using a special script as input.
The input file calls several functions that execute configuration checks and store the results in the cache file. These functions hide the complexity of the cache system (this means that it might change without notice, as you are expected to use this module as a frontend).
The module issues the following steps to generate the output file:
The bt_wizard module (see Chapter 16, The project wizard) is used to create a template package under the /tmp/ directory. If, by some reason, the temporary name used already exists, the process will be aborted.
The input file is executed in script mode. This creates a regular configuration script, which is later placed in the template package previously created.
The input file is executed in conf mode to generate a configuration file containing a set of lines that will be replaced with check results using bt_output.
The template package is configured using the bt_config module (see Chapter 4, Automatic package configuration), skipping the system wide configuration file if it existed. This executes all checks specified in the input file, which will be cached.
The output file is generated according to results obtained by the configuration process, and is installed in the target location.
By default, both input and output files are located under the system wide configuration directory you selected when installing Buildtool. The former is called bt_config.conf.in and the later bt_config.conf, as you could expect.
The following options are recognized:
-h | --help
Shows an useful help message, listing all available options and default values for both input and output files.
-i file | --input=file
Sets the input file name.
-o file | --output=file
Sets the output filename.
The input file is a regular shell file which calls some specific functions. Therefore, it can contain conditionals, loops, comments or anything else supported by the shell interpreter. The file should follow the following structure:
# bt_config.conf.in input file # Calls to detect and cache development environments # Calls to detect and cache programs # Calls to detect and cache compiler features # Calls to detect and cache headers # Calls to detect and cache libraries # Other miscellaneous shell stuff
Due to the simple design of the program, if you are going to check for compiler features, headers and/or libraries, you must check for both C and C++ development environments at the very beginning.
The configuration file should only carry cache results for things that are unlikely to change in your system as time passes. For example, it is a good idea to cache type sizes, basic programs (like the compiler, the M4 processor, etc.). But caching less common things (like Gtk) that can easily change during updates or software maintenance will bring you problems, as the cache file will get out of sync.
The default configuration file provided by the module contains usually a good selection of things to check; follow its guidelines. It is also a good practice to run this module from cron periodically so the cache is updated without disturbing users.
This section describes all the functions that can be used when writting the input file.
Detects and caches the result of the bt_check_attribute check. See Section 11.7.6.5, “The attribute keyword”.
Detects and caches all results coming from a development environment detection. Recognized values include c and cxx. See Section 11.7.1, “Checking for build environments”.
Detects and caches all results coming from a function detection using the bt_check_func check. See Section 11.7.4.1, “Generic functions”.
Detects and caches all results coming from a C/C++ header file detection using the bt_check_hdr check. See Section 11.7.3.1, “Generic headers”.
Detects and caches all results coming from a C/C++ library detection using the bt_check_lib check. See Section 11.7.5.2, “Generic libraries”.
Detects and caches how to build libraries for the current host, that is, all results coming from the the bt_check_lib_howto check. See Section 11.7.5.1, “The library howto”. Note that this macro is automatically called when caching build environments, so you should not call it directly.
Detects and caches all results coming from a program detection using the bt_check_progs check (as well as specific checks to detect programs). See Section 11.7.2, “Checking for programs”.
Detects and caches all results coming from a C/C++ type size detection using the bt_check_sizeof check. See Section 11.7.6.2, “Size of C/C++ types”.
Detects and caches all results coming from a C/C++ type detection using the bt_check_type check. See Section 11.7.6.1, “Presence of C/C++ types”.
Writes the given lines (each one as a separate argument) to the output file literally. This lets you define single extra variables by hand, or whatever else you want.
Writes a copy of the given files to the output file. If no arguments are provided, it picks up data sent through stdin; this is a very convenient way to add multiple lines to the output file (without using bt_echo).
[6] This directory will usually be /etc/buildtool/ on most Linux based systems, but will probably change on BSD systems and others.