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

[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";;
#require "findlib";;
#require "unix";;
open Printf
let usage () =
......@@ -156,44 +158,45 @@ let exe = match Sys.os_type with
print "Cygwin detected... executable will have .exe extension"; "exe"
| _ -> ""
let rec search_sources source_list =
match source_list with
| [] -> (print "\
* Warning: no OCaml sources found in standard locations\n\
* Warning: please specify the source location with --mliface option\n\
* Warning: OCaml interface will not be compiled\n"; "")
| dir :: tail ->
print ("Looking for Ocaml sources in " ^ dir ^" ...\n"); flush stdout;
if Sys.command ("find " ^ dir ^ " -maxdepth 3 -name ocamlcomp.sh -fprintf .try %h 2> /dev/null") = 0
then try
let result = input_line (open_in ".try") in
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 check_mliface dir =
log ("Looking for ocaml modules in " ^ dir);
let file = if native then "types.cmx" else "types.cmo" in
if Sys.file_exists (Filename.concat dir file)
then `flat
else
if Sys.file_exists
(Filename.concat (Filename.concat dir "typing") file) then
`tree
else
`not_found
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 dir1 = !(List.assoc "mliface" vars) in
let dir = (if Sys.file_exists "/opt/godi/lib/ocaml/compiler-lib" then
"/opt/godi/lib/ocaml/compiler-lib"
else if dir1 = "" then
search_sources src_dirs else dir1) in
if dir = "" then `no
else
let file = if native then "types.cmx" else "types.cmo" in
printf "Checking for ocaml compiler modules ..."; flush stdout;
if Sys.file_exists (Filename.concat dir file)
then (print "ok (flat model)\n"; `flat dir)
else
if Sys.file_exists
(Filename.concat (Filename.concat dir "typing") file) then
(print "ok'\n"; `tree dir)
else
(print "not found\n";
fatal ("Cannot find ocaml compiler compiled modules, eg: " ^ file ^
"\n*** try configure with the option --mliface=DIR"))
let dirs =
let std = ocaml_stdlib () in
let d = Filename.concat (Filename.chop_suffix std "std-lib")
"compiler-lib" in
d :: src_dirs in
let dirs = if dir1 = "" then dirs else dir1 :: dirs in
print "Looking for ocaml compiler modules ...";
let rec loop = function
| [] ->
print "not found\n";
`no
| d::dirs ->
match check_mliface d with
| `flat -> print ("flat model: " ^ d ^ "\n"); `flat d
| `tree -> print ("tree model: " ^ d ^ "\n"); `tree d
| `not_found -> loop dirs
in
loop dirs
let expat = check_feature "expat" (check_pkg "expat")
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