Commit 19f26192 authored by Pietro Abate's avatar Pietro Abate
Browse files

[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 98c6f80e
...@@ -9,8 +9,17 @@ NATIVE = true ...@@ -9,8 +9,17 @@ NATIVE = true
PROFILE = false PROFILE = false
# .mli/.cmi file support to interface CDuce with OCaml. # .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)
ML_INTERFACE = false ML_INTERFACE = false
# use wlex lexers for parsing XML files with PXP # use wlex lexers for parsing XML files with PXP
PXP_WLEX = false PXP_WLEX = false
......
...@@ -74,7 +74,7 @@ else ...@@ -74,7 +74,7 @@ else
LINK = $(CAMLC) -custom -linkpkg gramlib.cma LINK = $(CAMLC) -custom -linkpkg gramlib.cma
endif endif
ifeq ($(ML_INTERFACE), true) ifneq ($(ML_INTERFACE), false)
SYNTAX += -symbol ML_INTERFACE= SYNTAX += -symbol ML_INTERFACE=
ML_LIB = oCaml_all.$(EXTENSION_LIB) ML_LIB = oCaml_all.$(EXTENSION_LIB)
ML_INTERFACE_OBJ = \ ML_INTERFACE_OBJ = \
...@@ -187,6 +187,9 @@ cDuce_all.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION)) ...@@ -187,6 +187,9 @@ cDuce_all.$(EXTENSION_LIB): $(OBJECTS:.cmo=.$(EXTENSION))
$(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^ $(COMPILE) -o cDuce_all.$(EXTENSION) -pack $^
$(LINK) -a -o $@ cDuce_all.$(EXTENSION) $(LINK) -a -o $@ cDuce_all.$(EXTENSION)
oCaml_all.$(EXTENSION_LIB):
cd cdo2cmo; $(MAKE) PREFIX=$(ML_MODULES) MODEL=$(ML_INTERFACE) $@
webiface: $(WEBIFACE:.cmo=.$(EXTENSION)) webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
$(LINK) -verbose $(INCLUDES) -o $@ $^ -ccopt -static $(LINK) -verbose $(INCLUDES) -o $@ $^ -ccopt -static
# webiface is made static to be able to move it more easily # webiface is made static to be able to move it more easily
...@@ -207,7 +210,7 @@ compute_depend: $(DEPEND_OCAMLDEP) ...@@ -207,7 +210,7 @@ compute_depend: $(DEPEND_OCAMLDEP)
sed -e "s|: |: misc/q_symbol.cmo |" > depend sed -e "s|: |: misc/q_symbol.cmo |" > depend
clean: clean:
for i in $(CLEAN_DIRS); do \ 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 *~); \
done done
(cd expat; $(MAKE) clean) (cd expat; $(MAKE) clean)
rm -f `find . -name "*~"` rm -f `find . -name "*~"`
...@@ -216,12 +219,13 @@ clean: ...@@ -216,12 +219,13 @@ clean:
rm -f dtd2cduce pool webiface validate rm -f dtd2cduce pool webiface validate
rm -Rf prepro package rm -Rf prepro package
rm -f web/www/*.html web/*~ rm -f web/www/*.html web/*~
rm -f web/*.cdo rm -f web/*.cdo
distclean: clean distclean: clean
rm -f Makefile.conf rm -f Makefile.conf
$(ML_INTERFACE_OBJ:.cmo=.$(EXTENSION)): oCaml_all.$(EXTENSION_LIB)
.SUFFIXES: .ml .mli .cmo .cmi .cmx .SUFFIXES: .ml .mli .cmo .cmi .cmx
......
PREFIX=/home/frisch/tmp/ocaml-3.07 # This Makefile generates oCaml_all.cma/.cmxa and put it in ..
MODEL=tree #
# 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)) OBJECTS=$(patsubst %,$(PREFIX)/%, $(UNITS))
XOBJECTS=$(OBJECTS:.cmo=.cmx) XOBJECTS=$(OBJECTS:.cmo=.cmx)
...@@ -19,13 +30,13 @@ endif ...@@ -19,13 +30,13 @@ endif
oCaml_all.cma: oCaml_all.cma:
ocamlc -pack -o oCaml_all.cmo $(OBJECTS) ocamlc -pack -o oCaml_all.cmo $(OBJECTS)
ocamlc -a -o oCaml_all.cma oCaml_all.cmo 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.* rm -f oCaml_all.*
oCaml_all.cmxa: oCaml_all.cmxa:
ocamlopt -pack -o oCaml_all.cmx $(XOBJECTS) ocamlopt -pack -o oCaml_all.cmx $(XOBJECTS)
ocamlopt -a -o oCaml_all.cmxa oCaml_all.cmx 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.* rm -f oCaml_all.*
clean: clean:
......
...@@ -19,12 +19,14 @@ Optional features: ...@@ -19,12 +19,14 @@ Optional features:
Available features: Available features:
ocamlopt use ocamlopt instead of ocamlc to build CDuce 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] pxp_wlex use wlexers for parsing utf8 with PXP [default: false]
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
OCaml/CDuce interface:
--mliface=DIR build the interface
Installation directories: Installation directories:
--prefix=PREFIX install files in PREFIX [/usr/local] --prefix=PREFIX install files in PREFIX [/usr/local]
--bindir=DIR install user executables in DIR [PREFIX/bin] --bindir=DIR install user executables in DIR [PREFIX/bin]
...@@ -54,11 +56,24 @@ let vars = ...@@ -54,11 +56,24 @@ let vars =
"cgidir", ref ""; "cgidir", ref "";
"htmldir", 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 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
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 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)
...@@ -81,34 +96,49 @@ let parse_arg s = ...@@ -81,34 +96,49 @@ let parse_arg s =
let () = let () =
print_endline "Configuring CDuce for compilation...\n"; print_endline "Configuring CDuce for compilation...\n";
try for i = 1 to Array.length Sys.argv - 1 do parse_arg Sys.argv.(i) done (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" 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 = 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 ->
printf "disabled\n"; false print "disabled\n"; false
| `yes -> | `yes ->
printf "checking... "; print "checking... ";
if p () if p ()
then (printf "ok\n"; true) then (print "ok\n"; true)
else (printf "failed !\n"; fatal "Required feature is not available") else (print "failed !\n"; fatal "Required feature is not available")
| `auto -> | `auto ->
printf "autodetecting... "; print "autodetecting... ";
if p () if p ()
then (printf "enabled\n"; true) then (print "enabled\n"; true)
else (printf "disabled\n"; false) else (print "disabled\n"; false)
let native =
check_feature "ocamlopt" (fun () -> command "ocamlfind ocamlopt")
let check_pkg p () = let check_pkg p () =
try ignore (Findlib.package_directory p); true try
with Fl_package_base.No_such_package (_,_) -> false (* ignore (Findlib.package_property
[ (if native then "native" else "bytecode") ]
p "archive"); *)
command
(sprintf
"ocamlfind ocaml%s -package %s -linkpkg -o /dev/null"
(if native then "opt" else "c")
p)
with Not_found -> false
let need_pkg p = let need_pkg p =
printf "Checking for package %s... " p; printf "Checking for package %s... " p; flush stdout;
if not (check_pkg p ()) if not (check_pkg p ())
then (printf "failed !\n"; fatal "Required package is not available") then (print "failed !\n"; fatal "Required package is not available")
else (printf "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
...@@ -118,13 +148,27 @@ let dir ?def d = ...@@ -118,13 +148,27 @@ let dir ?def d =
| None -> fatal (sprintf "%s cannot be empty" d) | None -> fatal (sprintf "%s cannot be empty" d)
let native = let exe = match Sys.os_type with
check_feature "ocamlopt" | "Cygwin" ->
(fun () -> Sys.command "ocamlfind ocamlopt 2> /dev/null" = 0) print "Cygwin detected... executable will have .exe extension"; "exe"
| _ -> ""
let ml_interface = let ml_interface =
check_feature "mliface" let dir = !(List.assoc "mliface" vars) in
(fun () -> if dir = "" then `no
Sys.command "ocamlfind ocamlc -o /dev/null oCaml_all.cma 2> /dev/null" = 0) 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))
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")
let netclient = check_feature "netclient" (check_pkg "netclient") let netclient = check_feature "netclient" (check_pkg "netclient")
...@@ -137,8 +181,6 @@ let cgidir = dir ~def:(wprefix^"/cgi-bin") "cgidir" ...@@ -137,8 +181,6 @@ 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 exe = match Sys.os_type with "Cygwin" -> "exe" | _ -> ""
let curl,netclient = let curl,netclient =
match curl,netclient with match curl,netclient with
| true,true -> | true,true ->
...@@ -159,12 +201,15 @@ let () = ...@@ -159,12 +201,15 @@ let () =
List.iter need_pkg required_packages; List.iter need_pkg required_packages;
if not pxp_wlex then need_pkg "pxp-lex-utf8"; 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 let out = open_out "Makefile.conf" in
fprintf out "# This file has been generated by the configure script\n"; fprintf out "# This file has been generated by the configure script\n";
fprintf out "NATIVE=%b\n" native; 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 "EXPAT=%b\n" expat;
fprintf out "CURL=%b\n" curl; fprintf out "CURL=%b\n" curl;
fprintf out "NETCLIENT=%b\n" netclient; fprintf out "NETCLIENT=%b\n" netclient;
......
...@@ -110,8 +110,8 @@ schema/schema_parser.cmx: misc/q_symbol.cmo misc/encodings.cmx types/intervals.c ...@@ -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 runtime/value.cmx schema/schema_parser.cmi
parser/location.cmo: misc/q_symbol.cmo parser/location.cmi parser/location.cmo: misc/q_symbol.cmo parser/location.cmi
parser/location.cmx: 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.cmo: misc/q_symbol.cmo parser/url.cmi
parser/url.cmx: misc/q_symbol.cmo parser/location.cmx 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.cmo: misc/q_symbol.cmo parser/ulexer.cmi
parser/ulexer.cmx: 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 \ 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