Commit fd4c762b authored by Julien Lopez's avatar Julien Lopez

[MINOR] install_lib is now always compiling native code

	Add --bytecode option for configure
parent 1a63a8b2
......@@ -109,8 +109,10 @@ install_bin:
$(HIDE)mkdir -p $(BINDIR)
$(HIDE)$(INSTALL) -m755 $(INSTALL_BINARIES) $(BINDIR)/
install_lib:
install_lib: all
install_lib:
$(HIDE)$(MAKE) NATIVE=true all
@echo "Build META"
$(HIDE)(sed "s/%REQ%/$(PACKAGES)/" < META.in | sed "s/%VER%/$(VERSION)/" > META)
$(HIDE)-$(OCAMLFIND) remove cduce
......
......@@ -17,6 +17,7 @@ Defaults for the options are specified in brackets.
Options:
--help display this help and exit
--bytecode compile CDuce in bytecode instead of native
Optional features:
--with-FEATURE force support for FEATURE [default: autodetect]
......@@ -29,7 +30,7 @@ Optional features:
expat support for the expat XML parser
curl support for the libcurl library
netclient support for the netclient library
cgi support for the cgi library
cgi support for the cgi library
OCaml/CDuce interface:
--mliface=DIR build the interface with the OCaml sources in DIR
......@@ -44,11 +45,11 @@ if not_distrib then print_string "
--wprefix=WPREFIX root directory of the web-server [/var/www]
--cgidir=DIR install the cgi-bin interpreter in DIR [WPREFIX/cgi-bin]
--htmldir=DIR install the website in DIR [WPREFIX/html]
--sessiondir=DIR store the open sessions of the cgi-bin in DIR
--sessiondir=DIR store the open sessions of the cgi-bin in DIR
[/tmp/cduce_sessions]
"
let features =
let features =
[ "ocamlopt", ref `auto;
"mliface", ref `auto;
"pxp", ref `auto;
......@@ -57,8 +58,8 @@ let features =
"netclient", ref `auto;
"cgi", ref `auto;
"pxp_wlex", ref `no ]
let vars =
let vars =
[ "prefix", ref "/usr/local";
"bindir", ref "";
"mandir", ref "";
......@@ -69,12 +70,13 @@ let vars =
"htmldir", ref "";
"sessiondir", ref "/tmp/cduce_sessions";
"mliface", ref ""
"mliface", ref "";
]
let native = ref true
let src_dirs = ["/usr/src"; "/usr/local/src"; "/tmp"]
let fatal s = printf "*** Fatal error: %s\n" s; exit 1
let warning s = printf "* Warning: %s\n" s
......@@ -93,9 +95,10 @@ let start_with s p =
let ls = String.length s and lp = String.length p in
if (ls >= lp) && (String.sub s 0 lp = p)
then Some (String.sub s lp (ls - lp)) else None
let parse_arg s =
if s = "--help" then (usage (); exit 0)
else if s = "--bytecode" then native := false
else
match start_with s "--with-" with
| Some f -> (List.assoc f features) := `yes
......@@ -121,29 +124,29 @@ let print s = print_string s; flush stdout
let check_feature f p =
printf "%s: " f;
match !(List.assoc f features) with
| `no ->
| `no ->
print "disabled\n"; false
| `yes ->
| `yes ->
print "checking... ";
if p ()
then (print "ok\n"; true)
if p ()
then (print "ok\n"; true)
else (print "failed !\n"; fatal "Required feature is not available")
| `auto ->
| `auto ->
print "autodetecting... ";
if p ()
if p ()
then (print "enabled\n"; true)
else (print "disabled\n"; false)
let native =
check_feature "ocamlopt" (fun () -> command "ocamlfind ocamlopt")
let native =
check_feature "ocamlopt" (fun () -> command "ocamlfind ocamlopt") && !native
let check_pkg p () =
try
(* ignore (Findlib.package_property
[ (if native then "native" else "bytecode") ]
p "archive"); *)
command
(sprintf
command
(sprintf
"ocamlfind ocaml%s -package %s -linkpkg -o configure.try && rm -f configure.try"
(if native then "opt" else "c")
p)
......@@ -151,32 +154,32 @@ let check_pkg p () =
let need_pkg p =
printf "Checking for package %s... " p; flush stdout;
if not (check_pkg p ())
if not (check_pkg p ())
then (print "failed !\n"; fatal "Required package is not available")
else (print "ok\n")
let dir ?def d =
let dir ?def d =
let s = !(List.assoc d vars) in
if s <> "" then s
else match def with
| Some x -> x
else match def with
| Some x -> x
| None -> fatal (sprintf "%s cannot be empty" d)
let exe = match Sys.os_type with
let exe = match Sys.os_type with
| "Win32" ->
print "Win32 detected... executable will have .exe extension\n"; ".exe"
print "Win32 detected... executable will have .exe extension\n"; ".exe"
| "Cygwin" ->
print "Cygwin detected... executable will have .exe extension\n"; ".exe"
print "Cygwin detected... executable will have .exe extension\n"; ".exe"
| _ -> ""
let add_icon = match Sys.os_type with
let add_icon = match Sys.os_type with
| "Win32" | "Cygwin" -> true
| _ -> false
let check_mliface dir =
(* Sys.file_exists (Filename.concat dir "typing/types.ml") *)
Sys.file_exists (Filename.concat dir "typing/types.ml")
Sys.file_exists (Filename.concat dir "typing/types.ml")
let ocaml_stdlib () =
if (Sys.command "ocamlc -where > ocaml_stdlib" <> 0) then
......@@ -188,16 +191,16 @@ let ocaml_stdlib () =
s
let make_absolute dir =
if Filename.is_relative dir
if Filename.is_relative dir
then Filename.concat (Sys.getcwd ()) dir
else dir
let ml_interface =
let ml_interface =
let dir1 = !(List.assoc "mliface" vars) in
let dirs = if dir1 = "" then [] else [ make_absolute dir1 ] in
print "ocaml sources... ";
let rec loop = function
| [] ->
| [] ->
print "not found (the interface will not be built)\n";
None
| d::dirs ->
......@@ -206,7 +209,7 @@ let ml_interface =
else loop dirs
in
loop dirs
let pxp = check_feature "pxp" (check_pkg "pxp")
let expat = check_feature "expat" (check_pkg "expat")
let curl = check_feature "curl" (check_pkg "curl")
......@@ -222,9 +225,9 @@ let cgidir = dir ~def:(wprefix^"/cgi-bin") "cgidir"
let htmldir = dir ~def:(wprefix^"/html") "htmldir"
let sessiondir = dir "sessiondir"
let curl,netclient =
let curl,netclient =
match curl,netclient with
| true,true ->
| true,true ->
warning "Both netclient and curl are available. Will use curl.";
true,false
| false,false ->
......@@ -232,9 +235,9 @@ let curl,netclient =
false,false
| c,n -> c,n
let pxp,expat =
let pxp,expat =
match pxp,expat with
| true,true ->
| true,true ->
warning "Both PXP and expat are available. Will build both and use expat by default.";
true,true
| false,false ->
......
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