The mkconfigure program reads a BSDBuild source from the standard input and outputs a valid Bourne configure script to the standard output.

The source may include valid Bourne shell script, along with special directives interpreted by mkconfigure. Directive names are case-insensitive. Long lines can be wrapped with a terminating \\ character.


The following directives provide information about the package:
PACKAGE(name) Short name for the package. Included in generated messages and comments.
VERSION(string) Specify current package version.
RELEASE(string) Specify a release codename.
REGISTER(name,desc) Describe a configure script argument to show in ./configure --help. name is the name of the getopt_long style argument (e.g., --with-foo, --enable-foo) and desc is a one-line description.
REGISTER_ENV_VAR(name,desc) Describe an influential environment variable to show in ./configure --help. name is the name of the environment variable and desc is a one-line description.
REGISTER_SECTION(text) Provide a title for a section of arguments in ./configure --help.


The following directives alter the operation of the configure script.
CONFIG_CACHE(yes|no) Enable support for caching of test results (./configure --cache option). By default, caching is disabled.
CONFIG_GUESS(path) Specify an alternate path to config.guess (default is mk/config.guess).
DEFAULT_DIR(dirname, path) Override one of the standard installation path defaults. dirname may be one of: PREFIX, BINDIR, LIBDIR, LIBEXECDIR, DATADIR, STATEDIR, SYSCONFDIR, LOCALEDIR or MANDIR. The path argument may include variable references such as "${PREFIX}".
SUCCESS_FN(fname) Instead of printing the default "Configuration successful" message at the end of the script, run the indicated Bourne shell function fname instead.


The following directives invoke installed BSDBuild test modules. Modules generate Bourne script for performing tests and returning results as variables. For instance, a test for a package "foo" would set variable HAVE_FOO to "yes" or "no" and return detected compilation flags under FOO_CFLAGS and FOO_LIBS.
CHECK(pkg[,ver[,pfx]]) Invoke the BSDBuild module called pkg. A <pkg>.pm module file should exist under ${PREFIX}/share/bsdbuild/BSDBuild/.

If ver is given and non-zero, check the version and set MK_VERSION_OK to "yes" if the installed version is compatible with ver.

If pfx is given, look under that installation prefix (and fail if it is not installed there). Typically, the value "${prefix_foo}" (from user-given --enable-foo=VALUE or --with-foo=VALUE) is used here.
REQUIRE(pkg[,ver[,pfx]]) Variant of CHECK() which implicitely terminates the script with an error message if pkg is not found or the ver is incompatible.
TEST_DIR(path) Specify an extra directory in which to search for BSDBuild test modules (.pm files). The default module path is ${PREFIX}/share/bsdbuild/BSDBuild/.


The following directives deal with Ada code compilation.
ADA_OPTION(option) Append an option to the ADAFLAGS which will be passed to the Ada compiler.
ADA_BFLAG(option) Append an option to the ADABFLAGS which will be passed to the Ada binder.


The following directives apply to C, C++ and other C-like languages.
C_DEFINE(optname) Specify a global define that will be passed to the compiler. An optname of "FOO" would result in the -DFOO flag being passed to the compiler. This value is also used by
C_INCDIR(dir) Specify a directory for include files. This results in the -Idir flag being added to the compiler command line. This value is also used by
C_INCDIR_CONFIG(dir) Specify a target directory for individual include files with configure-script generated statements (i.e., HAVE_FOO is written to have_foo.h in the specified directory). Pass an empty argument to disable. By default, config/ is used.
C_INCLUDE_CONFIG(file) Specify a monolithic C include file which will contain configure-script generated statements (i.e., HAVE_FOO defines). Pass an empty argument to disable (default).
C_INCPREP(dir) Specify a target directory for preprocessed C header files. The ./configure option --includes is a BSDBuild extension which gives the user the option of either generating preprocessed headers in the working directory ("--includes=yes", the default) or alternatively, to create a set of symbolic links to the original headers in the source directory ("--includes=link").
C_OPTION(option) Provide a gcc-style compiler option, such as -Wall, -Werror or -Wmissing-prototypes. For environments using other compilers, BSDBuild will attempt to set equivalent options.
CHECK_FUNC(fn[, ...]) Check for the existence of one or more C functions. If a function fn called foo() exists, then HAVE_FUNCTION_FOO is set.
CHECK_FUNC_OPTS(cflags, libs, fn[, ...]) Variant of CHECK_FUNCTION() with additional CFLAGS and LIBS arguments.
CHECK_HEADER(name[, ...]) Check whether one or more header files are available (with the current CFLAGS). If a header such as sys/foo.h is found, then HAVE_SYS_FOO_H is set.
CHECK_HEADER_OPTS(cflags, libs, header[, ...]) Variant of CHECK_HEADER(), with additional CFLAGS and LIBS arguments.
C_EXTRA_WARNINGS() Request extra compiler warnings. Exact interpretation is compiler specific.
C_FATAL_WARNINGS() Fail compilation if warnings are encountered.
HDEFINE(opt,val) Define a C preprocessor style header option. opt is an unquoted string (uppercase by convention), and the value val is a string enclosed in double quotes. For example, if opt is ENABLE_FOO, a file config/enable_foo.h will be generated by configure.
HDEFINE_UNQUOTED(opt,val) Variant of HDEFINE() which keeps val unquoted instead of interpreting it as a string.
HUNDEF(opt) Opposite of HDEFINE(), which writes an #undef directive to config/<option>.h.
LD_OPTION(option) Provide a ld-style linker option, such as -g or -nostdlib.
MAPPEND(opt,val) Append a space and val to the exported make variable opt.
MDEFINE(opt,val) Define an exported make variable opt with value val.


The following directives deal with the installation of Perl modules.
CHECK_PERL_MODULE(mod) Check that the specified Perl module is installed and functioning. For example, if mod is "Time::Zone", the macro will set the variable "HAVE_TIME_ZONE" accordingly.
REQUIRE_PERL_MODULE(mod) Same as CHECK_PERL_MODULE, except that the configure script will abort if the module is not found.


The following directives produce output scripts and modules for integration by external packages.
CONFIG_SCRIPT(name[,args]) Generate a standard "foo-config" script. name specifies the name of the script. For C/C++ style packages, the arguments are usually the --cflags output, followed by the --libs output.
PKGCONFIG_MODULE(name, desc, req, confl, cflags, libs, pvtLibs) Output a pkgconf compatible pc file to "name.pc" (which may be then installed into PKGCONFIG_LIBDIR). desc is the "Description" string, req is the "Required" modules list (space-separated), confl is the "Conflicts" list, cflags is the "Cflags" field, libs is Libs (for --libs) and pvtLibs is Libs.private (for --static --libs).