Coccinelle release 1.0.0-rc1
[bpt/coccinelle.git] / configure
index 073d6f7..7b9d0de 100755 (executable)
--- a/configure
+++ b/configure
@@ -38,9 +38,10 @@ my $sexpdir="ocamlsexp";
 local $_ = join ' ', @ARGV;
 
 # Parse options
-/-h/ || /--help/ and die "usage: $0 [--prefix=path] [--without-python] [--no-opt]\n\n\t--no-opt\tDo not use the optimimized version of OCaml\n\t--opt\tUse the optimimized version of OCaml\n\n";
+/-h/ || /--help/ and die "usage: $0 [--prefix=path] [--without-python] [--without-ocaml] [--no-opt]\n\n\t--no-opt\tDo not use the optimimized version of OCaml\n\t--opt\tUse the optimimized version of OCaml\n\n";
 /--prefix=([^ ]*)/ and $prefix = $1;
 /--without-python/ and $python = 0;
+/--without-ocaml/ and $noocamlscripting = 1;
 /--no-opt/ and $opt = "";
 /--opt/ and $opt = ".opt";
 
@@ -108,11 +109,13 @@ $error +=
                  "The program ocaml is missing or is not a good version. We need at least 3.09",
                  );
 
+unless ($noocamlscripting) {
 $noocamlscripting = check_config("echo \"1;;\\n\" | ocaml |",
                  "Objective(.*) 3.1[1-9]",
                  "OCaml >= 3.11 is present. OCaml scripting activated.",
                  "OCaml scripting disabled. We need at least OCaml 3.11",
                  );
+}
 my $ocamlprefix = $noocamlscripting ? "no" : "yes";
 
 if ($opt eq ".opt") {
@@ -183,7 +186,6 @@ $error += check_config(
 We need  3.XX",
 );
 
-
 #---------------------------------------------------------------------
 # More developers tools
 #---------------------------------------------------------------------
@@ -192,6 +194,41 @@ We need  3.XX",
 # Librairies
 #---------------------------------------------------------------------
 
+# Python dev
+my $PY_VERSION;
+if($python) {
+    if(check_config(
+       "python --version 2>&1 |",
+       '^Python 2\.([4567]|[4567]\.\S*)$',
+       "python is present",
+       "python is missing or is not a good version."
+       ))
+    {
+       $python=0;
+    }
+    if($python) {
+       my $PY_PREFIX = `python pycaml/getprefix.py | tr -d '\n'`;
+       $PY_VERSION = `python 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(
+       "which ocamlfind 2> /dev/null |",
+       '/ocamlfind$',
+       "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`;
 
@@ -272,14 +309,15 @@ Then, to test $project simply type:
 
 ";
 
-if($python) {
-        pr2
+    if($python) {
+       pr2
 "To use the python SmPL feature you may have to set some environment variables.
 However, they are automatically set by the front-end installed in $prefix/bin.
 For bash do:
 export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:$prefix/lib
 export PYTHONPATH=\$PYTHONPATH:$src/python"
     }
+
     pr2 "----------------------------------------------------------------------";
 }
 
@@ -287,6 +325,8 @@ export PYTHONPATH=\$PYTHONPATH:$src/python"
 # Generating the configuration
 ######################################################################
 
+pr2 "  Compilation configuration\n";
+
 pr2 "$project target prefix: $prefix (you can use --prefix to override it)";
 pr2 "Generating Makefile.config";
 open(CONFIG, ">Makefile.config");
@@ -314,7 +354,13 @@ BASH_COMPLETION_DIR=/etc/bash_completion.d
 # Features
 FEATURE_PYTHON=$python
 FEATURE_TARZAN=$tarzan
+";
 
+if ($python) {
+print CONFIG "PYVER=$PY_VERSION";
+}
+
+print CONFIG "
 PYCAMLDIR=$pydir
 MENHIRDIR=$menhirdir
 SEXPDIR=$sexpdir
@@ -329,11 +375,11 @@ OPTBIN=$opt
 
 
 my $pythonprefix = $python ? "yes" : "no";
-pr2 "Support for python scripting : $pythonprefix";
+pr2 "Support for python scripting: $pythonprefix";
 `cd python; ln -sf ${pythonprefix}_pycocci.ml pycocci.ml; `;
 `cd python; make depend`;
 
-pr2 "Support for ocaml scripting : $ocamlprefix";
+pr2 "Support for ocaml scripting: $ocamlprefix";
 `cd ocaml; ln -sf ${ocamlprefix}_prepare_ocamlcocci.ml prepare_ocamlcocci.ml;`;
 `cd ocaml; make depend`;
 
@@ -341,3 +387,14 @@ pr2 "Modifying globals/config.ml";
 my $command = "perl -p -e 's#Not_found.\*#Not_found->\\\"$src\\\"#' globals/config.ml.in > globals/config.ml";
 `$command`;
 
+pr2 "----------------------------------------------------------------------";
+pr2 "  Runtime dependency\n";
+
+if ($ocamlfind) {
+pr2 "Support for external ocaml library in ocaml scripting: yes (ocamlfind found)";
+}
+else {
+pr2 "Support for external ocaml library in ocaml scripting: no (ocamlfind may be required at runtime)";
+}
+
+pr2 "";