Helper library for gathering system configuration
OCaml Makefile
Clone or download
Latest commit 3dfa8e6 May 23, 2018
Permalink
Failed to load latest commit information.
src v0.11.117.00+101 Mar 29, 2018
.gitignore 114.35+03 Mar 7, 2017
CONTRIBUTING.md v0.11.117.08+54 May 23, 2018
LICENSE.md v0.11.117.08+54 May 23, 2018
Makefile v0.11.117.08+54 May 23, 2018
README.org 114.20+69 Dec 23, 2016
configurator.opam v0.11.117.08+54 May 23, 2018

README.org

Configurator

Configurator is a small library that helps writing OCaml scripts that test features available on the system, in order to generate config.h files for instance.

Configurator allows one to:

  • test if a C program compiles
  • query pkg-config
  • import #define from OCaml header files
  • generate config.h file

For instance:

open Base
module C = Configurator

let clock_gettime_code = {|
#include <time.h>

int main()
{
  struct timespec ts;
  clock_gettime(CLOCK_REALTIME, &ts);
  return 0;
}
|}

let () =
  C.main ~name:"foo" (fun c ->
    let has_clock_gettime = C.c_test c clock_gettime_code ~link_flags:["-lrt"] in

    C.C_define.gen_header_file c ~fname:"config.h"
      [ "HAS_CKOCK_GETTIME", Switch has_ckock_gettime ]);