Menu ▾ ▴

SyntaxStmtConfigure

Brad Lanam

Wiki Home
Syntax

Syntax: .configuration_file

.configuration_file generates a configuration file for use by the project.

.configuration_file { <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.

Manual Replacement Strings
.configuration_file {
  .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.

Attributes
See Also
Examples
Example 1: Auto, with define_zero
.project mktest;

.check_function malloc;
.check_function junk;

.configuration_file {
  .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 */
Example 2: Auto, without define_zero
.project mkctest;

.check_function malloc;
.check_function junk;

.configuration_file {
  .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 */
Example 3: Manual
.check_function malloc;

.configuration_file {
  .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 */
Example 4: Manual, with replace attribute
.check_function malloc;
.set something 'abc';

.configuration_file {
  .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
Syntax


Related

Wiki: Home
Wiki: Syntax
Wiki: SyntaxAttrInput
Wiki: SyntaxAttrMethod
Wiki: SyntaxAttrOutput
Wiki: SyntaxAttrReplace
Wiki: SyntaxStmtMark