+# Python dev
+my $PY_VERSION;
+if($python) {
+ if(check_config(
+ "$python_cmd --version 2>&1 |",
+ '^Python [23]\.',
+ "$python_cmd is present",
+ "$python_cmd is missing or is not a good version."
+ ))
+ {
+ $python=0;
+ }
+ if($python) {
+ my $PY_PREFIX = `$python_cmd pycaml/getprefix.py | tr -d '\n'`;
+ $PY_VERSION = `$python_cmd pycaml/getversion.py | tr -d '\n'`;
+ my $python_hdr = "$PY_PREFIX/include/python$PY_VERSION/Python.h";
+ if(check_config(
+ "ls $python_hdr 2> /dev/null | ",
+ $python_hdr,
+ "Python.h found",
+ "Python.h missing - You need to install python-dev"
+ ))
+ {
+ $python=0
+ }
+ }
+}
+
+my $ocamlfind=!check_config(
+ "ocamlfind ocamlc -version 2> /dev/null | ",
+ '^[0-9\.]+',
+ "ocamlfind is present",
+ "ocamlfind is missing -- Switch to local library copies."
+ );
+
+# pycaml. Binding between Python and OCaml
+my $syspydir=`ocamlfind query pycaml 2> /dev/null | xargs echo -n`;
+
+if($syspydir) {
+ pr2 "'pycaml' library is present in $syspydir";
+ if ($libs{'pycaml'} > 1) {
+ pr2 "... but a local copy of 'pycaml' will be used.";
+ }
+ else {
+ $pydir=$syspydir;
+ }
+} else {
+ pr2 "'pycaml' library is not present. A local copy will be used.";
+}
+
+# menhirLib. Runtime system for the parsers generated with menhir
+my $sysmenhirdir=`ocamlfind query menhirLib 2> /dev/null | xargs echo -n`;
+
+if($sysmenhirdir) {
+ $menhirdir=$sysmenhirdir;
+ pr2 "'menhirLib' library is present in $menhirdir";
+} else {
+ pr2 "'menhirLib' library is not present. A local copy will be used.";
+}
+
+# sexplib.
+my $syssexpdir=`ocamlfind query sexplib 2> /dev/null | xargs echo -n`;
+
+if($syssexpdir) {
+ $sexpdir=$syssexpdir;
+ pr2 "'sexplib' library is present in $sexpdir";
+} else {
+ pr2 "'sexplib' library is not present. A local copy will be used.";
+}
+
+# Check if libpcre-ocaml is available
+# when pcre feature is enabled.
+my $pcredir="";
+if($pcre) {
+ $pcredir=`ocamlfind query pcre 2> /dev/null | xargs echo -n `;
+ if(check_config(
+ "echo -n $pcredir | ",
+ '^/.*$',
+ "'pcre-ocaml' library is present in $pcredir",
+ "'pcre-ocaml' library is not present - You need to install libpcre-ocaml-dev"
+ ))
+ {
+ $pcre=0
+ }
+}
+
+######################################################################
+# Printing of library selection
+######################################################################
+
+
+pr2 "----------------------------------------------------------------------";
+pr2 "Library configuration:";
+
+my %libPaths;
+foreach my $lib (keys %libs) {
+ my $isSelected = $libs{$lib};
+ if ($isSelected) {
+ my $libdir = `ocamlfind query $lib 2> /dev/null | xargs echo -n`;
+ if ($libdir && $libs{$lib} <= 1) {
+ $libs{$lib} = 1;
+ $libPaths{$lib} = $libdir;
+ }
+ else {
+ if (-d $lib) { # test if local directory exists
+ $libs{$lib} = 2; # use local version
+ $libPaths{$lib} = $lib;
+ } else {
+ $libs{$lib} = 0; # disable the feature
+ $libPaths{$lib} = "";
+ }
+ }
+ }
+
+ my $choice = $libs{$lib};
+ if ($choice == 0) {
+ pr2 "$lib: disabled";
+ } elsif ($choice == 1) {
+ pr2 "$lib: global version in $libPaths{$lib}";
+ } else {
+ pr2 "$lib: local version selected";
+ }
+}
+