This file is part of MXE. See LICENSE.md for licensing information. Contains ad hoc patches for cross building. From 3a3ddccba8fa90a42551fb4d529c921c0aac4f63 Mon Sep 17 00:00:00 2001 From: MXE Date: Wed, 3 Oct 2012 09:25:11 +0200 Subject: [PATCH] ocamlbuild : support for prefixed ocaml{c,opt,mklib,mktop,find} tools diff --git a/ocamlbuild/findlib.ml b/ocamlbuild/findlib.ml index b5ef878..77454ed 100644 --- a/ocamlbuild/findlib.ml +++ b/ocamlbuild/findlib.ml @@ -44,7 +44,7 @@ let report_error e = prerr_endline (string_of_error e); exit 2 -let ocamlfind = "ocamlfind" +let ocamlfind = "@target@-ocamlfind" type package = { name: string; diff --git a/ocamlbuild/options.ml b/ocamlbuild/options.ml index 1be4b63..e7313de 100644 --- a/ocamlbuild/options.ml +++ b/ocamlbuild/options.ml @@ -39,16 +39,17 @@ let use_menhir = ref false let catch_errors = ref true let use_ocamlfind = ref false -let mk_virtual_solvers = +let mk_virtual_solvers target = let dir = Ocamlbuild_where.bindir in List.iter begin fun cmd -> - let opt = cmd ^ ".opt" in + let target_cmd = target^cmd in + let opt = target_cmd ^ ".opt" in let a_opt = A opt in - let a_cmd = A cmd in + let a_cmd = A target_cmd in let search_in_path = memo Command.search_in_path in let solver () = if sys_file_exists !dir then - let long = filename_concat !dir cmd in + let long = filename_concat !dir target_cmd in let long_opt = long ^ ".opt" in if file_or_exe_exists long_opt then A long_opt else if file_or_exe_exists long then A long @@ -61,9 +62,9 @@ let mk_virtual_solvers = end let () = - mk_virtual_solvers - ["ocamlc"; "ocamlopt"; "ocamldep"; "ocamldoc"; - "ocamlyacc"; "menhir"; "ocamllex"; "ocamlmklib"; "ocamlmktop"; "ocamlfind"] + mk_virtual_solvers "@target@-" + ["ocamlc"; "ocamlopt"; "ocamldep"; "ocamlmklib"; "ocamlmktop"; "ocamlfind"]; + mk_virtual_solvers "" ["ocamldoc"; "ocamlyacc"; "menhir"; "ocamllex"] let ocamlc = ref (V"OCAMLC") let ocamlopt = ref (V"OCAMLOPT") let ocamldep = ref (V"OCAMLDEP") @@ -73,7 +74,7 @@ let ocamllex = ref (V"OCAMLLEX") let ocamlmklib = ref (V"OCAMLMKLIB") let ocamlmktop = ref (V"OCAMLMKTOP") let ocamlrun = ref N -let ocamlfind x = S[V"OCAMLFIND"; x] +let ocamlfind = (V"OCAMLFIND") let program_to_execute = ref false let must_clean = ref false let show_documentation = ref false @@ -261,11 +262,19 @@ let init () = (* TODO: warning message when using an option such as -ocamlc *) (* Note that plugins can still modify these variables After_options. This design decision can easily be changed. *) - ocamlc := ocamlfind & A"ocamlc"; - ocamlopt := ocamlfind & A"ocamlopt"; - ocamldep := ocamlfind & A"ocamldep"; - ocamldoc := ocamlfind & A"ocamldoc"; - ocamlmktop := ocamlfind & A"ocamlmktop"; + List.iter (fun (option,string) -> + (match !option with + | Sh s + | A s -> + Log.eprintf "Warning : Command '-%s %s' overidden by option -use-ocamlfind" string s + | _ -> () + ); + option := S[ocamlfind; A string] + ) [(ocamlc,"ocamlc"); + (ocamlopt,"ocamlopt"); + (ocamldep,"ocamldep"); + (ocamldoc,"ocamldoc"); + (ocamlmktop,"ocamlmktop")] end; let reorder x y = x := !x @ (List.concat (List.rev !y)) in -- 1.8.1.2