Module Conf


module Conf: sig  end
A module for build-time configuration.

Things it can do at build time:

  1. Check that certain findlib packages are installed, and where.
  2. Search for a file from a list of possibilities, for crude trial-and-error location.
  3. Process user parameters for the build.

It handles the command line parameters for all of the above, and returns a Conf.t - or configuration.

A configuration is a string to value mapping. It is generated by the Conf.configure function from a configuration_item list. Each item, in order, is passed the current configuration, and returns a potentially modified configuration.



type value =
| StringList of string list (*A space separated string must be passed by the user.*)
| String of string
| Bool of bool
The types of values that the configuration tracks
type t 
The type of configurations
type key = string 
type doc = string 

type configuration_item =
| FindLib of key * string option * string option
| Path of key * doc * string list
| Param of key * value * doc
| Custom of (t -> t)
A configuration item represents one build-time check that will be performed. This type will be made private in future versions of ocamlconf.
val standard_spec : (configuration_item * bool) list
A fairly standard configuration. In most cases you should append your configuration items onto the end of this list, as contains a few universal parameters that are nice. In the future it will be augmented to supply all the useful defaults that one expects from autoconf

Configuration Items


val findlib_check : ?min:string -> ?max:string -> string -> configuration_item
findlib_check name checks that a findlib package called name exists. If min or max are specified, then it ensures the package has a version within those constraints.
val path_search : ?doc:string -> string -> string list -> configuration_item
path_search name doc paths performs a rudimentary search through the list of paths. This provides a method for locating libraries that don't have any other way to be found.
val param : ?doc:string -> string -> value -> configuration_item
param name defaultvalue provides a compile-time parameter that can be overridden by the user. The default value is mandatory so that ocamlconf knows what type the user should be supplying.
val custom : (t -> t) -> configuration_item
custom f allows you to have a totally custom configuration function that takes in the configuration so far, and returns a possibly modified configuration. You only need to use this if other configuration items depend on the results, otherwise you can just program you custom stuff into your configure.ml

Configuration Function


val configure : (configuration_item * bool) list -> t
Takes a configuration_item list, supplemented with a bool to say whether to show each item to the user, and returns the configuration that results from all the tests are command-line parameters.

At this stage, the command line will be parsed and help output will be provided to users who request it, using the documentation strings you may or may not have provided when creating configuration items.


Accessing the generated configuration


val conf_value : t -> string -> value
val conf_stringlist : t -> string -> string list
This, and the next couple functions, are just wrappers around the value variant type, to save you a couple lines of code - keeping the configure.ml small is key
val conf_string : t -> string -> string
val conf_bool : t -> string -> bool

Outping / Informing the User


val output_config_file : t -> string -> unit
Outputs your completed config into a string, which is valid ML and can be used by your program
val summarize_config : t -> (configuration_item * bool) list -> string
Returns a human readable version of the configuration