From abb35cbdb136a70e7f43d6dfa77d7356da73ec44 Mon Sep 17 00:00:00 2001 From: Vincent Laporte Date: Sun, 1 Feb 2015 11:19:50 +0100 Subject: [PATCH] ocamlbuild: use ocamlfind to discover camlp4 path and default to `+camlp4` --- Changes | 2 ++ ocamlbuild/ocaml_specific.ml | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Changes b/Changes index eab955009cf1..a5e866b18e81 100644 --- a/Changes +++ b/Changes @@ -226,6 +226,8 @@ OCamlbuild: - Changed OCamlbuild's license to LGPLv2 with static linking exception. - GPR#219: speedup target-already-built builds (ygrek) +- PR#6605, GPR#117: use ocamlfind, if available, to discover camlp4 path + (Vincent Laporte) Bug fixes: - PR#3612: memory leak in bigarray read from file diff --git a/ocamlbuild/ocaml_specific.ml b/ocamlbuild/ocaml_specific.ml index b902810ad780..a73b7a5c92ec 100644 --- a/ocamlbuild/ocaml_specific.ml +++ b/ocamlbuild/ocaml_specific.ml @@ -698,15 +698,25 @@ ocaml_lib ~extern:true ~tag_name:"use_toplevel" "toplevellib";; ocaml_lib ~extern:true ~dir:"+ocamldoc" "ocamldoc";; ocaml_lib ~extern:true ~dir:"+ocamlbuild" ~tag_name:"use_ocamlbuild" "ocamlbuildlib";; -ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_camlp4" "camlp4lib";; -ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_old_camlp4" "camlp4";; -ocaml_lib ~extern:true ~dir:"+camlp4" ~tag_name:"use_camlp4_full" "camlp4fulllib";; +let camlp4dir = + Findlib.( + try + if sys_command "sh -c 'ocamlfind list >/dev/null' 2>/dev/null" != 0 + then raise (Findlib_error Cannot_run_ocamlfind); + (query "camlp4").location + with Findlib_error _ -> + "+camlp4" + );; + +ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_camlp4" "camlp4lib";; +ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_old_camlp4" "camlp4";; +ocaml_lib ~extern:true ~dir:camlp4dir ~tag_name:"use_camlp4_full" "camlp4fulllib";; flag ["ocaml"; "compile"; "use_camlp4_full"] - (S[A"-I"; A"+camlp4/Camlp4Parsers"; - A"-I"; A"+camlp4/Camlp4Printers"; - A"-I"; A"+camlp4/Camlp4Filters"]);; -flag ["ocaml"; "use_camlp4_bin"; "link"; "byte"] (A"+camlp4/Camlp4Bin.cmo");; -flag ["ocaml"; "use_camlp4_bin"; "link"; "native"] (A"+camlp4/Camlp4Bin.cmx");; + (S[A"-I"; A(camlp4dir^"/Camlp4Parsers"); + A"-I"; A(camlp4dir^"/Camlp4Printers"); + A"-I"; A(camlp4dir^"/Camlp4Filters")]);; +flag ["ocaml"; "use_camlp4_bin"; "link"; "byte"] (A(camlp4dir^"/Camlp4Bin.cmo"));; +flag ["ocaml"; "use_camlp4_bin"; "link"; "native"] (A(camlp4dir^"/Camlp4Bin.cmx"));; flag ["ocaml"; "debug"; "compile"; "byte"] (A "-g");; flag ["ocaml"; "debug"; "link"; "byte"; "program"] (A "-g");;