Project description
The
project
block defines global properties and requirements for the project.
Unlike rule files, this block is not purely declarative and there may only be
one. While the rule translator is free to move around declarations, the project
block defines an order in which requirements are tested. This order is honoured
by the translator.
project 'MakePP' { version: '0.1' contact: 'makepp@xinutec.org' config_header: config.h section 'some checks' { ... } }
section
Configure time checks are grouped in sections for better readability. Each section is introduced with a message in the configure script output.
library
In a
project
context,
library
checks whether a library is installed and a
program can be linked against it.
# GNU Multiprecision Library, can be disabled with --without-gmp, # if all targets defined in Rules files that link to it are optional. library gmp { symbol: mpz_init header: gmp.h # You may optionally add a description to each check. This will cause it # to appear in the summary at the end of a configure run. 'Build with GNU Multiprecision Library support' }
The above
library
directive defines the following variables:
- $gmp_available
A shell variable is defined in the configure script with the value
"yes"
or"no"
. The variable name is normalised, i.e. any character that is not a valid shell identifier (such as '-') is transliterated to '_'. - GMP
An uppercased and normalised version of the library name is provided as an
automake
conditional. It can therefore be used in rules files in conditional contexts or in includedautomake
rule files. - GMP_AVAILABLE
An uppercased and normalised version suffixed with
_AVAILABLE
is provided in the config header, so that C code can conditionally compile parts based on library availability. This macro is defined to 0 or 1.
headers/functions
The
headers
section can be used to check for additional headers.
functions
checks whether a list of functions is available.
headers { # Valgrind runtime support valgrind/valgrind.h } functions { # New POSIX signal handling sigaction }
This directive only defines
HAVE_
variables in the config header.
arg_enable
This directive adds an option to the resulting configure script. The content of
this directive is a descriptive string that is shown when configure is passed
--help
, followed by more directives that are evaluated if the argument is
yes
. A default may be given. This default may be
yes
or
no
or a
backtick-string, which is evaluated at configure time. Thus, the following two
are equivalent:
arg_enable my-sub-package = yes { 'Also build sub-package' } arg_enable my-sub-package = `echo yes` { 'Also build sub-package' }
This adds the option
--enable-my-sub-package
and defines the following
variables:
- $my_sub_package_enabled
A normalised version of the argument name is set to the passed value. This variable is added to the configure script.
- MY_SUB_PACKAGE
An automake conditional is created, as well. This means that a previously asserted condition, e.g. the existence of a library, can be explicitly disabled by the user. Thus, by adding
arg_enable gmp
, you can let the user decide explicitly that even though GMP is available, he does not want to build any component that uses it. - MY_SUB_PACKAGE_ENABLED
Analogously to the config header macro set by the
library
directive, thearg_enable
directive sets a macro with an normalised and uppercased name to 0 or 1, depending on the user's choice.
options
Instead of a yes/no, you can define your own options.
arg_enable app = iphone { 'Build an app for this software. Only one app can be chosen' options { android => { # check for additional libraries } iphone => { warning 'Support for iPhones is unstable.' } no => { # no app is being built } # optional catch-all option _ => { error 'No support for the $app phone planned.' } } }
The defined variables and macros are the same as with the normal yes/no
arg_enable
, except that the config header gets one macro per option, which is
defined to 1 if that option is selected. Thus,
--enable-app=android
will
define
APP_ANDROID
to 1.
cflags
The
cflags
directive tries to compile a simple program with the passed flags
and adds them to the named variable or
CFLAGS
by default.
# Adds to CFLAGS cflags { -pipe -ggdb3 -pedantic -ansi } # Adds to HIDDEN_CFLAGS cflags HIDDEN_CFLAGS { -fvisibility=hidden }
Each of the flags is tested separately in the order listed. The set added to the variable is the subset of flags that work together.
Additional checks
These are checks from autoconf. They translate to
AC_
followed by the check
name, uppercased.
- c_bigendian
- c_typeof
- alignof
Translates to
AC_CHECK_ALIGNOF
. - sizeof
Translates to
AC_CHECK_SIZEOF
.
The following are new:
- c_charset
Defines
HAVE_EBCDIC
if the character set is EBCDIC, does nothing if the character set is ASCII, fails if it can't detect the character set. - c_enum_fwdecl
Check for ability to typedef enums before definition. Defines
HAVE_ENUM_FWDECL
to 1 if so. - c_variadic_templates
Check whether the C++ compiler supports C++0x lambdas. Defines
HAVE_LAMBDA
to 1 if so. - c_late_expansion
Check whether the preprocessor supports ANSI conforming late macro expansion. Defines the C preprocessor macro
HAVE_LATE_EXPANSION
to 1 if so. - c_stmt_exprs
Checks whether the C compiler supports the GNU extension of brace-expressions:
({ code; })
. DefinesHAVE_STMT_EXPRS
to 1 if the compiler supports braced statements within expressions. - c_token_paste
Checks if the preprocessor implements ANSI-style token pasting (with
##
). Defines the C preprocessor macroHAVE_ANSI_PASTE
to 1 if so. - c_variadic_templates
Check whether the C++ compiler supports C++0x variadic templates. Defines the C preprocessor macro
HAVE_VARIADIC_TEMPLATES
to 1 if so. - c_stdint_h
Checks for the existence of
stdint.h
types and defines appropriate types in case of absence. As a side effect, this also checks for the size of every built-in integer type andvoid *
. This directive will enforce thatsizeof(char) == 1
. This should be the case for standard conforming implementations. The following types are asserted:- size_t
- uint8_t
- uint16_t
- uint32_t
- uint64_t
- uintmax_t
- uintptr_t
- int8_t
- int16_t
- int32_t
- int64_t
- intmax_t
- intptr_t