Commit d890640f authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-23 18:41:10 by cvscast] Makefile and co

Original author: cvscast
Date: 2003-05-23 18:41:11+00:00
parent ddc258c0
...@@ -54,19 +54,14 @@ Important notes: ...@@ -54,19 +54,14 @@ Important notes:
CDuce requires a development version >= 1.1.93. CDuce requires a development version >= 1.1.93.
Less important: Efficiency issues:
- OCamlnet: if you plan to load XML file with encodings other than - OCamlnet: if you plan to load XML file with encodings other than
UTF-8, it is advised to used to CVS version of OCamlnet: UTF-8, it is advised to use the CVS version of OCamlnet:
http://sourceforge.net/cvs/?group_id=19774 http://sourceforge.net/cvs/?group_id=19774
Indeed, the netconversion module in the lastest release (0.95) was Indeed, the netconversion module in the lastest release (0.95) was
very slow, and it has been rewritten since then. very slow, and it has been rewritten since then.
- PXP: you don't need to build all the encodings.
./configure -lexlist iso88591 -with-wlex
should be enough in general.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Compilation Compilation
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
...@@ -74,15 +69,33 @@ Compilation ...@@ -74,15 +69,33 @@ Compilation
You need a GNU Make (or equivalent) to use the Makefile from the You need a GNU Make (or equivalent) to use the Makefile from the
distribution. It defines the following goals: distribution. It defines the following goals:
- make cduce / cduce.opt - make cduce
compiles the CDuce command line interpreter compiles the CDuce command line interpreter
- make dtd2cduce - make dtd2cduce
compiles the dtd2cduce tools (converts DTD to CDuce types) compiles the dtd2cduce tools (converts DTD to CDuce types)
- make webiface / webiface.opt - make webiface
compiles the CDuce web interface interpreter (to be used as a CGI script) compiles the CDuce web interface interpreter (to be used as a CGI script)
- make local_website - make local_website
compiles in the web/ directory the HTML files of CDuce website compiles in the web/www/ subdirectory the HTML files of CDuce website
(including the tutorial) (including the tutorial)
- make all
equivalent to (make cduce; make dtd2cduce; make local_website)
Makefile accepts the following options, which can take the values
true or false.
NATIVE=true : use the OCaml native code compiler (ocamlopt) to build CDuce
NATIVE=false : use the OCaml bytecode compiler (ocamlc)
default: true (the native code version is much faster)
PXP_WLEX=true : use wlex for parsing UTF-8 XML files
PXP_WLEX=false: use ocamllex for parsing UTF-8 XML files
default: false (ocamllex is faster; wlex is more compact)
E.g.:
make cduce NATIVE=false
\ No newline at end of file
DEBUG = -g NATIVE = true
OCAMLCP = ocamlc PROFILE = false
OCAMLC = ocamlfind $(OCAMLCP) -package $(PACKAGES) PXP_WLEX = false
OCAMLOPT = ocamlfind ocamlopt -package $(PACKAGES)
# extra options:
# -p (profiling)
# -inline 25
PACKAGES = "pxp-engine pxp-lex-iso88591 pxp-lex-utf8 wlexing camlp4 num,cgi" PACKAGES = -package "pxp-engine pxp-lex-iso88591 wlexing camlp4 num cgi"
ifeq ($(PXP_WLEX), true)
PACKAGES += -package pxp-wlex-utf8
else
PACKAGES += -package pxp-lex-utf8
endif
DISTRIB = $(DIRS) tools web depend INSTALL LICENSE README Makefile SYNTAX = camlp4o pa_extend.cmo
all: cduce.opt dtd2cduce local_website ifeq ($(PROFILE), true)
CAMLC_P = ocamlcp -p a
CAMLOPT_P = ocamlopt -p
SYNTAX_PARSER =
else
CAMLC_P = ocamlc
CAMLOPT_P = ocamlopt
SYNTAX_PARSER = -pp '$(SYNTAX)'
endif
CAMLC = ocamlfind $(CAMLC_P) $(PACKAGES)
CAMLOPT = ocamlfind $(CAMLOPT_P) $(PACKAGES)
ifeq ($(NATIVE), true)
EXTENSION = cmx
LINK = $(CAMLOPT) -linkpkg gramlib.cmxa
else
EXTENSION = cmo
LINK = $(CAMLC) -custom -linkpkg gramlib.cma
endif
all: cduce dtd2cduce local_website
# Source directories # Source directories
...@@ -38,32 +60,23 @@ OBJECTS = \ ...@@ -38,32 +60,23 @@ OBJECTS = \
CDUCE = $(OBJECTS) driver/run.cmo CDUCE = $(OBJECTS) driver/run.cmo
WEBIFACE = $(OBJECTS) driver/examples.cmo driver/webiface.cmo WEBIFACE = $(OBJECTS) driver/examples.cmo driver/webiface.cmo
DTD2CDUCE = tools/dtd2cduce.cmo
XCDUCE = $(CDUCE:.cmo=.cmx)
XWEBIFACE = $(WEBIFACE:.cmo=.cmx)
DEPEND = $(DIRS:=/*.ml) $(DIRS:=/*.mli) DEPEND = $(DIRS:=/*.ml) $(DIRS:=/*.mli)
INCLUDES = $(DIRS:%=-I %) INCLUDES = $(DIRS:%=-I %)
SYNTAX = camlp4o pa_extend.cmo
SYNTAX_PARSER = -pp '$(SYNTAX)'
PREPRO = $(SYNTAX) pr_o.cmo PREPRO = $(SYNTAX) pr_o.cmo
cduce: $(CDUCE) cduce: $(CDUCE:.cmo=.$(EXTENSION))
$(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $^ $(LINK) -o $@ $^
webiface: $(WEBIFACE)
$(OCAMLC) $(DEBUG) -linkpkg -o $@ gramlib.cma $^
dtd2cduce: tools/dtd2cduce.cmo
$(OCAMLC) $(DEBUG) -linkpkg -o $@ $^
cduce.opt: $(XCDUCE) webiface: $(WEBIFACE:.cmo=.$(EXTENSION))
$(OCAMLOPT) -linkpkg -o $@ gramlib.cmxa $^ $(LINK) -o $@ $^
webiface.opt: $(XWEBIFACE) dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION))
$(OCAMLOPT) -linkpkg -o $@ gramlib.cmxa $^ $(LINK) -o $@ $^
.PHONY: compute_depend
compute_depend: compute_depend:
@echo "Computing dependencies ..." @echo "Computing dependencies ..."
ocamldep $(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend ocamldep $(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend
...@@ -76,7 +89,7 @@ clean: ...@@ -76,7 +89,7 @@ clean:
(cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \ (cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \
done done
rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~
rm -f cduce cduce.opt webiface.opt ocamlprof.dump rm -f cduce ocamlprof.dump
rm -f dtd2cduce pool webiface rm -f dtd2cduce pool webiface
rm -Rf prepro package rm -Rf prepro package
rm -f web/www/*.php web/www/*.html web/*~ rm -f web/www/*.php web/www/*.html web/*~
...@@ -85,23 +98,23 @@ clean: ...@@ -85,23 +98,23 @@ clean:
.SUFFIXES: .ml .mli .cmo .cmi .cmx .SUFFIXES: .ml .mli .cmo .cmi .cmx
.ml.cmo: .ml.cmo:
$(OCAMLC) $(DEBUG) -c $(SYNTAX_PARSER) $(INCLUDES) $< $(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
.ml.cmx: .ml.cmx:
$(OCAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $< $(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $<
.mli.cmi: .mli.cmi:
$(OCAMLC) $(DEBUG) -c $(SYNTAX_PARSER) $(INCLUDES) $< $(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $<
include depend include depend
# CDuce-generated files # CDuce-generated files
driver/examples.ml: cduce.opt web/examples/build.cd web/examples/examples.xml driver/examples.ml: cduce web/examples/build.cd web/examples/examples.xml
(cd web/examples; ../../cduce.opt -quiet build.cd) (cd web/examples; ../../cduce -quiet build.cd)
web/files: cduce.opt web/site.cd web/files: cduce web/site.cd
(cd web; ../cduce.opt -quiet site.cd -- -php site.xml) (cd web; ../cduce -quiet site.cd -- -php site.xml)
# Packaging # Packaging
...@@ -113,17 +126,8 @@ remove_header: ...@@ -113,17 +126,8 @@ remove_header:
# For development # For development
pull: tools/pull.cmo pull: tools/pull.$(EXTENSION)
$(OCAMLC) $(DEBUG) -linkpkg -o $@ $^ $(LINK) -o $@ $^
all.cma: $(OBJECTS)
$(OCAMLC) $(DEBUG) -o $@ -linkpkg gramlib.cma -a $(OBJECTS)
test: all.cma
fort all.cma -I +fort $(INCLUDES) tests/test_fort.ml
run_top: all.cma
ledit ocaml $(INCLUDES) `ocamlfind use pxp` all.cma
profile: profile:
rm -Rf prepro rm -Rf prepro
...@@ -139,28 +143,30 @@ profile: ...@@ -139,28 +143,30 @@ profile:
done done
cp parser/wlexer.mll prepro/parser/ cp parser/wlexer.mll prepro/parser/
cp Makefile depend prepro/ cp Makefile depend prepro/
(cd prepro; make cduce OCAMLCP="ocamlcp -p a" SYNTAX_PARSER=) (cd prepro; make cduce PROFILE=true SYNTAX_PARSER= NATIVE=false)
# Site-specific installation # Site-specific installation
cedre_build: cedre_build:
rsh cedre ". .env; cd IMPLEM/CDUCE; make webiface.opt; make web/files" rsh cedre ". .env; cd IMPLEM/CDUCE; make webiface; make web/files"
install_web: install_web:
scp web/www/*.php web/cduce.css cduce@iris:public_html/ scp web/www/*.php web/cduce.css cduce@iris:public_html/
scp webiface.opt cduce@iris:cgi-bin/cduce scp webiface cduce@iris:cgi-bin/cduce
ssh cduce@iris "chmod +s cgi-bin/cduce" ssh cduce@iris "chmod +s cgi-bin/cduce"
install_web_local: install_web_local:
ssh root@localhost "cp -f ~beppe/IMPLEM/CDUCE/webiface.opt /var/www/cgi-bin/cduce; cp -f ~beppe/IMPLEM/CDUCE/web/www/*.php /var/www/html/; chmod +s /var/www/cgi-bin/cduce;" ssh root@localhost "cp -f ~beppe/IMPLEM/CDUCE/webiface /var/www/cgi-bin/cduce; cp -f ~beppe/IMPLEM/CDUCE/web/www/*.php /var/www/html/; chmod +s /var/www/cgi-bin/cduce;"
website: web/files website: web/files
scp web/www/*.php web/cduce.css cduce@iris:public_html/ scp web/www/*.php web/cduce.css cduce@iris:public_html/
local_website: cduce.opt webiface.opt local_website: cduce
(cd web; ../cduce.opt -quiet site.cd -- site.xml) (cd web; ../cduce -quiet site.cd -- site.xml)
# Distribution # Distribution
DISTRIB = $(DIRS) tools web depend INSTALL CHANGES LICENSE README Makefile
.PHONY: package .PHONY: package
package: package:
rm -Rf package rm -Rf package
......
...@@ -49,7 +49,9 @@ let attrib att = ...@@ -49,7 +49,9 @@ let attrib att =
let elem tag att child = let elem tag att child =
Xml (Atom (Atoms.mk (U.mk tag)), Pair (Record (attrib att), child)) Xml (Atom (Atoms.mk (U.mk tag)), Pair (Record (attrib att), child))
(*
class warner = object method warn w = print_endline ("PXP WARNING: " ^ w) end class warner = object method warn w = print_endline ("PXP WARNING: " ^ w) end
*)
type token = type token =
| Element of Value.t | Element of Value.t
......
...@@ -87,7 +87,7 @@ let import_dtd ppf name filename = ...@@ -87,7 +87,7 @@ let import_dtd ppf name filename =
content (e # content_model) content (e # content_model)
in in
let dtd = parse_dtd_entity default_config (from_file filename) in let dtd = parse_dtd_entity { default_config with encoding = `Enc_utf8 } (from_file filename) in
Format.fprintf ppf Format.fprintf ppf
"(* This type has been automatically generated from %s by dtd2cduce *)@\n" "(* This type has been automatically generated from %s by dtd2cduce *)@\n"
filename; filename;
......
...@@ -94,13 +94,14 @@ let fun split_comma (String -> [String*]) ...@@ -94,13 +94,14 @@ let fun split_comma (String -> [String*])
The function patch_css search for the textual representation of this The function patch_css search for the textual representation of this
element and replace it with the PHP code. **) element and replace it with the PHP code. **)
let css : String = let css : Latin1 =
['<link rel="stylesheet" href="cduce.css" type="text/css">'];; ['<link rel="stylesheet" href="cduce.css" type="text/css">'];;
let fun protect_quote (s : String) : String = let fun protect_quote (s : Latin1) : Latin1 =
transform s with '"' -> [ '\\"' ] | c -> [c];; transform s with '"' -> [ '\\"' ] | c -> [c];;
let php_css : Latin1 = let php_css : Latin1 =
if php then
[' <?php [' <?php
$browser = getenv("HTTP_USER_AGENT"); $browser = getenv("HTTP_USER_AGENT");
if (preg_match("/MSIE/i", "$browser")) { if (preg_match("/MSIE/i", "$browser")) {
...@@ -117,7 +118,8 @@ type=\\"text/css\\">"; ...@@ -117,7 +118,8 @@ type=\\"text/css\\">";
type=\\"text/css\\">"; type=\\"text/css\\">";
} }
echo "$css"; echo "$css";
?> '];; ?> ']
else css;;
(** It does not work with IE (** It does not work with IE
if php then if php then
......
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