diff options
author | 2015-02-26 15:54:01 +0100 | |
---|---|---|
committer | 2015-02-26 15:59:42 +0100 | |
commit | 1b7d4a033af8c449877252710683f6f9494a6096 (patch) | |
tree | 97679a3d9ae05581aaa5163723f3c6fcc9fb3b9d /configure.ml | |
parent | 9582053a841c55010ddb2c4868f691151d4d949d (diff) |
Trying to fix code locating camlp4/camlp5.
Should fix #3396 and #3964.
Diffstat (limited to 'configure.ml')
-rw-r--r-- | configure.ml | 85 |
1 files changed, 38 insertions, 47 deletions
diff --git a/configure.ml b/configure.ml index 8667a5359..f169e7100 100644 --- a/configure.ml +++ b/configure.ml @@ -291,7 +291,7 @@ let args_options = Arg.align [ "-coqdocdir", arg_string_option Prefs.coqdocdir, "<dir> Where to install Coqdoc style files"; "-camldir", arg_string_option Prefs.camldir, - "<dir> Specifies the path to the OCaml library"; + "<dir> Specifies the path to the OCaml binaries"; "-lablgtkdir", arg_string_option Prefs.lablgtkdir, "<dir> Specifies the path to the Lablgtk library"; "-usecamlp5", Arg.Set Prefs.usecamlp5, @@ -359,8 +359,7 @@ type camlexec = mutable dep : string; mutable doc : string; mutable lex : string; - mutable yacc : string; - mutable p4 : string } + mutable yacc : string } (* TODO: autodetect .opt binaries ? *) @@ -372,8 +371,7 @@ let camlexec = dep = "ocamldep"; doc = "ocamldoc"; lex = "ocamllex"; - yacc = "ocamlyacc"; - p4 = "camlp4o" } + yacc = "ocamlyacc" } let reset_caml_byte c o = c.byte <- o let reset_caml_opt c o = c.opt <- o @@ -389,8 +387,7 @@ let rebase_camlexec dir c = c.dep <- Filename.concat dir c.dep; c.doc <- Filename.concat dir c.doc; c.lex <- Filename.concat dir c.lex; - c.yacc <- Filename.concat dir c.yacc; - c.p4 <- Filename.concat dir c.p4 + c.yacc <- Filename.concat dir c.yacc let coq_debug_flag = if !Prefs.debug then "-g" else "" let coq_profile_flag = if !Prefs.profile then "-p" else "" @@ -537,11 +534,6 @@ let camltag = match caml_version_list with (** * CamlpX configuration *) -(** We assume that camlp(4|5) binaries are at the same place as ocaml ones - (this should become configurable some day). *) - -let camlp4bin = camlbin - (* TODO: camlp5dir should rather be the *binary* location, just as camldir *) (* TODO: remove the late attempts at finding gramlib.cma *) @@ -564,7 +556,7 @@ let check_camlp5 testcma = match !Prefs.camlp5dir with camllib/"site-lib"/"camlp5" else "" in - (* if the two values are different than camlp5 has been relocated + (* if the two values are different then camlp5 has been relocated * and will not be able to find its own files, so we prefer the * path where the files actually do exist *) if dir2 = "" then @@ -576,39 +568,39 @@ let check_camlp5 testcma = match !Prefs.camlp5dir with else dir2 let check_camlp5_version () = - let s = camlexec.p4 in - (* translate 4 into 5 in the binary name *) - for i = 0 to String.length s - 1 do - if s.[i] = '4' then s.[i] <- '5' - done; try - let version_line, _ = run ~err:StdOut camlexec.p4 ["-v"] in + let camlp5o = which "camlp5o" in + let version_line, _ = run ~err:StdOut camlp5o ["-v"] in let version = List.nth (string_split ' ' version_line) 2 in match string_split '.' version with | major::minor::_ when s2i major > 5 || (s2i major, s2i minor) >= (5,1) -> - printf "You have Camlp5 %s. Good!\n" version + printf "You have Camlp5 %s. Good!\n" version; camlp5o | _ -> failwith "bad version" - with _ -> die "Error: unsupported Camlp5 (version < 5.01 or unrecognized).\n" + with + | Not_found -> die "Error: cannot find Camlp5 binaries in path.\n" + | _ -> die "Error: unsupported Camlp5 (version < 5.01 or unrecognized).\n" let config_camlpX () = try if not !Prefs.usecamlp5 then raise NoCamlp5; - let lib = "gramlib" in - let dir = check_camlp5 (lib^".cma") in - let () = check_camlp5_version () in - "camlp5", dir, lib + let camlp5mod = "gramlib" in + let camlp5libdir = check_camlp5 (camlp5mod^".cma") in + let camlp5o = check_camlp5_version () in + "camlp5", camlp5o, Filename.basename camlp5o, camlp5libdir, camlp5mod with NoCamlp5 -> (* We now try to use Camlp4, either by explicit choice or by lack of proper Camlp5 installation *) - let lib = "camlp4lib" in - let dir = camllib/"camlp4" in - if not (Sys.file_exists (dir/lib^".cma")) then + let camlp4mod = "camlp4lib" in + let camlp4libdir = camllib/"camlp4" in + if not (Sys.file_exists (camlp4libdir/camlp4mod^".cma")) then die "No Camlp4 installation found.\n"; - let () = camlexec.p4 <- camlexec.p4 ^ "rf" in - ignore (run camlexec.p4 []); - "camlp4", dir, lib + try + let camlp4orf = which "camlp4orf" in + ignore (run camlp4orf []); + "camlp4", camlp4orf, Filename.basename camlp4orf, camlp4libdir, camlp4mod + with _ -> die "No Camlp4 installation found.\n" -let camlp4, fullcamlp4lib, camlp4mod = config_camlpX () +let camlpX, camlpXo, camlpXbindir, fullcamlpXlibdir, camlpXmod = config_camlpX () let shorten_camllib s = if starts_with s (camllib^"/") then @@ -616,8 +608,7 @@ let shorten_camllib s = "+" ^ String.sub s l (String.length s - l) else s -let camlp4lib = shorten_camllib fullcamlp4lib - +let camlpXlibdir = shorten_camllib fullcamlpXlibdir (** * Native compiler *) @@ -627,8 +618,8 @@ let msg_byteonly () = let msg_no_ocamlopt () = printf "Cannot find the OCaml native-code compiler.\n"; msg_byteonly () -let msg_no_camlp4_cmxa () = - printf "Cannot find the native-code library of %s.\n" camlp4; msg_byteonly () +let msg_no_camlpX_cmxa () = + printf "Cannot find the native-code library of %s.\n" camlpX; msg_byteonly () let msg_no_dynlink_cmxa () = printf "Cannot find native-code dynlink library.\n"; msg_byteonly (); @@ -643,8 +634,8 @@ let check_native () = reset_caml_opt camlexec camloptopt else if not (is_executable camlexec.opt || program_in_path camlexec.opt) then (msg_no_ocamlopt (); raise Not_found); - if not (Sys.file_exists (fullcamlp4lib/camlp4mod^".cmxa")) then - (msg_no_camlp4_cmxa (); raise Not_found); + if not (Sys.file_exists (fullcamlpXlibdir/camlpXmod^".cmxa")) then + (msg_no_camlpX_cmxa (); raise Not_found); if not (Sys.file_exists (camllib/"dynlink.cmxa")) then (msg_no_dynlink_cmxa (); raise Not_found); let version, _ = run camlexec.opt ["-version"] in @@ -969,7 +960,7 @@ let print_summary () = pr " OCaml/Camlp4 version : %s\n" caml_version; pr " OCaml/Camlp4 binaries in : %s\n" camlbin; pr " OCaml library in : %s\n" camllib; - pr " Camlp4 library in : %s\n" camlp4lib; + pr " %s library in : %s\n" (String.capitalize camlpX) camlpXlibdir; if best_compiler = "opt" then pr " Native dynamic link support : %B\n" hasnatdynlink; if coqide <> "no" then @@ -1009,7 +1000,7 @@ let write_dbg_wrapper f = pr "# DO NOT EDIT THIS FILE: automatically generated by ../configure #\n\n"; pr "export COQTOP=%S\n" coqtop; pr "OCAMLDEBUG=%S\n" (camlbin^"/ocamldebug"); - pr "CAMLP4LIB=%S\n\n" camlp4lib; + pr "CAMLP4LIB=%S\n\n" camlpXlibdir; pr ". $COQTOP/dev/ocamldebug-coq.run\n"; close_out o; Unix.chmod f 0o555 @@ -1048,10 +1039,10 @@ let write_configml f = pr_s "ocamllex" camlexec.lex; pr_s "camlbin" camlbin; pr_s "camllib" camllib; - pr_s "camlp4" camlp4; - pr_s "camlp4o" camlexec.p4; - pr_s "camlp4bin" camlp4bin; - pr_s "camlp4lib" camlp4lib; + pr_s "camlp4" camlpX; + pr_s "camlp4o" camlpXo; + pr_s "camlp4bin" camlpXbindir; + pr_s "camlp4lib" camlpXlibdir; pr_s "camlp4compat" camlp4compat; pr_s "cflags" cflags; pr_s "best" best_compiler; @@ -1159,10 +1150,10 @@ let write_makefile f = pr "CAMLTIMEPROF=%s\n\n" coq_profile_flag; pr "# Camlp4 : flavor, binaries, libraries ...\n"; pr "# NB : avoid using CAMLP4LIB (conflict under Windows)\n"; - pr "CAMLP4=%s\n" camlp4; - pr "CAMLP4O=%S\n" camlexec.p4; + pr "CAMLP4=%s\n" camlpX; + pr "CAMLP4O=%S\n" camlpXo; pr "CAMLP4COMPAT=%s\n" camlp4compat; - pr "MYCAMLP4LIB=%S\n\n" camlp4lib; + pr "MYCAMLP4LIB=%S\n\n" camlpXlibdir; pr "# Your architecture\n"; pr "# Can be obtain by UNIX command arch\n"; pr "ARCH=%s\n" arch; |