Commit 9caed0a7 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-07-05 14:15:03 by afrisch] auto find compiler-lib (e.g. for GODI)

Original author: afrisch
Date: 2004-07-05 14:15:03+00:00
parent 1f94d397
#use "topfind";; #use "topfind";;
#require "findlib";; #require "findlib";;
#require "unix";;
open Printf open Printf
let usage () = let usage () =
...@@ -156,44 +158,45 @@ let exe = match Sys.os_type with ...@@ -156,44 +158,45 @@ let exe = match Sys.os_type with
print "Cygwin detected... executable will have .exe extension"; "exe" print "Cygwin detected... executable will have .exe extension"; "exe"
| _ -> "" | _ -> ""
let rec search_sources source_list = let check_mliface dir =
match source_list with log ("Looking for ocaml modules in " ^ dir);
| [] -> (print "\ let file = if native then "types.cmx" else "types.cmo" in
* Warning: no OCaml sources found in standard locations\n\ if Sys.file_exists (Filename.concat dir file)
* Warning: please specify the source location with --mliface option\n\ then `flat
* Warning: OCaml interface will not be compiled\n"; "") else
| dir :: tail -> if Sys.file_exists
print ("Looking for Ocaml sources in " ^ dir ^" ...\n"); flush stdout; (Filename.concat (Filename.concat dir "typing") file) then
if Sys.command ("find " ^ dir ^ " -maxdepth 3 -name ocamlcomp.sh -fprintf .try %h 2> /dev/null") = 0 `tree
then try else
let result = input_line (open_in ".try") in `not_found
ignore(Sys.command "rm .try") ;
print ("Found OCaml sources in" ^ result ^ "\n");
result
with End_of_file -> search_sources tail
else search_sources tail
let ocaml_stdlib () =
let ic = Unix.open_process_in "ocamlc -where" in
let s = input_line ic in
close_in ic;
s
let ml_interface = let ml_interface =
let dir1 = !(List.assoc "mliface" vars) in let dir1 = !(List.assoc "mliface" vars) in
let dir = (if Sys.file_exists "/opt/godi/lib/ocaml/compiler-lib" then let dirs =
"/opt/godi/lib/ocaml/compiler-lib" let std = ocaml_stdlib () in
else if dir1 = "" then let d = Filename.concat (Filename.chop_suffix std "std-lib")
search_sources src_dirs else dir1) in "compiler-lib" in
if dir = "" then `no d :: src_dirs in
else let dirs = if dir1 = "" then dirs else dir1 :: dirs in
let file = if native then "types.cmx" else "types.cmo" in print "Looking for ocaml compiler modules ...";
printf "Checking for ocaml compiler modules ..."; flush stdout; let rec loop = function
if Sys.file_exists (Filename.concat dir file) | [] ->
then (print "ok (flat model)\n"; `flat dir) print "not found\n";
else `no
if Sys.file_exists | d::dirs ->
(Filename.concat (Filename.concat dir "typing") file) then match check_mliface d with
(print "ok'\n"; `tree dir) | `flat -> print ("flat model: " ^ d ^ "\n"); `flat d
else | `tree -> print ("tree model: " ^ d ^ "\n"); `tree d
(print "not found\n"; | `not_found -> loop dirs
fatal ("Cannot find ocaml compiler compiled modules, eg: " ^ file ^ in
"\n*** try configure with the option --mliface=DIR")) loop dirs
let expat = check_feature "expat" (check_pkg "expat") let expat = check_feature "expat" (check_pkg "expat")
let curl = check_feature "curl" (check_pkg "curl") let curl = check_feature "curl" (check_pkg "curl")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment