[Pkg-ocaml-maint-commits] [SCM] ocamlviz packaging branch, ocamlbuild, updated. upstream/1.01-2-gc1c1ba1
Mehdi Dogguy
mehdi at debian.org
Thu Mar 25 22:44:10 UTC 2010
The following commit has been merged in the ocamlbuild branch:
commit c1c1ba120a0063b33a65ce705f2fa2bb7a1fb975
Author: Mehdi Dogguy <mehdi at debian.org>
Date: Thu Mar 25 23:41:47 2010 +0100
Complete ocamlbuild port
diff --git a/Makefile b/Makefile
index e1155ec..3de270d 100644
--- a/Makefile
+++ b/Makefile
@@ -9,6 +9,14 @@
# #
##########################################################################
+# where to install the binaries
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+BINDIR=@bindir@
+
+# where to install the man page
+MANDIR=@mandir@
+
NAME = ocamlviz
OCAMLBUILD = ocamlbuild
OCAMLFIND = ocamlfind
@@ -22,87 +30,15 @@ native:
final:
$(OCAMLBUILD) $@
-doc:
- $(OCAMLBUILD) ocamlviz.docdir/index.html
-
-# bytecode and native-code compilation
-######################################
-
-
-GENERATED = src/version.ml src/preflexer.ml
-
-PROTOCOLCMO = src/binary.cmo src/bproto.cmo
-PROTOCOLCMX = $(PROTOCOLCMO:.cmo=.cmx)
-
-OCAMLVIZCMO = $(PROTOCOLCMO) src/monitor_impl.cmo src/ocamlviz.cmo src/ocamlviz_threads.cmo
-OCAMLVIZCMX = $(OCAMLVIZCMO:.cmo=.cmx)
-
-LIBOCAMLVIZ = libocamlviz.cmxa
-LIBOCAMLVIZBYTE = libocamlviz.cma
-
-$(LIBOCAMLVIZ): $(OCAMLVIZCMX)
- $(OCAMLOPT) -a $(OFLAGS) -o $@ $^
-
-$(LIBOCAMLVIZBYTE): $(OCAMLVIZCMO)
- $(OCAMLC) -a $(BFLAGS) -thread -o $@ threads.cma $^
-
-
-CLIENTCMO = $(PROTOCOLCMO) src/timemap.cmo src/db.cmo src/options.cmo src/net.cmo
-CLIENTCMX = $(CLIENTCMO:.cmo=.cmx)
-
-ASCIICMO = $(CLIENTCMO) src/ascii.cmo
-ASCIICMX = $(ASCIICMO:.cmo=.cmx)
-
-ascii.byte: $(ASCIICMO)
- $(OCAMLC) -thread $(BFLAGS) -o $@ unix.cma threads.cma $^
+tests/pa-%.ml: tests/%.ml _build/camlp4/pa_ocamlviz.cmo
+ camlp4 pa_o.cmo str.cma _build/camlp4/pa_ocamlviz.cmo pr_o.cmo tests/$*.ml -o tests/pa-$*.ml
-ascii.opt: $(ASCIICMX)
- $(OCAMLOPT) -thread $(OFLAGS) -o $@ unix.cmxa threads.cmxa $^
-
-
-TREEPANELCMO = $(CLIENTCMO) src/dot.cmo src/tree_panel.cmo
-TREEPANELCMX = $(TREEPANELCMO:.cmo=.cmx)
-
-GUICMO = $(TREEPANELCMO) src/graph.cmo src/preflexer.cmo src/gui_misc.cmo src/gui_models.cmo src/gui_views.cmo src/gui_pref.cmo src/gui.cmo
-GUICMX = $(GUICMO:.cmo=.cmx)
-
-gui.byte: $(GUICMO)
- $(OCAMLC) $(BFLAGS) -o $@ lablgtk.cma gtkInit.cma unix.cma $^
-
-gui.opt: $(GUICMX)
- $(OCAMLOPT) $(OFLAGS) -o $@ unix.cmxa threads.cmxa lablgtk.cmxa cairo.cmxa cairo_lablgtk.cmxa gtkThread.cmx $^
-
-
-camlp4/pa_ocamlviz.cmo: camlp4/pa_ocamlviz.ml
- ocamlc -c -dtypes -I +camlp4 -I +str -pp camlp4of str.cma $^
-
-tests/pa-%.ml: tests/%.ml camlp4/pa_ocamlviz.cmo
- camlp4 pa_o.cmo str.cma camlp4/pa_ocamlviz.cmo pr_o.cmo tests/$*.ml -o tests/pa-$*.ml
-
-test-%: tests/%.opt gui.opt
- xterm -e "tests/$*.opt 100" &
- sleep 1 && ./gui.opt
-
-test-%-byte: tests/%.byte gui.opt
- xterm -e "tests/$*.byte 100" &
- sleep 1 && ./gui.opt
-
-ascii-%: tests/%.opt ascii.opt
- xterm -e "tests/$*.opt 100" &
- sleep 1 && ./ascii.opt
-
-tests/%.opt: $(LIBOCAMLVIZ) tests/%.ml
- $(OCAMLOPT) -thread $(OFLAGS) -o $@ unix.cmxa threads.cmxa $^
-
-tests/%.byte: $(LIBOCAMLVIZBYTE) tests/%.ml
- $(OCAMLC) -thread -I src -o $@ unix.cma threads.cma $^
-
-
-VERSION=0.1
+test-%.native:
+test-%.byte:
+ascii-%.native:
+ascii-%.byte:
+ $(OCAMLBUILD) $@
-src/version.ml: Makefile
- echo "let version = \""$(VERSION)"\"" > $@
- echo "let date = \""`date`"\"" >> $@
# installation
##############
@@ -112,36 +48,27 @@ install-indep:
mkdir -p $(MANDIR)/man1
cp -f doc/ocamlviz.1 $(MANDIR)/man1/ocamlviz.1
-install: install-indep install-$(OCAMLBEST)
+install: final install-indep install-$(OCAMLBEST)
cp -f src/ocamlviz.mli src/ocamlviz.cmi src/ocamlviz_threads.cmi $(OCAMLLIB)
- cp -f libocamlviz.cma $(OCAMLLIB)
- cp -f camlp4/pa_ocamlviz.cmi camlp4/pa_ocamlviz.cmo $(OCAMLLIB)/camlp4
- cp -f ascii.$(OCAMLBEST) $(BINDIR)/ocamlviz-ascii
+ cp -f _build/src/libocamlviz.cma $(OCAMLLIB)
+ cp -f _build/camlp4/pa_ocamlviz.cmi _build/camlp4/pa_ocamlviz.cmo $(OCAMLLIB)/camlp4
+ cp -f _build/src/ocamlviz-ascii $(BINDIR)
+ cp -f _build/src/ocamlviz-gui $(BINDIR)
install-byte:
install-opt:
- cp -f libocamlviz.cmxa libocamlviz.a $(OCAMLLIB)
- cp -f gui.$(OCAMLBEST) $(BINDIR)/ocamlviz-gui
-
+ cp -f _build/src/libocamlviz.cmxa _build/src/libocamlviz.a $(OCAMLLIB)
# documentation
###############
-DOCFILES=doc/index.html
-
.PHONY: doc/index.html
-
.PHONY: doc/manual.pdf
-doc: $(DOCFILES)
-
-# OCAMLDOCFILES=$(filter-out src/monitor_sig.mli, $(wildcard src/*.mli))
-OCAMLDOCFILES=src/*.mli
-
-doc/index.html:
- ocamldoc -html -d doc -I src -I +lablgtk2 $(OCAMLDOCFILES)
+doc:
+ $(OCAMLBUILD) ocamlviz.docdir/index.html
doc/manual.pdf: doc/manual.tex
cd doc && mlpost -native -latex manual.tex -pdf fig.ml && pdflatex manual.tex
@@ -162,63 +89,6 @@ FILES = *.ml* $(NAME).1 manual.tex \
Makefile.in configure configure.in \
.depend README INSTALL COPYING GPL CHANGES
-
-# literate programming
-######################
-
-SOURCES =
-
-$(NAME).tex: $(SOURCES)
- $(OCAMLWEB) -o $@ $^
-
-# generic rules
-###############
-
-.SUFFIXES: .mli .ml .cmi .cmo .cmx .mll .mly .tex .dvi .ps .html
-
-.mli.cmi:
- $(OCAMLC) -c $(BFLAGS) $<
-
-.ml.cmo:
- $(OCAMLC) -c $(BFLAGS) $<
-
-.ml.o:
- $(OCAMLOPT) -c $(OFLAGS) $<
-
-.ml.cmx:
- $(OCAMLOPT) -c $(OFLAGS) $<
-
-.mll.ml:
- $(OCAMLLEX) $<
-
-.mly.ml:
- $(OCAMLYACC) -v $<
-
-.mly.mli:
- $(OCAMLYACC) -v $<
-
-.tex.dvi:
- latex $< && latex $<
-
-.dvi.ps:
- dvips $< -o $@
-
-.tex.html:
- hevea $<
-
-# Emacs tags
-############
-
-tags:
- find . -name "*.ml*" | sort -r | xargs \
- etags "--regex=/let[ \t]+\([^ \t]+\)/\1/" \
- "--regex=/let[ \t]+rec[ \t]+\([^ \t]+\)/\1/" \
- "--regex=/and[ \t]+\([^ \t]+\)/\1/" \
- "--regex=/type[ \t]+\([^ \t]+\)/\1/" \
- "--regex=/exception[ \t]+\([^ \t]+\)/\1/" \
- "--regex=/val[ \t]+\([^ \t]+\)/\1/" \
- "--regex=/module[ \t]+\([^ \t]+\)/\1/"
-
# file headers
##############
headers:
@@ -241,26 +111,8 @@ configure: configure.in
# clean
#######
-clean::
- rm -f src/*.cm[iox] src/*.o src/*~ src/*.annot
- rm -f tests/*.cm[iox] tests/*.o tests/*~ tests/*.annot tests/*.byte tests/*.opt
- rm -f $(GENERATED)
- rm -f *.byte *.opt
- rm -f libocamlviz.*
- rm -f doc/*.html doc/*mps doc/*.aux doc/*.bbl doc/*.blg
- rm -f doc/*.log doc/*.toc doc/*.vrb doc/*.snm doc.*.out doc/*.nav
+clean:
+ $(OCAMLBUILD) $@
dist-clean distclean:: clean
rm -f Makefile config.cache config.log config.status
-
-# depend
-########
-
-dep:
- ocamldep -I src src/*.ml src/*.mli | ocamldot | dot -Tps | gv -
-
-.depend depend:: $(GENERATED)
- rm -f .depend
- $(OCAMLDEP) $(INCLUDES) src/*.ml src/*.mli > .depend
-
-include .depend
diff --git a/_tags b/_tags
index 3444c04..1fe2220 100644
--- a/_tags
+++ b/_tags
@@ -1,2 +1,3 @@
<**/*.ml*> : annot
<camlp4/pa_*.ml> : use_camlp4, pp(camlp4of)
+<tests/*.*> : use_ocamlviz
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
index 56306f7..02e38c5 100644
--- a/myocamlbuild.ml
+++ b/myocamlbuild.ml
@@ -51,12 +51,10 @@ let findlib_packages = [
let _ = List.iter require findlib_packages
-let unit_name suffix name =
+let unit_path suffix name =
__ "src/%s.%s" name suffix
-let native =
- List.map (unit_name "native") bin @ List.map (unit_name "cmxa") libs
-let byte =
- List.map (unit_name "byte") bin @ List.map (unit_name "cma") libs
+let test_path suffix name =
+ __ "tests/%s.%s" name suffix
let get_version _ =
match string_list_of_file "VERSION" with
@@ -86,6 +84,19 @@ let _ =
| After_rules ->
+ (* Targets *)
+ let gui = unit_path best "gui" in
+ let ascii = unit_path best "ascii" in
+ let gui_native = unit_path "native" "gui" in
+ let ascii_native = unit_path "native" "ascii" in
+ let gui_byte = unit_path "byte" "gui" in
+ let ascii_byte = unit_path "byte" "ascii" in
+ let pa_ocamlviz = "camlp4/pa_ocamlviz.cmo" in
+ let cma = unit_path "cma" "libocamlviz" in
+ let cmxa = unit_path "cmxa" "libocamlviz" in
+ let native = [ cmxa; ascii_native; gui_native ] in
+ let byte = [ cma; ascii_byte; gui_byte; pa_ocamlviz ] in
+
(* Use -linkpkg when linking *)
flag ["ocaml"; "link"; "program"] & A"-linkpkg";
@@ -103,32 +114,76 @@ let _ =
)
["ocamldep"; "compile"; "link"; "doc"];
+ (* Tests need ocamlviz *)
+ List.iter
+ (fun stage ->
+ flag (stage::["ocaml"; "native"; "use_ocamlviz"]) & S[A"-I"; A"src"; A cmxa];
+ flag (stage::["ocaml"; "byte"; "use_ocamlviz"]) & S[A"-I"; A"src"; A cma];
+ )
+ ["ocamldep"; "compile"; "link"; "doc"];
+
(* Helpers *)
let virtual_rule name deps =
rule name ~stamp:name ~deps (fun _ _ -> Nop)
in
- let mycopy_rule name dep =
- rule name ~stamp:name ~deps:([dep])
- (fun _ _ -> Cmd (Sh (__ "cp %s %s" dep name)))
+ let copy dep name =
+ copy_rule name dep name
in
- (* Targets *)
- let gui = __ "src/gui.%s" best in
- let ascii = __ "src/ascii.%s" best in
- let pa_ocamlviz = "camlp4/pa_ocamlviz.cmo" in
-
(* Usual byte/native/opt/all targets *)
virtual_rule "all" & "META" :: if have_native then [ "byte" ; "native" ] else [ "byte" ];
- virtual_rule "byte" & "META" ::pa_ocamlviz :: byte;
+ virtual_rule "byte" & "META" :: byte;
virtual_rule "native" & "META" :: native;
virtual_rule "opt" & native;
- mycopy_rule "ocamlviz-gui" gui;
- mycopy_rule "ocamlviz-ascii" ascii;
+ copy gui "ocamlviz-gui";
+ copy ascii "ocamlviz-ascii";
virtual_rule "final" & [ "all"; "ocamlviz-gui"; "ocamlviz-ascii" ];
+ (* Tests *)
+ let tests = Sys.readdir ("tests/") in
+
+ (* Native tests *)
+ let test_cmd _bin _gui =
+ (fun _ _ ->
+ Cmd (Sh (__ "xterm -e \"./%s 100\" & (sleep 1 ; ./%s)" _bin _gui))
+ )
+ in
+ Array.iter
+ (fun test ->
+ let name = Filename.chop_suffix test ".ml" in
+ let id = __ "tests/%s" test in
+
+ let rule_native = __ "test-%s.native" name in
+ let bin_native = test_path "native" name in
+
+ let rule_byte = __ "test-%s.byte" name in
+ let bin_byte = test_path "byte" name in
+
+ let ascii_native_rule = __ "ascii-%s.native" name in
+ let ascii_byte_rule = __ "ascii-%s.byte" name in
+
+ rule rule_native ~stamp:rule_native ~deps:([cmxa; gui_native; bin_native])
+ (test_cmd bin_native gui_native);
+
+ rule rule_byte ~stamp:rule_byte ~deps:([cma; gui_byte; bin_byte])
+ (test_cmd bin_byte gui_byte);
+
+ rule ascii_native_rule ~stamp:ascii_native_rule ~deps:([cmxa; ascii_native; bin_native])
+ (test_cmd bin_native ascii_native);
+
+ rule ascii_byte_rule ~stamp:ascii_byte_rule ~deps:([cmxa; ascii_byte; bin_byte])
+ (test_cmd bin_byte ascii_byte);
+
+ let pa_test = __ "tests/pa-%s" test in
+ rule pa_test ~stamp:pa_test ~deps:([ id; pa_ocamlviz ])
+ (fun _ _ ->
+ Cmd (Sh (__ "camlp4 pa_o.cmo str.cma camlp4/pa_ocamlviz.cmo pr_o.cmo %s -o %s" id pa_test))
+ )
+ ) tests;
+
(* META file *)
rule "META" ~deps:["META.in"; "VERSION"] ~prod:"META"
(fun _ _ ->
--
ocamlviz packaging
More information about the Pkg-ocaml-maint-commits
mailing list