Commit fd4c762b authored by Julien Lopez's avatar Julien Lopez
Browse files

[MINOR] install_lib is now always compiling native code

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