Commit 90afc7ba authored by Pietro Abate's avatar Pietro Abate

[r2004-04-23 13:17:18 by afrisch] Build oCaml_all.cma/cmxa ourselves

Original author: afrisch
Date: 2004-04-23 13:17:19+00:00
parent f4c80333
......@@ -9,8 +9,17 @@ NATIVE = true
PROFILE = false
# .mli/.cmi file support to interface CDuce with OCaml.
# possible values: false, flat, tree
# - if ML_INTERFACE=flat, set ML_MODULES to a directory that
# contains all the compiled modules from the directory
# utils, parsing, typing of the OCaml compilers
# - if ML_INTERFACE=tree, set ML_MODULES to a directory
# with three subdirectories utils/ parsing/ typing/
# that contain the compiled modules
# (see cdo2cmo/Makefile for more details)
# use wlex lexers for parsing XML files with PXP
PXP_WLEX = false
......@@ -74,7 +74,7 @@ else
LINK = $(CAMLC) -custom -linkpkg gramlib.cma
ifeq ($(ML_INTERFACE), true)
ifneq ($(ML_INTERFACE), false)
......@@ -187,6 +187,9 @@ cDuce_all.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
$(LINK) -a -o $@ cDuce_all.$(EXTENSION)
webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
$(LINK) -verbose $(INCLUDES) -o $@ $^ -ccopt -static
# webiface is made static to be able to move it more easily
......@@ -207,7 +210,7 @@ compute_depend: $(DEPEND_OCAMLDEP)
sed -e "s|: |: misc/q_symbol.cmo |" > depend
for i in $(CLEAN_DIRS); do \
(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *.a *.cmxa *~); \
(cd expat; $(MAKE) clean)
rm -f `find . -name "*~"`
......@@ -216,12 +219,13 @@ clean:
rm -f dtd2cduce pool webiface validate
rm -Rf prepro package
rm -f web/www/*.html web/*~
rm -f web/*.cdo
distclean: clean
rm -f Makefile.conf
.SUFFIXES: .ml .mli .cmo .cmi .cmx
# This Makefile generates oCaml_all.cma/.cmxa and put it in ..
# We need the units such that typing/types.cmo (.cmx)
# - If OCaml has been compiler in a directory DIR,
# you can do:
# make MODEL=tree PREFIX=DIR
# e.g.: make oCaml_all.cma MODEL=tree PREFIX=$HOME/ocaml-3.07
# - If you have a (flat) directory DIR will all the compiled units
# from utils/ parsing/ and typing/, you can do:
# make MODEL=flat PREFIX=DIR
# e.g.: make oCaml_all.cma MODEL=fal PREFIX=$HOME/godi/lib/ocaml/compiler-lib
OBJECTS=$(patsubst %,$(PREFIX)/%, $(UNITS))
......@@ -19,13 +30,13 @@ endif
ocamlc -pack -o oCaml_all.cmo $(OBJECTS)
ocamlc -a -o oCaml_all.cma oCaml_all.cmo
cp oCaml_all.cma oCaml_all.cmi ..
mv oCaml_all.cma oCaml_all.cmi ..
rm -f oCaml_all.*
ocamlopt -pack -o oCaml_all.cmx $(XOBJECTS)
ocamlopt -a -o oCaml_all.cmxa oCaml_all.cmx
cp oCaml_all.cmxa oCaml_all.cmi ..
mv oCaml_all.cmxa oCaml_all.a oCaml_all.cmi ..
rm -f oCaml_all.*
......@@ -19,12 +19,14 @@ Optional features:
Available features:
ocamlopt use ocamlopt instead of ocamlc to build CDuce
mliface support for the CDuce/OCaml interface
pxp_wlex use wlexers for parsing utf8 with PXP [default: false]
expat support for the expat XML parser
curl support for the libcurl library
netclient support for the netclient library
OCaml/CDuce interface:
--mliface=DIR build the interface
Installation directories:
--prefix=PREFIX install files in PREFIX [/usr/local]
--bindir=DIR install user executables in DIR [PREFIX/bin]
......@@ -54,11 +56,24 @@ let vars =
"cgidir", ref "";
"htmldir", ref "";
"sessiondir", ref "/tmp/cduce_sessions" ]
"sessiondir", ref "/tmp/cduce_sessions";
"mliface", ref ""
let fatal s = printf "*** Fatal error: %s\n" s; exit 1
let warning s = printf "* Warning: %s\n" s
let log s =
let oc = open_out_gen [ Open_append; Open_creat ] 0o600 "configure.log" in
output_string oc s;
output_char oc '\n';
close_out oc;
flush stdout
let command s =
log ("==> " ^ s);
Sys.command (sprintf "%s 2>> configure.log" s) = 0
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)
......@@ -81,34 +96,49 @@ let parse_arg s =
let () =
print_endline "Configuring CDuce for compilation...\n";
try for i = 1 to Array.length Sys.argv - 1 do parse_arg Sys.argv.(i) done
with Not_found -> usage (); fatal "Incorrect command line"
(try for i = 1 to Array.length Sys.argv - 1 do parse_arg Sys.argv.(i) done
with Not_found -> usage (); fatal "Incorrect command line");
(try Sys.remove "configure.log" with Sys_error _ -> ());
ignore (Sys.command "uname -a >> configure.log")
let print s = print_string s; flush stdout
let check_feature f p =
printf "%s: " f;
match !(List.assoc f features) with
| `no ->
printf "disabled\n"; false
print "disabled\n"; false
| `yes ->
printf "checking... ";
print "checking... ";
if p ()
then (printf "ok\n"; true)
else (printf "failed !\n"; fatal "Required feature is not available")
then (print "ok\n"; true)
else (print "failed !\n"; fatal "Required feature is not available")
| `auto ->
printf "autodetecting... ";
print "autodetecting... ";
if p ()
then (printf "enabled\n"; true)
else (printf "disabled\n"; false)
then (print "enabled\n"; true)
else (print "disabled\n"; false)
let native =
check_feature "ocamlopt" (fun () -> command "ocamlfind ocamlopt")
let check_pkg p () =
try ignore (Findlib.package_directory p); true
with Fl_package_base.No_such_package (_,_) -> false
(* ignore (Findlib.package_property
[ (if native then "native" else "bytecode") ]
p "archive"); *)
"ocamlfind ocaml%s -package %s -linkpkg -o /dev/null"
(if native then "opt" else "c")
with Not_found -> false
let need_pkg p =
printf "Checking for package %s... " p;
printf "Checking for package %s... " p; flush stdout;
if not (check_pkg p ())
then (printf "failed !\n"; fatal "Required package is not available")
else (printf "ok\n")
then (print "failed !\n"; fatal "Required package is not available")
else (print "ok\n")
let dir ?def d =
let s = !(List.assoc d vars) in
......@@ -118,13 +148,27 @@ let dir ?def d =
| None -> fatal (sprintf "%s cannot be empty" d)
let native =
check_feature "ocamlopt"
(fun () -> Sys.command "ocamlfind ocamlopt 2> /dev/null" = 0)
let exe = match Sys.os_type with
| "Cygwin" ->
print "Cygwin detected... executable will have .exe extension"; "exe"
| _ -> ""
let ml_interface =
check_feature "mliface"
(fun () ->
Sys.command "ocamlfind ocamlc -o /dev/null oCaml_all.cma 2> /dev/null" = 0)
let dir = !(List.assoc "mliface" vars) in
if dir = "" then `no
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)
if Sys.file_exists
(Filename.concat (Filename.concat dir "typing") file) then
(print "ok'n"; `tree dir)
(print "not found\n";
fatal ("Cannot find ocaml compiler compiled modules, eg:" ^ file))
let expat = check_feature "expat" (check_pkg "expat")
let curl = check_feature "curl" (check_pkg "curl")
let netclient = check_feature "netclient" (check_pkg "netclient")
......@@ -137,8 +181,6 @@ let cgidir = dir ~def:(wprefix^"/cgi-bin") "cgidir"
let htmldir = dir ~def:(wprefix^"/html") "htmldir"
let sessiondir = dir "sessiondir"
let exe = match Sys.os_type with "Cygwin" -> "exe" | _ -> ""
let curl,netclient =
match curl,netclient with
| true,true ->
......@@ -159,12 +201,15 @@ let () =
List.iter need_pkg required_packages;
if not pxp_wlex then need_pkg "pxp-lex-utf8";
print_endline "Creating Makefile.conf...";
print "Creating Makefile.conf...\n";
let out = open_out "Makefile.conf" in
fprintf out "# This file has been generated by the configure script\n";
fprintf out "NATIVE=%b\n" native;
fprintf out "ML_INTERFACE=%b\n" ml_interface;
(match ml_interface with
| `no -> fprintf out "ML_INTERFACE=false\n"
| `flat d -> fprintf out "ML_INTERFACE=flat\nML_MODULES=%s\n" d
| `tree d -> fprintf out "ML_INTERFACE=tree\nML_MODULES=%s\n" d);
fprintf out "EXPAT=%b\n" expat;
fprintf out "CURL=%b\n" curl;
fprintf out "NETCLIENT=%b\n" netclient;
......@@ -110,8 +110,8 @@ schema/schema_parser.cmx: misc/q_symbol.cmo misc/encodings.cmx types/intervals.c
runtime/value.cmx schema/schema_parser.cmi
parser/location.cmo: misc/q_symbol.cmo parser/location.cmi
parser/location.cmx: misc/q_symbol.cmo parser/location.cmi
parser/url.cmo: misc/q_symbol.cmo parser/location.cmi parser/url.cmi
parser/url.cmx: misc/q_symbol.cmo parser/location.cmx parser/url.cmi
parser/url.cmo: misc/q_symbol.cmo parser/url.cmi
parser/url.cmx: misc/q_symbol.cmo parser/url.cmi
parser/ulexer.cmo: misc/q_symbol.cmo parser/ulexer.cmi
parser/ulexer.cmx: misc/q_symbol.cmo parser/ulexer.cmi
parser/ast.cmo: misc/q_symbol.cmo types/builtin_defs.cmi types/chars.cmi types/ident.cmo \
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