Overview  Index  Help 
CConfig Library

C_CONFIG

All Known Implementing Modules:

CConfig


signature C_CONFIG =
sig
  val verbose : bool -> unit
  val message : bool -> unit
  val logging : bool -> unit
  val config
      : string -> {set : string option -> unit, get : unit -> string option}
  val expand : string -> string
  val haveLibrary : string * string * string list -> bool
  val findLibrary : string * string * string list -> string option
  val haveConstInt : string * string list -> int option
  val haveConstLong : string * string list -> LargeInt.int option
  val haveConstUInt : string * string list -> word option
  val haveConstULong : string * string list -> LargeWord.word option
  val haveConstFloat : string * string list -> real option
  val haveConstDouble : string * string list -> real option
  val haveConstString : string * string list -> string option
  val checkSizeOf : string * string list -> int
  val checkStructMember : string * string * string list -> (int * int) option
  val checkIsBigEndian : unit -> bool
  val accessor
      : int * int ->
          {
            set : Word8Array.array * word -> unit,
            get : Word8Array.array -> word
          }
end

System configuration inspection by using C compiler.

Author:
UENO Katsuhiro
Copyright:
(c) 2007, Tohoku University.

       
Value detail

verbose

val verbose : bool -> unit

set verbose flag. If true, CConfig dumps all logs to standard error output. Default is false.


message

val message : bool -> unit

set message flag. If true, CConfig displays current inspection status and results of inspections to standard error output. Default is true. string allocated outside of the managed heap.


logging

val logging : bool -> unit

set logging flag. If true, CConfig writes all logs to "cconfig.log" file in current directory. Default is true.


config

fun config name
    : string -> {set : string option -> unit, get : unit -> string option}

return a pair of getter and setter of a variable.

Parameters:
name
a name of variable

expand

fun expand string : string -> string

replace every variable reference in a string with its content. A variable reference is $ followed by one name of variable optionally surrounded by parentheses or braces. $$ is replaced with $. The content of variable VAR is
  1. string set by #set config to VAR,
  2. the value of environment variable VAR if no string is set to VAR by #set config,
  3. default string provided CConfig if neither no string is set nor environment variable is not defined, or
  4. an empty string.
All variable referecenes are expanded recursivelly; if the content of FOO is "+$BAR+" and the content of BAR is "BAZ", this function replaces "$FOO" with "+BAZ+". Note that this function never stop if there is a looped reference.

Parameters:
string
string containing variable references
Returns:
a string such that every variable reference in given string is replaced with its content.

haveLibrary

fun haveLibrary (libraryName, functionName, headerFiles)
    : string * string * string list -> bool

check whether a library is installed on current system.

This function inspects whether the library is already installed on the current system like GNU Autoconf. This function generates minimal C source code and try to compile and link it by C compiler.

The command line to compile a C source file is given by TRY_COMPILE variable, and one to link is given by TRY_LINK variable. Default content of TRY_COMPILE is the following:

 $(CC) -c $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(ccopt) $(src)
 

And default content of TRY_LINK is:

 $(CC) $(OUTFLAG)$(out) $(INCFLAGS) $(CPPFLAGS)
 $(CFLAGS) $(ccopt) $(src) $(LIBPATH) $(LDFLAGS) $(ldopt)
 $(LOCAL_LIBS) $(LIBS)
 

Parameters:
libraryName
a name of library to look for.
functionName
an arbitary function name which is in the library.
headerFiles
header filenames to be included from generated C source code.
Returns:
true if found the library.

findLibrary

fun findLibrary (libraryName, functionName, headerFiles)
    : string * string * string list -> string option

search a library and return its filename if found.

This function inspects whether the library exists in the same way as haveLibrary function. If found, this function analyzes the resulting C object file by using ldd command, and extracts a list of library filenames which are linked dynamically from the object code, and then chooses appropriciate one from the list.

The command line to invoke ldd command is given by TRY_LDD variable. Default content of TRY_LDD is the following:

 $(LDD) $(out)
 

Parameters:
libraryName
a name of library to look for.
functionName
an arbitary function name which is in the library.
headerFiles
header filenames to be included from generated C source code.
Returns:
NONE if the library is not found. SOME filename if found, where filename is an absolute path to the library file.

haveConstInt

fun haveConstInt (constantName, headerFiles)
    : string * string list -> int option

check whether a constant is defined and return its value if found.

This function inspects whether the contant (C constant or macro constant) is defined like GNU Autoconf. This function generates minimal C program to print the constant, and try to compile and link by C compiler and execute the resulting executable file to get the output of the program.

Parameters:
constantName
a name of constant to look for.
headerFiles
header filenames to be included from generated C source code.
Returns:
NONE if the const is not found. SOME value if found, where value is the value of the constant.

haveConstLong

val haveConstLong : string * string list -> LargeInt.int option

see also haveConstInt.


haveConstUInt

val haveConstUInt : string * string list -> word option

see also haveConstInt.


haveConstULong

val haveConstULong : string * string list -> LargeWord.word option

see also haveConstInt.


haveConstFloat

val haveConstFloat : string * string list -> real option

see also haveConstInt.


haveConstDouble

val haveConstDouble : string * string list -> real option

see also haveConstInt.


haveConstString

val haveConstString : string * string list -> string option

see also haveConstInt.


checkSizeOf

fun checkSizeOf (typeName, headerFiles) : string * string list -> int

inspect the size of a C type.

Parameters:
typeName
a name of C type.
headerFiles
header filenames to be included.
Returns:
an integer value of sizeof(typeName).

checkStructMember

fun checkStructMember (structName, memberName, headerFiles)
    : string * string * string list -> (int * int) option

inspect informations about a member of a structure.

Parameters:
structName
a name of structure.
memberName
a name of a member of the struction.
headerFiles
header filenames to be included.
Returns:
a pair of integers. First integer is the size of the member of the structure, and another is the offset of the member.

checkIsBigEndian

val checkIsBigEndian : unit -> bool

check whether current system is big endian.

Returns:
true if current system is big endian.

accessor

fun accessor (size, offset)
    : int * int ->
        {set : Word8Array.array * word -> unit, get : Word8Array.array -> word}

create a pair of accessor of an integral member of a structure from offset and size.

Parameters:
size
the size of the member of the structure.
offset
the offset of the member.
Returns:
a pair of setter and getter.

 


Overview  Index  Help 
CConfig Library