--- Makefile 2007/07/10 16:56:57 4 +++ Makefile 2007/07/10 17:32:50 414 @@ -1,53 +1,177 @@ -PARSER = parser/location.cmo parser/ast.cmo parser/parser.cmo +NATIVE = true +PROFILE = false +PXP_WLEX = false + +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 + +SYNTAX = camlp4o pa_extend.cmo + +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 + +DIRS = misc parser typing types runtime driver +CLEAN_DIRS = $(DIRS) tools tests + +# Objects to build + +OBJECTS = \ + misc/state.cmo misc/pool.cmo misc/encodings.cmo misc/bool.cmo \ + misc/pretty.cmo \ + \ + types/sortedList.cmo types/boolean.cmo types/ident.cmo \ + types/intervals.cmo types/chars.cmo types/atoms.cmo types/normal.cmo \ + types/types.cmo types/patterns.cmo types/sequence.cmo types/builtin.cmo \ + types/sample.cmo \ + \ + parser/location.cmo parser/wlexer.cmo parser/ast.cmo parser/parser.cmo \ + \ + typing/typed.cmo typing/typer.cmo \ + \ + runtime/value.cmo runtime/load_xml.cmo runtime/run_dispatch.cmo \ + runtime/print_xml.cmo runtime/eval.cmo \ + \ + driver/cduce.cmo + +CDUCE = $(OBJECTS) driver/run.cmo +WEBIFACE = $(OBJECTS) driver/examples.cmo driver/webiface.cmo +DTD2CDUCE = tools/dtd2cduce.cmo + +DEPEND = $(DIRS:=/*.ml) $(DIRS:=/*.mli) +INCLUDES = $(DIRS:%=-I %) + +PREPRO = $(SYNTAX) pr_o.cmo + +cduce: $(CDUCE:.cmo=.$(EXTENSION)) + $(LINK) -o $@ $^ -TYPING = typing/parse_pat.cmo typing/typed.cmo +webiface: $(WEBIFACE:.cmo=.$(EXTENSION)) + $(LINK) -o $@ $^ -TYPES = types/recursive.cmo types/sortedList.cmo \ - types/sortedMap.cmo types/boolean.cmo \ - types/intervals.cmo types/atoms.cmo \ - types/strings.cmo types/types.cmo \ - types/patterns.cmo - -DIRS = parser typing types - -OBJECTS = $(TYPES) $(PARSER) $(TYPING) -DEPEND = parser/*.ml parser/*.mli typing/*.ml typing/*.mli types/*.ml types/*.mli -INCLUDES = -I +camlp4 -I parser -I types - -SYNTAX_PARSER = -pp 'camlp4o pa_extend.cmo' - -all.cma: $(OBJECTS) - ocamlc -o all.cma -I +camlp4 gramlib.cma -a $(OBJECTS) +dtd2cduce: $(DTD2CDUCE:.cmo=.$(EXTENSION)) + $(LINK) -o $@ $^ +.PHONY: compute_depend compute_depend: @echo "Computing dependencies ..." ocamldep $(INCLUDES) $(SYNTAX_PARSER) $(DEPEND) > depend -run_top: all.cma - ledit ocaml $(INCLUDES) all.cma +parser/wlexer.ml: parser/wlexer.mll + wlex parser/wlexer.mll clean: - (cd parser; rm -f *.cmi *.cmo *.cma *~) - (cd types; rm -f *.cmi *.cmo *.cma *~) - (cd typing; rm -f *.cmi *.cmo *.cma *~) - rm -f *.cmi *.cmo *.cma *~ + for i in $(CLEAN_DIRS); do \ + (cd $$i; rm -f *.cmi *.cmo *.cma *.cmx *.o *~); \ + done + rm -f *.cmi *.cmo *.cma *.cmx *.a *.cmxa *.o *~ + rm -f cduce ocamlprof.dump + rm -f dtd2cduce pool webiface + rm -Rf prepro package + rm -f web/www/*.php web/www/*.html web/*~ + .SUFFIXES: .ml .mli .cmo .cmi .cmx .ml.cmo: - ocamlc -c $(SYNTAX_PARSER) $(INCLUDES) $< + $(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $< + .ml.cmx: - ocamlopt -c $(SYNTAX_PARSER) $(INCLUDES) $< + $(CAMLOPT) -c $(SYNTAX_PARSER) $(INCLUDES) $< .mli.cmi: - ocamlc -c $(INCLUDES) $< + $(CAMLC) -c $(SYNTAX_PARSER) $(INCLUDES) $< -# FORTPATH = /users/formel8/frisch/solaris/fort/fort -FORTPATH = /home/frisch/fort -FORTBIN = $(FORTPATH)/fort -FORTLIB = $(FORTPATH) +include depend -test: all.cma - $(FORTBIN) -I $(FORTLIB) all.cma test_fort.ml +# CDuce-generated files + +driver/examples.ml: cduce web/examples/build.cd web/examples/examples.xml + (cd web/examples; ../../cduce --quiet build.cd) + +web/files: cduce web/site.cd + (cd web; ../cduce --quiet site.cd --arg -php site.xml) + +# Packaging + +write_header: + headache -h header $(DEPEND) + +remove_header: + headache -r $(DEPEND) + +# For development + +pull: tools/pull.$(EXTENSION) + $(LINK) -o $@ $^ + +profile: + rm -Rf prepro + mkdir prepro + for i in $(DIRS); do \ + mkdir prepro/$$i; \ + for j in $$i/*.ml $$i/*.mli; do \ + if [ -f "$$j" ]; then \ + echo $$j; \ + $(PREPRO) $$j -o prepro/$$j; \ + fi; \ + done; \ + done + cp parser/wlexer.mll prepro/parser/ + cp Makefile depend prepro/ + (cd prepro; make cduce PROFILE=true SYNTAX_PARSER= NATIVE=false) + +# Site-specific installation + +cedre_build: + rsh cedre ". .env; cd IMPLEM/CDUCE; make webiface; make web/files" +install_web: + scp web/www/*.php web/cduce.css cduce@iris:public_html/ + scp webiface cduce@iris:cgi-bin/cduce + ssh cduce@iris "chmod +s cgi-bin/cduce" + +install_web_local: + 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 + scp web/www/*.php web/cduce.css cduce@iris:public_html/ + +local_website: cduce + (cd web; ../cduce --quiet site.cd --arg site.xml) + +# Distribution + +DISTRIB = $(DIRS) tools web depend INSTALL CHANGES LICENSE README Makefile + +.PHONY: package +package: + rm -Rf package + mkdir package + cp -R $(DISTRIB) package/ + (cd package; headache -h ../header $(DEPEND)) -include depend