configure generates a configuration file for use by the project.
configure { <attribute-list> };
If the method attribute is auto, the filename will be automatically generated based on the project name: project_config.h .
If the method attribute is manual, the input file is processed and all variable names are substituted.
configure {
method manual;
replace '@install-dir@' ${my_install_dir};
replace '@HAVE_MALLOC@' ${_function_malloc};
}
When using the manual method, replacement strings can be specified in the attribute list. This is useful when configuring pkg-config (.pc) files or shell scripts that may have
${variable} strings in them.
When one or more replace attributes are specified, the strings specified by the replacement attributes will be substituted, and no variable substitution will be performed.
project {
name mkctest;
}
check_function malloc;
check_function junk;
configure {
method auto;
# the define_zero attribute will output defines if the
# check failed.
define_zero;
}
mkctest_config.h:
#ifndef INC_MKCTEST_CONFIG_H
#define INC_MKCTEST_CONFIG_H
#define _function_malloc 1
#define _function_junk 0
#endif /* INC_MKCTEST_CONFIG_H */
project {
name mkctest;
}
check_function malloc;
check_function junk;
configure {
method auto;
# an output attribute overrides automatic generation of the filename
output 'myconfig.h';
}
myconfig.h:
#ifndef INC_MYCONFIG_H
#define INC_MYCONFIG_H
#define _function_malloc 1
#endif /* INC_MYCONFIG_H */
check_function malloc;
configure {
method manual;
input 'config.h.in';
output 'config.h';
}
config.h.in:
#ifndef INC_CONFIG_H
#define INC_CONFIG_H
#define HAVE_MALLOC ${_function_malloc}
#define SHLIBEXT ${MKC_SHARED_LIBRARY_EXTENSION}
#endif /* INC_CONFIG_H */
config.h:
#ifndef INC_CONFIG_H
#define INC_CONFIG_H
#define HAVE_MALLOC 1
#define SHLIBEXT ".so"
#endif /* INC_CONFIG_H */
check_function malloc;
set something 'abc';
configure {
method manual;
replace '@malloc@' ${_function_malloc};
replace '@shlibext@' ${MKC_SHARED_LIBRARY_EXTENSION}
input 'config.h.in';
output 'config.h';
}
config.h.in:
#ifndef INC_CONFIG_H
#define INC_CONFIG_H
#define HAVE_MALLOC @malloc@
#define SHLIBEXT "@shlibext@"
#define something "${something}"
#endif /* INC_CONFIG_H */
config.h:
#ifndef INC_CONFIG_H
#define INC_CONFIG_H
#define HAVE_MALLOC 1
#define SHLIBEXT ".so"
#define something "${something}"
#endif /* INC_CONFIG_H */
Wiki: Home
Wiki: Syntax
Wiki: SyntaxAttrInput
Wiki: SyntaxAttrMethod
Wiki: SyntaxAttrOutput
Wiki: SyntaxAttrReplace