From: Yamagata Y. <yor...@mb...> - 2003-10-11 22:09:52
|
From: "Nicolas Cannasse" <war...@fr...> Subject: Re: [Ocaml-lib-devel] Next Step Date: Sat, 11 Oct 2003 20:01:36 +0200 > I don't know about findlib, since it doesn't work under Windows. > Maybe you could provide an install_findlib.ml ? Here is a patch. install.ml automatically tests the presence of findlib. Also, META.txt should be META (no suffix). You can not change the name of META file. The original install.ml checks whether extlib-doc presents in the *current* directory. It looks like a bug. The patch fixes this too. Index: install.ml =================================================================== RCS file: /cvsroot/ocaml-lib/extlib-dev/install.ml,v retrieving revision 1.4 diff -u -r1.4 install.ml --- install.ml 27 Sep 2003 20:06:45 -0000 1.4 +++ install.ml 11 Oct 2003 22:00:31 -0000 @@ -77,6 +77,20 @@ with _ -> prerr_endline ("Warning : failed to delete "^file) +(** package name *) +let name = "extlib" + +(** Do we have findlib? *) +let is_findlib () = + printf "Looking for findlib...\n"; + let findlib = Sys.command "ocamlfind printconf" = 0 in + printf "Done.\n"; + if findlib then + printf "We have findlib.\n" + else + printf "We do not have findlib.\n"; + findlib + let install() = printf "ExtLib installation program v1.0\n(c)2003 Nicolas Cannasse\n"; printf "Choose one of the following :\n1- Bytecode installation only\n2- Native installation only\n3- Both Native and Bytecode installation\n> "; @@ -86,8 +100,13 @@ | "3" -> true, true | _ -> failwith "Invalid choice, exit.") in - printf "Choose installation directory :\n> "; - let dest = complete_path (read_line()) in + + let findlib = is_findlib () in + let ocamlc = if findlib then "ocamlfind ocamlc" else "ocamlc" in + let ocamlopt = if findlib then "ocamlfind ocamlopt" else "ocamlopt" in + + if not findlib then printf "Choose installation directory :\n> "; + let dest = complete_path (if findlib then "." else read_line()) in (try close_out (open_out (dest^"test.file")); Sys.remove (dest^"test.file"); @@ -99,17 +118,18 @@ | "n" | "N" -> false | _ -> failwith "Invalid choice, exit."); in - if doc && not (Sys.file_exists "extlib-doc") then run (sprintf "mkdir %sextlib-doc" dest); - run (sprintf "ocamlc -c %s" (m_list ".mli")); + if doc && not (Sys.file_exists (sprintf "%sextlib-doc" dest)) then + run (sprintf "mkdir %sextlib-doc" dest); + run (sprintf "%s -c %s" ocamlc (m_list ".mli")); if byte then begin - List.iter (fun m -> run (sprintf "ocamlc -c %s.ml" m)) modules; - run (sprintf "ocamlc -a -o extLib.cma %s extLib.ml" (m_list ".cmo")); + List.iter (fun m -> run (sprintf "%s -c %s.ml" ocamlc m)) modules; + run (sprintf "%s -a -o extLib.cma %s extLib.ml" ocamlc (m_list ".cmo")); List.iter (fun m -> remove (m^".cmo")) modules; remove "extLib.cmo"; end; if native then begin - List.iter (fun m -> run (sprintf "ocamlopt -c %s.ml" m)) modules; - run (sprintf "ocamlopt -a -o extLib.cmxa %s extLib.ml" (m_list ".cmx")); + List.iter (fun m -> run (sprintf "%s -c %s.ml" ocamlopt m)) modules; + run (sprintf "%s -a -o extLib.cmxa %s extLib.ml" ocamlopt (m_list ".cmx")); List.iter (fun m -> remove (m^".cmx"); remove (m^obj_ext)) modules; remove "extLib.cmx"; remove ("extLib"^obj_ext); @@ -120,12 +140,32 @@ | PathDos -> sprintf "%s odoc_style.css %sextlib-doc\\style.css"; | PathUnix -> sprintf "%s odoc_style.css %sextlib-doc/style.css") cp_cmd dest); end; + if findlib then + let mlis = + String.concat + " " + (List.map (fun m -> m^".mli") modules) in + let cmis = + String.concat + " " + (List.map (fun m -> m^".cmi") modules) in + let cma = if byte then "extLib.cma" else "" in + let cmxa = if native then "extLib.cmxa" else "" in + if Sys.command + (sprintf + "ocamlfind install %s %s %s %s %s META" + name mlis cmis cma cmxa) + <> 0 + then failwith "installtion fails" + else () + else begin List.iter (fun m -> copy (m^".cmi") dest) modules; copy "extLib.cmi" dest; if byte then copy "extLib.cma" dest; if native then begin copy "extLib.cmxa" dest; copy ("extLib"^lib_ext) dest; + end end ;; |