, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
ocamlbricks-0.90+bzr456.orig/Makefile.local 0000644 0001750 0001750 00000015435 13175721005 017464 0 ustar lucas lucas # This -*- makefile -*- is part of our reusable OCaml BRICKS library
# Copyright (C) 2008, 2011 Luca Saiu
# Copyright (C) 2008, 2010, 2011 Jean-Vincent Loddo
# Copyright (C) 2008, 2010, 2011 Université Paris 13
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# Set this variable to "-verbose 0" for more details
OCAMLBUILD_OPTIONS=-quiet
# BYTE_COMPILE_OPTIONS += -custom -ccopt -L./ -cclib -L./
COMPILE_OPTIONS += -g -thread
DIRECTORIES_TO_INCLUDE = threads lablgtk2 camlp4
LIBRARIES_TO_LINK = str unix threads lablgtk
NATIVE_PROGRAMS += mutexExtra_test.native
BYTE_PROGRAMS += mutexExtra_test.byte
NATIVE_LIBRARY_NAME = ocamlbricks.cmxa
BYTE_LIBRARY_NAME = ocamlbricks.cma
NATIVE_LIBRARIES = $(shell \
if which ocamlopt.opt &>/dev/null || which ocamlopt &>/dev/null;\
then echo $(NATIVE_LIBRARY_NAME); fi)
BYTE_LIBRARIES = $(shell \
if which ocamlc.opt &>/dev/null || which ocamlc &>/dev/null;\
then echo $(BYTE_LIBRARY_NAME); fi)
# Empty for OCaml 3.x.y series, set to "-DOCAML4_OR_LATER" for 4.x.y or later:
OCAML4_OR_LATER=$(shell if grep -q "^[4-9]" <<<"$(OCAML_VERSION)"; then echo "-DOCAML4_OR_LATER"; fi)
# Empty for OCaml 3.x.y series, set to "-DOCAML4_02_OR_LATER" for 4.02.y or later:
OCAML4_02_OR_LATER=$(shell if grep -q "^\([5-9]\)\|\(4[.]\([1-9]\|0[2-9]\)\)" <<<"$(OCAML_VERSION)"; then echo "-DOCAML4_02_OR_LATER"; fi)
# Empty for OCaml 3.x.y series, set to "-DOCAML4_04_OR_LATER" for 4.04.y or later:
OCAML4_04_OR_LATER=$(shell if grep -q "^\([5-9]\)\|\(4[.]\([1-9]\|0[4-9]\)\)" <<<"$(OCAML_VERSION)"; then echo "-DOCAML4_04_OR_LATER"; fi)
# Transmit the information about the compiler version in order to
# activate conditional compilation:
PP_OPTION = camlp4of $(OCAML4_OR_LATER) $(OCAML4_02_OR_LATER) $(OCAML4_04_OR_LATER)
GETTEXT=GETTEXT
C_OBJECTS_TO_LINK = gettext-c-wrapper does-process-exist-c-wrapper waitpid-c-wrapper
OTHER_LIBRARY_FILES_TO_INSTALL = _build/{gettext-c-wrapper.o,does-process-exist-c-wrapper.o,gettext_extract_pot_p4.cmo,waitpid-c-wrapper.o,include_type_definitions_p4.cmo,include_as_string_p4.cmo,where_p4.cmo,option_extract_p4.cmo,raise_p4.cmo,log_module_loading_p4.cmo}
MANUALLY_PRE_COPY_IN_build = \
GETTEXT/gettext_extract_pot_p4.ml{,i} \
GETTEXT/gettext-c-wrapper.c \
EXTRA/does-process-exist-c-wrapper.c \
EXTRA/waitpid-c-wrapper.c \
CAMLP4/include_type_definitions_p4.ml{,i} \
CAMLP4/include_as_string_p4.ml{,i} \
CAMLP4/where_p4.ml{,i} \
CAMLP4/option_extract_p4.ml{,i} \
CAMLP4/common_tools_for_preprocessors.ml{,i} \
CAMLP4/raise_p4.ml{,i} \
CAMLP4/log_module_loading_p4.ml{,i}
MANUALLY_PRE_MAKE_IN_build = \
gettext_extract_pot_p4.cm{i,o} \
include_type_definitions_p4.cm{i,o} \
include_as_string_p4.cm{i,o} \
where_p4.cm{i,o} \
option_extract_p4.cm{i,o} \
raise_p4.cm{i,o} \
log_module_loading_p4.cm{i,o} \
libocamlbricks_stubs.a
main-local: meta_ocamlbricks.ml
meta_ocamlbricks.ml: meta.ml
cp $< meta_ocamlbricks.ml
EXCLUDE_FROM_EDITING=meta_ocamlbricks.ml
# include_type_definitions_p4
_build/include_type_definitions_p4.cmi: CAMLP4/include_type_definitions_p4.mli
ocamlc -c -I +camlp4 -pp '$(PP_OPTION)' -o $@ $<
_build/include_type_definitions_p4.cmo: CAMLP4/include_type_definitions_p4.ml
ocamlc -c -I +camlp4 -I _build/ -pp '$(PP_OPTION)' -o $@ $<
# include_as_string_p4
_build/include_as_string_p4.cmi: CAMLP4/include_as_string_p4.mli
ocamlc -c -I +camlp4 -pp '$(PP_OPTION)' -o $@ $<
_build/include_as_string_p4.cmo: CAMLP4/include_as_string_p4.ml
ocamlc -c -I +camlp4 -I _build/ -pp '$(PP_OPTION)' -o $@ $<
_build/where_p4.cmi: CAMLP4/where_p4.mli
ocamlc -c -I +camlp4 -pp camlp4of -o $@ $<
_build/where_p4.cmo: CAMLP4/where_p4.ml
ocamlc -c -I +camlp4 -I _build/ -pp camlp4of -o $@ $<
_build/option_extract_p4.cmi: CAMLP4/option_extract_p4.mli
ocamlc -c -I +camlp4 -I _build/ -pp camlp4of -o $@ $<
_build/option_extract_p4.cmo: CAMLP4/option_extract_p4.ml
ocamlc -c -I +camlp4 -I _build/ -pp camlp4of -o $@ $<
_build/raise_p4.cmi: CAMLP4/raise_p4.mli
ocamlc -c -I +camlp4 -I _build/ -pp camlp4of -o $@ $<
_build/raise_p4.cmo: CAMLP4/raise_p4.ml
ocamlc -c -I +camlp4 -I _build/ -pp camlp4of -o $@ $<
_build/log_module_loading_p4.cmi: CAMLP4/log_module_loading_p4.mli
ocamlc -c -I +camlp4 -I _build/ -pp camlp4of -o $@ $<
_build/log_module_loading_p4.cmo: CAMLP4/log_module_loading_p4.ml
ocamlc -c -I +camlp4 -I _build/ -pp camlp4of -o $@ $<
# gettext_extract_pot_p4
_build/gettext_extract_pot_p4.cmi: $(GETTEXT)/gettext_extract_pot_p4.mli
ocamlc -c -I +camlp4 -pp camlp4of camlp4lib.cma -o $@ $<
_build/gettext_extract_pot_p4.cmo: $(GETTEXT)/gettext_extract_pot_p4.ml
ocamlc -c -I +camlp4 -I _build/ -pp camlp4of camlp4lib.cma -o $@ $<
_build/libocamlbricks_stubs.a: $(GETTEXT)/gettext-c-wrapper.c EXTRA/does-process-exist-c-wrapper.c EXTRA/waitpid-c-wrapper.c
@(mkdir _build &> /dev/null || true); \
cd _build; \
ocamlc -c -verbose $(GETTEXT)/gettext-c-wrapper.c; \
ocamlc -c -verbose EXTRA/does-process-exist-c-wrapper.c; \
ocamlc -c -verbose EXTRA/waitpid-c-wrapper.c; \
ocamlmklib -verbose -oc ocamlbricks_stubs gettext-c-wrapper.o does-process-exist-c-wrapper.o waitpid-c-wrapper.o
# idempotent
rebuilding:
@chmod +x Makefile.d/ocamlmklib_wrapper.sh
@Makefile.d/ocamlmklib_wrapper.sh $(C_OBJECTS_TO_LINK)
preprocessors: _build/gettext_extract_pot_p4.cmo
install-libraries-local: rebuilding preprocessors
# Remove the automatically-generated documentation on clean:
clean-local:
@(rm -rf doc/html)
rm -f meta_ocamlbrics.ml _build/meta_ocamlbrics.ml
rm -rf _build/does_process_exist.o
rm -rf _build/waitpid-c-wrapper.o
compile_for_testing:
@if grep -q "DDOCUMENTATION_OR_DEBUGGING" $(LOGFILE); then echo "Fine, already compiled for testing."; else make clean; fi; \
make PP_OPTION="$(PP_OPTION) -DDOCUMENTATION_OR_DEBUGGING"
# Test without installation
LIBRARY_TO_TEST=_build/ocamlbricks.cma
test: compile_for_testing rebuilding
@chmod +x Makefile.d/test_with.sh
@Makefile.d/test_with.sh "ocaml"
# Test without installation with the utop toplevel
test_with_utop: compile_for_testing rebuilding
@chmod +x Makefile.d/test_with.sh
@Makefile.d/test_with.sh "utop"
# Test without installation with the utop toplevel
test_with_utop+widgets: compile_for_testing rebuilding
@chmod +x Makefile.d/test_with.sh
@Makefile.d/test_with.sh "utop" "lablgtk2"
ocamlbricks-0.90+bzr456.orig/MAKE/ 0000755 0001750 0001750 00000000000 13175721005 015440 5 ustar lucas lucas ocamlbricks-0.90+bzr456.orig/MAKE/crep.ml 0000644 0001750 0001750 00000002371 13175721005 016726 0 ustar lucas lucas (* This file is part of our reusable OCaml BRICKS library
Copyright (C) 2007 Jean-Vincent Loddo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . *)
(** This simple program run as the famous {b grep} command but taking a regular expression in the [Str] O'Caml library format.
The regular expression must be given as the first and unique argument. The parsed file is the standard input. *)
let main () =
let re = Str.regexp (Sys.argv.(1)) in
let rec boucle () =
try begin
let line = read_line () in
(match Str.string_match re line 0 with
| true -> print_endline line
| false -> ());
boucle ()
end with End_of_file -> ()
in boucle ()
;;
main ()
;;
ocamlbricks-0.90+bzr456.orig/DOT/ 0000755 0001750 0001750 00000000000 13175721005 015351 5 ustar lucas lucas ocamlbricks-0.90+bzr456.orig/DOT/dot_widget.mli 0000644 0001750 0001750 00000002430 13175721005 020204 0 ustar lucas lucas (* This file is part of ocamlbricks
Copyright (C) 2010 Jean-Vincent Loddo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . *)
(** Widgets for dot. *)
val filter_of_format : Dot.output_format -> GFile.filter
val filter_of_string : string -> GFile.filter
val make_all_working_filters : unit -> GFile.filter list
val make_all_working_filters_assoc : unit -> (Dot.output_format * GFile.filter) list
val combo_of_working_output_formats :
?active:Dot.output_format ->
?add_tearoffs:bool ->
?focus_on_click:bool ->
?has_frame:bool ->
?wrap_width:int ->
?width:int ->
?height:int ->
?packing:(GObj.widget -> unit) ->
?show:bool -> unit
-> GEdit.combo_box * (unit -> Dot.output_format)
ocamlbricks-0.90+bzr456.orig/DOT/dot.mli 0000644 0001750 0001750 00000116732 13175721005 016654 0 ustar lucas lucas (* This file is part of ocamlbricks
Copyright (C) 2010 Jean-Vincent Loddo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . *)
(** Simplified interface (forgetting options):
{[
val graph : ?... -> statement list -> graph
val subgraph : ?... -> statement list -> statement
val cluster : ?... -> statement list -> statement
val node : ?... -> node_ident -> statement
val edge : ?... -> node_ident -> node_ident -> statement
val graph_default : ?... -> unit -> statement
val node_default : ?... -> unit -> statement
val edge_default : ?... -> unit -> statement
val label_of_text : ?fontcolor:color -> ?fontname:string -> ?fontsize:int -> text -> [ `html of html_like ]
val label_of_table : ?fontcolor:color -> ?fontname:string -> ?fontsize:int -> table -> [ `html of html_like ]
val html_of_text : ?fontcolor:color -> ?fontname:string -> ?fontsize:int -> text -> html_like
val html_of_table : ?fontcolor:color -> ?fontname:string -> ?fontsize:int -> table -> html_like
val text_of_string : ?br:unit -> ?align:[ `CENTER | `LEFT | `RIGHT ] -> string -> text
val text_concat : text list -> text
val table : ?... -> row list -> table
val cell_of_text : ?... -> text -> cell
val cell_of_table : ?... -> table -> cell
val cell_of_image : ?... -> filename -> cell
val print : graph -> unit
val fprint : filename -> graph -> unit
val sprint : graph -> string
]}
*)
type graph
type statement
type color = [ `RGB of int * int * int | `HSV of float*float*float | `name of string ]
type filename = string
type ident = string
type layer_ident = string
type point_ident = string
type port_ident = string
type node_ident = string
type cluster_ident = string
type escaped_string = string
(* string allowing escape sequences which are replaced according to the context. For node attributes,
the substring "\N" is replaced by the name of the node, and the substring "\G" by the name of the graph.
For graph or cluster attributes, the substring "\G" is replaced by the name of the graph or cluster.
For edge attributes, the substring "\N" is replaced by the name of the edge, and the substrings "\T"
and "\H" by the names of the tail and head nodes, respectively. The name of an edge is the string formed
from the name of the tail node, the appropriate edge operator ("--" or "->") and the name of the head node.
In addition, if the associated attribute is label, headlabel or taillabel, the escape sequences "\n", "\l" and "\r"
divide the label into lines, centered, left-justified, and right-justified, respectively. *)
(* See http://www.graphviz.org/pub/scm/graphviz2/doc/info/shapes.html#html *)
type html_like = [ `text of text | `TABLE of table | `FONT of font ]
and text = item list
and item = [ `string of string | `BR of br_attribute list ]
and table = table_attribute list * row list
and table_attribute =
[ `ALIGN of [`CENTER|`LEFT|`RIGHT]
| `BGCOLOR of color
| `BORDER of float
| `CELLBORDER of float
| `CELLPADDING of float
| `CELLSPACING of float
| `FIXEDSIZE of bool
| `HEIGHT of float
| `HREF of string
| `PORT of string
| `TARGET of string
| `TITLE of string
| `TOOLTIP of string
| `VALIGN of [ `MIDDLE|`BOTTOM|`TOP ]
| `WIDTH of float
]
and font = font_attribute list * html_like
and font_attribute =
[ `COLOR of color
| `FACE of string
| `POINT_SIZE of int
]
and br_attribute =
[ `ALIGN of [`CENTER|`LEFT|`RIGHT]
]
and row = cell list
and cell = cell_attribute list * [ `html of html_like | `IMG of image ]
and cell_attribute =
[ `ALIGN of [`CENTER|`LEFT|`RIGHT]
| `BGCOLOR of color
| `BORDER of float
| `CELLPADDING of float
| `CELLSPACING of float
| `FIXEDSIZE of bool
| `HEIGHT of float
| `HREF of string
| `PORT of string
| `TARGET of string
| `TITLE of string
| `TOOLTIP of string
| `VALIGN of [ `MIDDLE|`BOTTOM|`TOP ]
| `WIDTH of float
(* cell specific: *)
| `COLSPAN of int
| `ROWSPAN of int
]
and image = image_attribute list
and image_attribute =
[ `SCALE of [`FALSE|`TRUE|`WIDTH|`HEIGHT|`BOTH]
| `SRC of filename
]
type label = [ `escaped of escaped_string | `html of html_like ]
(** Graph constructor. *)
val graph:
?strict:unit -> (* If the graph is strict then multiple edges are not allowed between the same pairs of nodes. *)
?digraph:bool ->
(* If it is a directed graph, indicated by digraph, then the edgeop must be "->".
If it is an undirected graph then the edgeop must be "--". *)
?name:ident ->
?size:[ `max of (float*float) | `force of (float*float) ] ->
(* size="x,y" sets bounding box of drawing in inches.
Maximum width and height of drawing, in inches. If defined and the drawing is too large, the drawing is uniformly scaled down so
that it fits within the given size.
If size ends in an exclamation point (!), then it is taken to be the desired size. In this case, if both dimensions of the
drawing are less than size, the drawing is scaled up uniformly until at least one dimension equals its dimension in size.
Note that there is some interaction between the size and ratio attributes. *)
?page:(float*float) ->
(* page="x,y" sets the PostScript pagination unit.
Width and height of output pages, in inches. If this is set and is smaller than the size of the layout, a rectangular array
of pages of the specified page size is overlaid on the layout, with origins aligned in the lower-left corner, thereby
partitioning the layout into pages. The pages are then produced one at a time, in pagedir order. *)
?pagedir: [ `BL | `BR | `TL | `TR | `RB | `RT | `LB | `LT ] ->
(* pagedir "BL", "BR", "TL", "TR", "RB", "RT", "LB", "LT" specify the 8 row or column major orders for traversing
a rectangular array, the first character corresponding to the major order and the second to the minor order. Thus, for "BL",
the major order is from bottom to top, and the minor order is from left to right. This means the bottom row is traversed
first, from left to right, then the next row up, from left to right, and so on, until the topmost row is traversed. *)
?rotate:float -> (* rotate=90 sets landscape mode. *)
?ratio:[ `float of float | `fill | `compress | `auto ] ->
(* ratio=f sets the aspect ratio (drawing height/drawing width) for the drawing.
Note that this is adjusted before the size attribute constraints are enforced.
- If ratio is numeric, it is taken as the desired aspect ratio. Then, if the actual aspect ratio is less than
the desired ratio, the drawing height is scaled up to achieve the desired ratio; if the actual ratio is greater
than that desired ratio, the drawing width is scaled up.
- If ratio = "fill" and the size attribute is set, node positions are scaled, separately in both x and y, so that
the final drawing exactly fills the specified size.
- If ratio = "compress" and the size attribute is set, dot attempts to compress the initial layout to fit in the given size.
This achieves a tighter packing of nodes but reduces the balance and symmetry. This feature only works in dot.
- If ratio = "expand", the size attribute is set, and both the width and the height of the graph are less than the value in size,
node positions are scaled uniformly until at least one dimension fits size exactly. Note that this is distinct from using size as
the desired size, as here the drawing is expanded before edges are generated and all node and text sizes remain unchanged.
- If ratio = "auto", the page attribute is set and the graph cannot be drawn on a single page, then size is set to an ``ideal'' value.
In particular, the size in a given dimension will be the smallest integral multiple of the page size in that dimension which is at
least half the current size. The two dimensions are then scaled independently to the new size. This feature only works in dot. *)
?margin:(float*float) -> (* For graphs, this sets x and y margins of canvas, in inches. *)
?center:unit -> (* If true, the drawing is centered in the output canvas. *)
?nodesep:float -> (* nodesep=f set the minimum space between two adjacent nodes in the same rank, in inches. Default 0.25, minimum 0.02 *)
?ordering:[ `inp | `out ] ->
(* If "out" for a graph G, and n is a node in G, then edges n->* appear left-to-right in the
same order in which they are defined. If "in", the edges *->n appear left-to-right in the
same order in which they are defined for all nodes n. *)
?outputorder: [ `breadthfirst | `nodesfirst | `edgesfirst ] ->
(* Specify order in which nodes and edges are drawn. "breadthfirst","nodesfirst","edgesfirst" specify the order in which nodes
and edges are drawn in concrete output. The default "breadthfirst" is the simplest, but when the graph layout does not avoid
edge-node overlap, this mode will sometimes have edges drawn over nodes and sometimes on top of nodes. If the mode "nodesfirst"
is chosen, all nodes are drawn first, followed by the edges. This guarantees an edge-node overlap will not be mistaken for an
edge ending at a node. On the other hand, usually for aesthetic reasons, it may be desirable that all edges appear beneath nodes,
even if the resulting drawing is ambiguous. This can be achieved by choosing "edgesfirst". *)
?rank: [ `same | `min | `max | `source | `sink ] ->
(* rank=.. Rank constraints on the nodes in a subgraph. If rank="same", all nodes are placed on the same rank.
If rank="min", all nodes are placed on the minimum rank. If rank="source", all nodes are placed on the minimum
rank, and the only nodes on the minimum rank belong to some subgraph whose rank attribute is "source" or "min".
Analogous criteria hold for rank="max" and rank="sink". (Note: the minimum rank is topmost or leftmost, and the
maximum rank is bottommost or rightmost.) *)
?rankdir: [`TB|`LR|`RL|`BT] -> (* rankdir=LR|RL|BT requests a left‐to‐right, right‐to‐left, or bottom‐to‐top, drawing. *)
?ranksep:float -> (* ranksep=f sets the minimum separation between ranks. Default 0.5. *)
?clusterrank:[ `local | `global | `none ] ->
(* Mode used for handling clusters. If clusterrank is "local", a subgraph whose name begins with "cluster" is given
special treatment. The subgraph is laid out separately, and then integrated as a unit into its parent graph, with
a bounding rectangle drawn about it. If the cluster has a label parameter, this label is displayed within the rectangle.
Note also that there can be clusters within clusters. At present, the modes "global" and "none" appear to be identical,
both turning off the special cluster processing. *)
?nslimit:float -> (* nslimit=f adjusts the bound on the number of network simplex or min‐cross iterations by the given ratio. *)
?layers:layer_ident list -> (* graph layers declarations. See http://www.graphviz.org/Documentation/html/layers/ *)
?color:color ->
(* color=colorvalue sets foreground color. This is the basic drawing color for graphics, not text.
For the latter, use the fontcolor attribute. For edges, the value can either be a single color or a colorList.
In the latter case, the edge is drawn using parallel splines or lines, one for each color in the list, in the order given. *)
?bgcolor:color ->
(* bgcolor=colorvalue sets background color.
When attached to the root graph, this color is used as the background for entire canvas. When a cluster attribute, it is used as
the initial background for the cluster. If a cluster has a filled style, the cluster's fillcolor will overlay the background color.
If no background color is specified for the root graph, no graphics operation are performed on the background. This works fine for
PostScript but for bitmap output, all bits are initialized to something. This means that when the bitmap output is included in some
other document, all of the bits within the bitmap's bounding box will be set, overwriting whatever color or graphics where already
on the page. If this effect is not desired, and you only want to set bits explicitly assigned in drawing the graph, set background="transparent". *)
?href:string ->
(* href="url" the default url for image map files; in PostScript files, the base URL
for all relative URLs, as recognized by Acrobat Distiller 3.0 and up. *)
?url:escaped_string ->
(* Hyperlinks incorporated into device-dependent output. At present, used in ps2, cmap, i*map and svg formats. For all these formats,
URLs can be attached to nodes, edges and clusters. URL attributes can also be attached to the root graph in ps2, cmap and i*map formats.
This serves as the base URL for relative URLs in the former, and as the default image map file in the latter.
The active area for a node or cluster is its bounding box. For edges, the active areas are small circles where the edge contacts its head and tail nodes.
These areas may overlap the related node, and the edge URL dominates. If the edge has a label, this will also be active. Finally, if the edge has a head
or tail label, this will also be active. Note, however, that if the edge has a headURL attribute, it is this value that is used near the head node and on
the head label, if defined. The similar restriction holds when tailURL is defined.
The URL of the root graph is only treated as an escString if the output format is cmap. *)
?stylesheet:string ->
(* stylesheet="file.css" includes a reference to a stylesheet in -Tsvg and -Tsvgz
outputs. Ignored by other formats. *)
?charset:string ->
(* Specifies the character encoding used when interpreting string input as a text label. The default value is "UTF-8".
The other legal value is "iso-8859-1" or, equivalently, "Latin1". The charset attribute is case-insensitive.
Note that if the character encoding used in the input does not match the charset value, the resulting output may be very strange. *)
?comment: string -> (* Comments are inserted into output. Device-dependent *)
?compound: unit -> (* If true, allow edges between clusters. (See lhead and ltail). *)
?concentrate: unit -> (* If true, use edge concentrators. *)
?fontcolor: color -> (* Color used for text. *)
?fontname:string ->
(* Font used for text. This very much depends on the output format and, for non-bitmap output such as PostScript or SVG,
the availability of the font when the graph is displayed or printed. As such, it is best to rely on font faces that
are generally available, such as Times-Roman, Helvetica or Courier. *)
?fontpath:string list ->
(* Directory list used by libgd to search for bitmap fonts if Graphviz was not built with the fontconfig library.
If fontpath is not set, the environment variable DOTFONTPATH is checked. If that is not set, GDFONTPATH is checked.
If not set, libgd uses its compiled-in font path. Note that fontpath is an attribute of the root graph. *)
?fontsize:int -> (* Font size, in points, used for text. Default is 14.0, minimum is 1.0 *)
?label: label -> (* Text label attached to objects. *)
?labeljust: [ `r | `l | `c ] ->
(* Justification for cluster labels. If "r", the label is right-justified within bounding rectangle; if "l", left-justified;
else the label is centered. Note that a subgraph inherits attributes from its parent. Thus, if the root graph sets
labeljust to "l", the subgraph inherits this value. *)
?labelloc: [ `t | `b ] ->
(* Top/bottom placement of graph and cluster labels. If the attribute is "t", place label at the top; if the attribute is "b",
place label at the bottom. By default, root graph labels go on the bottom and cluster labels go on the top. Note that a
subgraph inherits attributes from its parent. Thus, if the root graph sets labelloc to "b", the subgraph inherits this value.
Default is "b" for root graphs. *)
?nojustify:unit ->
(* By default, the justification of multi-line labels is done within the largest context that makes sense. Thus, in the label of a
polygonal node, a left-justified line will align with the left side of the node (shifted by the prescribed margin).
In record nodes, left-justified line will line up with the left side of the enclosing column of fields.
If nojustify is "true", multi-line labels will be justified in the context of itself. For example, if the attribute is set,
the first label line is long, and the second is shorter and left-justified, the second will align with the left-most character
in the first line, regardless of how large the node might be. *)
?quantum:float -> (* If quantum > 0.0, node label dimensions will be rounded to integral multiples of the quantum. *)
?remincross:unit -> (* If true and there are multiple clusters, run cross minimization a second time. *)
?samplepoints: int ->
(* If the input graph defines the ?vertices attribute, and output is dot or xdot, this give the number of points used to represent
circles and ellipses. It plays the same role in neato, when adjusting the layout to avoid overlapping nodes. Default 8. *)
statement list -> graph
val subgraph:
?name:ident ->
?rank: [ `same | `min | `max | `source | `sink ] ->
(* rank=.. Rank constraints on the nodes in a subgraph. If rank="same", all nodes are placed on the same rank.
If rank="min", all nodes are placed on the minimum rank. If rank="source", all nodes are placed on the minimum
rank, and the only nodes on the minimum rank belong to some subgraph whose rank attribute is "source" or "min".
Analogous criteria hold for rank="max" and rank="sink". (Note: the minimum rank is topmost or leftmost, and the
maximum rank is bottommost or rightmost.) *)
statement list -> statement
(* See http://www.graphviz.org/Gallery/directed/cluster.html *)
val cluster:
?name_suffix:cluster_ident ->
?rank: [ `same | `min | `max | `source | `sink ] ->
?color:color ->
?bgcolor:color ->
?fillcolor: color ->
(* Color used to fill the background of a node or cluster. If fillcolor is not defined, color is used.
(For clusters, if color is not defined, bgcolor is used.) If this is not defined, the default is used, except for shape=point or when
the output format is MIF, which use black by default.
Note that a cluster inherits the root graph's attributes if defined. Thus, if the root graph has defined a fillcolor, this will override
a color or bgcolor attribute set for the cluster. Default is black for clusters. *)
?pencolor:color ->
(* Color used to draw the bounding box around a cluster. If pencolor is not defined, color is used. If this is not defined, bgcolor is used.
If this is not defined, the default is used. Note that a cluster inherits the root graph's attributes if defined. Thus, if the root graph
has defined a pencolor, this will override a color or bgcolor attribute set for the cluster. *)
?fontcolor: color ->
?fontname:string -> (* Default is "Times-Roman" *)
?fontsize:int ->
?label: label ->
?labeljust: [ `r | `l | `c ] ->
?labelloc: [ `t | `b ] -> (* Default is "t" for clusters. *)
?nojustify:unit ->
?url:escaped_string ->
?peripheries: int ->
(* Set number of peripheries used in polygonal shapes and cluster boundaries. Note that user-defined shapes are treated as a form of box shape,
so the default peripheries value is 1 and the user-defined shape will be drawn in a bounding rectangle. Setting peripheries=0 will turn this off.
Also, 1 is the maximum peripheries value for clusters. Default is 1 for clusters *)
?style: [ `filled | `rounded ] list -> (* For cluster subgraph, if "filled", the cluster box's background is filled. *)
statement list -> statement
val node :
?url:escaped_string ->
?color:color ->
?comment: string ->
?distortion:float ->
(* Distortion factor for shape=polygon. Positive values cause top part to be larger than bottom; negative values do the opposite.
Default is 0.0, maximum is 100.0 *)
?fillcolor: color -> (* Default is lightgrey for nodes *)
?fontcolor: color ->
?fontname:string ->
?fontsize:int ->
?fixedsize:unit ->
(* If true, the node size is specified by the values of the width and height attributes only and is not expanded to contain the text label. *)
?group:string ->
(* If the end points of an edge belong to the same group, i.e., have the same group attribute, parameters are set to avoid
crossings and keep the edges straight. *)
?height:float ->
(* Height of node, in inches. This is taken as the initial, minimum height of the node. If fixedsize is true, this will be the final height of the node.
Otherwise, if the node label requires more height to fit, the node's height will be increased to contain the label. Note also that, if the output
format is dot, the value given to height will be the final value. Default is 0.5, maximum is 0.02. *)
?layer: layer_ident list -> (* Specifies layers in which the node or edge is present. *)
?margin:(float*float) -> (* For nodes, this attribute specifies space left around the node's label. By default, the value is 0.11,0.055. *)
?nojustify:unit ->
?orientation:float -> (* Angle, in degrees, used to rotate node shapes. Default is 0.0, maximum is 360.0 *)
?peripheries: int -> (* Default is shape default for nodes *)
?pos:float*float -> (* Set the position of node in points. Concerning this, see the -s command line flag. *)
?regular:unit -> (* Force polygon to be regular. *)
?shape: [ `box | `ellipse | `circle | `point | `egg | `triangle | `plaintext | `diamond | `trapezium | `parallelogram | `house
| `pentagon | `hexagon | `septagon | `octagon | `doublecircle | `doubleoctagon | `tripleoctagon | `invtriangle | `invtrapezium
| `invhouse | `Mdiamond | `Msquare | `Mcircle | `rect | `rectangle | `none
| `epsf of filename (* shape=epsf, shapefile=filename *)
| `polygon of int * int (* shape=polygon, sides=int, skew=int. Default are sides=4 and skew=0.0 *)
] ->
(* Default is ellipse. See http://www.graphviz.org/pub/scm/graphviz2/doc/info/shapes.html#polygon *)
(* Undocumented, but really nice: the image act as a background for the label. *)
?image:filename ->
?label: label -> (* Internal label. Default is "N" for nodes. *)
?style: [ `dashed | `dotted | `solid | `invis | `bold | `filled | `diagonals | `rounded ] list ->
?width:float ->
(* Width of node, in inches. This is taken as the initial, minimum width of the node. If fixedsize is true, this will be the final width of the node.
Otherwise, if the node label requires more width to fit, the node's width will be increased to contain the label. Note also that, if the output format
is dot, the value given to width will be the final value. *)
?z:float ->
(* Provides z coordinate value for 3D layouts and displays. If the graph has dim set to 3 (or more), neato will use a node's z value for
the z coordinate of its initial position if its pos attribute is also defined.
Even if no z values are specified in the input, it is necessary to declare a z attribute for nodes, e.g, using node[z=""] in order to get z values on output.
Thus, setting dim=3 but not declaring z will cause neato -Tvrml to layout the graph in 3D but project the layout onto the xy-plane for the rendering.
If the z attribute is declared, the final rendering will be in 3D. *)
?outlabel:[ `north of label | `south of label | `east of label | `west of label ] ->
node_ident -> statement
val edge :
?url:escaped_string ->
?color:color ->
?comment: string ->
?arrowhead: [ `normal | `inv | `dot | `invdot | `odot | `invodot | `none | `tee | `empty | `invempty
| `diamond | `odiamond | `ediamond | `crow | `box | `obox | `Open | `halfopen | `vee ] ->
(* Style of arrowhead on the head node of an edge. Default is normal. See: http://www.graphviz.org/pub/scm/graphviz2/doc/info/attrs.html#k:arrowType *)
?arrowtail: [ `normal | `inv | `dot | `invdot | `odot | `invodot | `none | `tee | `empty | `invempty
| `diamond | `odiamond | `ediamond | `crow | `box | `obox | `Open | `halfopen | `vee ] ->
(* Style of arrowhead on the tail node of an edge. Default is normal. See: http://www.graphviz.org/pub/scm/graphviz2/doc/info/attrs.html#k:arrowType *)
?dir: [ `forward | `back | `both | `none ] -> (* Default is forward fo directed graphs *)
?arrowsize:float -> (* Multiplicative scale factor for arrowheads. Default is 1.0 *)
?constraint_off:unit ->
(* Dot attribute is simply "constraint" which is an OCaml keyword.
If set, the edge is not used in ranking the nodes. *)
?decorate:unit ->
(* Attach edge label to edge by a 2-segment polyline, underlining the label, then going to the closest point of spline. *)
?fontcolor: color ->
?fontname:string ->
?fontsize:int -> (* Default is 14.0, minimum is 1.0. *)
?headclip:bool ->
(* If true, the head of an edge is clipped to the boundary of the head node; otherwise, the end of the edge goes to the center of the node,
or the center of a port, if applicable. Default is true. *)
?headlabel: label ->
(* Text label to be placed near head of edge. *)
?headport: port_ident * ([ `n | `ne | `e | `se | `s | `sw | `w | `nw ] option) ->
(* Indicates where on the head node to attach the head of the edge. In the default case, the edge is aimed towards the center of the node,
and then clipped at the node boundary.
The optional modifier indicating where on a node an edge should be aimed. It has the form portname[:compass_point] or compass_point. If the first form is used,
the corresponding node must either have record shape with one of its fields having the given portname, or have an HTML-like label, one of whose
components has a PORT attribute set to portname. In this case, the edge is aimed for the center of the corresponding field.
If a compass point is used, it must have the form "n","ne","e","se","s","sw","w","nw". This modifies the edge placement to aim for the corresponding
compass point on the port or, in the second form where no portname is supplied, on the node itself.
This attribute can be attached to an edge using the headport and tailport attributes, or as part of the edge description as in
node1:port1 -> node2:port5:nw. Default is center. *)
?tailclip:bool ->
?taillabel: label ->
?tailport: port_ident * ([ `n | `ne | `e | `se | `s | `sw | `w | `nw ] option) ->
?label: label -> (* Default is the empty string for edges. *)
?labelangle:float ->
(* This, along with labeldistance, determine where the headlabel (taillabel) are placed with respect to the head (tail) in polar coordinates.
The origin in the coordinate system is the point where the edge touches the node. The ray of 0 degrees goes from the origin back along the edge,
parallel to the edge at the origin. The angle, in degrees, specifies the rotation from the 0 degree ray, with positive angles moving counterclockwise
and negative angles moving clockwise. Default is -25.0, minimum is -180.0 *)
?labeldistance:float ->
(* Multiplicative scaling factor adjusting the distance that the headlabel(taillabel) is from the head(tail) node.
The default distance is 10 points. See labelangle for more details. Default is 1.0. *)
?labelfloat:unit ->
(* Allows edge labels to be less constrained in position. In particular, it may appear on top of other edges. *)
?labelfontcolor: color ->
(* Color used for headlabel and taillabel. If not set, defaults to edge's fontcolor. Default is black. *)
?labelfontname:string ->
(* Font used for headlabel and taillabel. If not set, defaults to edge's fontname. *)
?labelfontsize:int ->
(* Font size, in points, used for headlabel and taillabel. If not set, defaults to edge's fontsize. *)
?layer: layer_ident list -> (* Specifies layers in which the node or edge is present. *)
?lhead:cluster_ident ->
(* Logical head of an edge. When the graph option "compound" is true, if lhead is defined and is the name of a cluster containing the real head,
the edge is clipped to the boundary of the cluster. *)
?ltail:cluster_ident ->
(* Logical tail of an edge. When compound is true, if ltail is defined and is the name of a cluster containing the real tail, the edge is clipped
to the boundary of the cluster. *)
?minlen:int ->
(* Minimum edge length (rank difference between head and tail). *)
?nojustify:unit ->
?pos:float*float -> (* Set the position of spline control points in points. Concerning this, see the -s command line flag. *)
?samehead:point_ident -> (* Edges with the same head and the same samehead value are aimed at the same point on the head. *)
?sametail:point_ident -> (* Edges with the same tail and the same sametail value are aimed at the same point on the tail. *)
?style: [ `dashed | `dotted | `solid | `invis | `bold ] list ->
?weight:float ->
(* Weight of edge. In dot, the heavier the weight, the shorter, straighter and more vertical the edge is.
Default is 1.0, minimum is 0. *)
node_ident -> node_ident -> statement
val graph_default :
?size:[ `max of (float*float) | `force of (float*float) ] ->
?page:(float*float) ->
?pagedir: [ `BL | `BR | `TL | `TR | `RB | `RT | `LB | `LT ] ->
?rotate:float ->
?ratio:[ `float of float | `fill | `compress | `auto ] ->
?margin:(float*float) ->
?center:unit ->
?nodesep:float ->
?ordering:[ `inp | `out ] ->
?outputorder: [ `breadthfirst | `nodesfirst | `edgesfirst ] ->
?rank: [ `same | `min | `max | `source | `sink ] ->
?rankdir: [`TB|`LR|`RL|`BT] ->
?ranksep:float ->
?clusterrank:[ `local | `global | `none ] ->
?nslimit:float ->
?layers:layer_ident list ->
?color:color ->
?bgcolor:color ->
?href:string ->
?url:escaped_string ->
?stylesheet:string ->
?charset:string ->
?comment: string ->
?compound: unit ->
?concentrate: unit ->
?fontcolor: color ->
?fontname:string ->
?fontpath:string list ->
?fontsize:int ->
?label: label ->
?labeljust: [ `r | `l | `c ] ->
?labelloc: [ `t | `b ] ->
?nojustify:unit ->
?quantum:float ->
?remincross:unit ->
?samplepoints: int ->
unit -> statement
val node_default :
?url:escaped_string ->
?color:color ->
?comment: string ->
?distortion:float ->
?fillcolor: color ->
?fontcolor: color ->
?fontname:string ->
?fontsize:int ->
?fixedsize:unit ->
?group:string ->
?height:float ->
?layer: layer_ident list ->
?margin:(float*float) ->
?nojustify:unit ->
?orientation:float ->
?peripheries: int ->
?pos:float*float ->
?regular:unit ->
?shape: [ `box | `ellipse | `circle | `point | `egg | `triangle | `plaintext | `diamond | `trapezium | `parallelogram | `house
| `pentagon | `hexagon | `septagon | `octagon | `doublecircle | `doubleoctagon | `tripleoctagon | `invtriangle | `invtrapezium
| `invhouse | `Mdiamond | `Msquare | `Mcircle | `rect | `rectangle | `none
| `epsf of filename (* shape=epsf, shapefile=filename *)
| `polygon of int * int (* shape=polygon, sides=int, skew=int. Default are sides=4 and skew=0.0 *)
] ->
?image:filename ->
?label: label ->
?style: [ `dashed | `dotted | `solid | `invis | `bold | `filled | `diagonals | `rounded ] list ->
?width:float ->
?z:float ->
unit -> statement
val edge_default :
?url:escaped_string ->
?color:color ->
?comment: string ->
?arrowhead: [ `normal | `inv | `dot | `invdot | `odot | `invodot | `none | `tee | `empty | `invempty
| `diamond | `odiamond | `ediamond | `crow | `box | `obox | `Open | `halfopen | `vee ] ->
?arrowtail: [ `normal | `inv | `dot | `invdot | `odot | `invodot | `none | `tee | `empty | `invempty
| `diamond | `odiamond | `ediamond | `crow | `box | `obox | `Open | `halfopen | `vee ] ->
?dir: [ `forward | `back | `both | `none ] ->
?arrowsize:float ->
?constraint_off:unit ->
?decorate:unit ->
?fontcolor: color ->
?fontname:string ->
?fontsize:int ->
?headclip:bool ->
?headlabel: label ->
?headport: port_ident * ([ `n | `ne | `e | `se | `s | `sw | `w | `nw ] option) ->
?tailclip:bool ->
?taillabel: label ->
?tailport: port_ident * ([ `n | `ne | `e | `se | `s | `sw | `w | `nw ] option) ->
?label: label ->
?labelangle:float ->
?labeldistance:float ->
?labelfloat:unit ->
?labelfontcolor: color ->
?labelfontname:string ->
?labelfontsize:int ->
?layer: layer_ident list ->
?lhead:cluster_ident ->
?ltail:cluster_ident ->
?minlen:int ->
?nojustify:unit ->
?pos:float*float ->
?samehead:point_ident ->
?sametail:point_ident ->
?style: [ `dashed | `dotted | `solid | `invis | `bold ] list ->
?weight:float ->
unit -> statement
val label_of_text : ?fontcolor:color -> ?fontname:string -> ?fontsize:int -> text -> label
val label_of_table : ?fontcolor:color -> ?fontname:string -> ?fontsize:int -> table -> label
val label_of_image :
?align: [ `CENTER | `LEFT | `RIGHT ] ->
?valign:[ `BOTTOM | `MIDDLE | `TOP ] ->
?bgcolor:color ->
?border:float ->
?cellborder:float ->
?cellpadding:float ->
?cellspacing:float ->
?fixedsize:bool ->
?height:float ->
?href:string ->
?port:string ->
?target:string ->
?title:string ->
?tooltip:string ->
?width:float ->
?imagescale:[ `BOTH | `FALSE | `HEIGHT | `TRUE | `WIDTH ] ->
filename -> label
val html_of_text : ?fontcolor:color -> ?fontname:string -> ?fontsize:int -> text -> html_like
val html_of_table : ?fontcolor:color -> ?fontname:string -> ?fontsize:int -> table -> html_like
val html_of_label : ?fontcolor:color -> ?fontname:string -> ?fontsize:int -> label -> html_like
val text_of_string : ?br:unit -> ?align:[ `CENTER | `LEFT | `RIGHT ] -> string -> text
val text_concat : text list -> text
val table :
?align: [ `CENTER | `LEFT | `RIGHT ] ->
?valign:[ `BOTTOM | `MIDDLE | `TOP ] ->
?bgcolor:color ->
?border:float ->
?cellborder:float ->
?cellpadding:float ->
?cellspacing:float ->
?fixedsize:bool ->
?height:float ->
?href:string ->
?port:string ->
?target:string ->
?title:string ->
?tooltip:string ->
?width:float
-> row list -> table
val cell_of_text :
?align: [ `CENTER | `LEFT | `RIGHT ] ->
?valign:[ `BOTTOM | `MIDDLE | `TOP ] ->
?bgcolor:color ->
?border:float ->
?cellpadding:float ->
?cellspacing:float ->
?fixedsize:bool ->
?height:float ->
?href:string ->
?port:string ->
?target:string ->
?title:string ->
?tooltip:string ->
?width:float ->
?colspan:int ->
?rowspan:int ->
?fontcolor:color -> ?fontname:string -> ?fontsize:int -> text -> cell
val cell_of_string :
?align: [ `CENTER | `LEFT | `RIGHT ] ->
?valign:[ `BOTTOM | `MIDDLE | `TOP ] ->
?bgcolor:color ->
?border:float ->
?cellpadding:float ->
?cellspacing:float ->
?fixedsize:bool ->
?height:float ->
?href:string ->
?port:string ->
?target:string ->
?title:string ->
?tooltip:string ->
?width:float ->
?colspan:int ->
?rowspan:int ->
?fontcolor:color -> ?fontname:string -> ?fontsize:int -> string -> cell
val cell_of_table :
?align: [ `CENTER | `LEFT | `RIGHT ] ->
?valign:[ `BOTTOM | `MIDDLE | `TOP ] ->
?bgcolor:color ->
?border:float ->
?cellpadding:float ->
?cellspacing:float ->
?fixedsize:bool ->
?height:float ->
?href:string ->
?port:string ->
?target:string ->
?title:string ->
?tooltip:string ->
?width:float ->
?colspan:int ->
?rowspan:int ->
?fontcolor:color -> ?fontname:string -> ?fontsize:int -> table -> cell
val cell_of_html :
?align: [ `CENTER | `LEFT | `RIGHT ] ->
?valign:[ `BOTTOM | `MIDDLE | `TOP ] ->
?bgcolor:color ->
?border:float ->
?cellpadding:float ->
?cellspacing:float ->
?fixedsize:bool ->
?height:float ->
?href:string ->
?port:string ->
?target:string ->
?title:string ->
?tooltip:string ->
?width:float ->
?colspan:int ->
?rowspan:int ->
?fontcolor:color -> ?fontname:string -> ?fontsize:int -> html_like -> cell
val cell_of_label :
?align: [ `CENTER | `LEFT | `RIGHT ] ->
?valign:[ `BOTTOM | `MIDDLE | `TOP ] ->
?bgcolor:color ->
?border:float ->
?cellpadding:float ->
?cellspacing:float ->
?fixedsize:bool ->
?height:float ->
?href:string ->
?port:string ->
?target:string ->
?title:string ->
?tooltip:string ->
?width:float ->
?colspan:int ->
?rowspan:int ->
?fontcolor:color -> ?fontname:string -> ?fontsize:int -> label -> cell
val cell_of_image :
?align: [ `CENTER | `LEFT | `RIGHT ] ->
?valign:[ `BOTTOM | `MIDDLE | `TOP ] ->
?bgcolor:color ->
?border:float ->
?cellpadding:float ->
?cellspacing:float ->
?fixedsize:bool ->
?height:float ->
?href:string ->
?port:string ->
?target:string ->
?title:string ->
?tooltip:string ->
?width:float ->
?colspan:int ->
?rowspan:int ->
?imagescale:[ `BOTH | `FALSE | `HEIGHT | `TRUE | `WIDTH ] ->
filename -> cell
val print : graph -> unit
val display : ?bg:unit -> ?silent:unit -> graph -> unit
val fprint : filename -> graph -> unit
val sprint : graph -> string
val graph_of_list : (node_ident * node_ident) list -> graph
type output_format =
[ `bmp (* Windows Bitmap Format *)
| `canon | `dot | `xdot (* DOT *)
| `cmap (* Client-side imagemap (deprecated) *)
| `dia (* Dia diagram creation program *)
| `eps (* Encapsulated PostScript *)
| `fig (* FIG *)
| `gd | `gd2 (* GD/GD2 formats *)
| `gif (* GIF *)
| `hpgl (* HP-GL subset of PCL *)
| `ico (* Icon Image File Format *)
| `imap | `cmapx (* Server-side and client-side imagemaps *)
| `imap_np | `cmapx_np (* Server-side and client-side imagemaps *)
| `ismap (* Server-side imagemap (deprecated) *)
| `jpg (* JPEG *)
| `pdf (* Portable Document Format (PDF) *)
| `plain | `plain_ext (* Simple text format *)
| `png (* Portable Network Graphics format *)
| `ps (* PostScript *)
| `ps2 (* PostScript for PDF *)
| `svg | `svgz (* Scalable Vector Graphics *)
| `tiff (* TIFF (Tag Image File Format) *)
| `vml | `vmlz (* Vector Markup Language (VML) *)
| `vrml (* VRML *)
| `wbmp (* Wireless BitMap format *)
(* The following provoke an long time (infinite?) execution: *)
(* | `xlib (* Xlib canvas *) *)
]
val string_of_output_format : output_format -> string
val output_format_of_string : string -> output_format
val output_format_description : output_format -> string
val admissible_output_formats : output_format list
val admissible_output_formats_as_strings : string list
val make_image :
?silent:unit -> (* Hide dot errors or warnings *)
?dotfile:filename ->
?imgfile:filename ->
?imgtype:output_format -> (* by default `png *)
graph -> (filename * filename)
(** Return a 4-tuple (output, as_string, description, file_command_output) *)
val working_output_formats : ?no_file_inspection:unit -> unit -> (output_format * string * string * string) list
val working_output_formats_as_objects : ?no_file_inspection:unit -> unit ->
< output_format : output_format;
output_format_as_string : string;
description : string;
file_command_output : string;
> list
ocamlbricks-0.90+bzr456.orig/DOT/dot_widget.ml 0000644 0001750 0001750 00000006353 13175721005 020043 0 ustar lucas lucas (* This file is part of ocamlbricks
Copyright (C) 2010 Jean-Vincent Loddo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . *)
(* Do not remove the following comment: it's an ocamldoc workaround. *)
(** *)
IFNDEF OCAML4_04_OR_LATER THEN
let lowercase = String.lowercase
let uppercase = String.uppercase
let capitalize = String.capitalize
ELSE
let lowercase = String.lowercase_ascii
let uppercase = String.uppercase_ascii
let capitalize = String.capitalize_ascii
ENDIF
let make_dot_filter_by_format_and_description ~output_format_as_string ~description =
let ext = output_format_as_string in
let name = Printf.sprintf "%s (*.%s)" description ext in
let patt1 = lowercase ext in
let patt2 = uppercase ext in
let patt3 = capitalize ext in
let patterns = List.map (Printf.sprintf "*.%s") [patt1; patt2; patt3] in
GFile.filter ~name ~patterns ()
let filter_of_format outfmt =
let xyzw_list = Dot.working_output_formats ~no_file_inspection:() () in
match ListExtra.search (fun (x,y,z,w) -> x=outfmt) xyzw_list with
| None -> failwith "Dot_widget.filter_of_output_format"
| Some (_, output_format_as_string, description, _) ->
make_dot_filter_by_format_and_description
~output_format_as_string
~description
let filter_of_string ext =
let outfmt = Dot.output_format_of_string ext in
filter_of_format outfmt
let make_all_working_filters_assoc () =
let xyzw_list = Dot.working_output_formats ~no_file_inspection:() () in
List.map (fun (x,y,z,w) -> (x, make_dot_filter_by_format_and_description y z)) xyzw_list
let make_all_working_filters () =
let xyzw_list = Dot.working_output_formats ~no_file_inspection:() () in
List.map (fun (x,y,z,w) -> make_dot_filter_by_format_and_description y z) xyzw_list
let combo_of_working_output_formats
?(active:Dot.output_format option)
?add_tearoffs
?focus_on_click
?has_frame
?wrap_width
?width
?height
?packing
?show
()
=
let xs = Dot.working_output_formats ~no_file_inspection:() () in
let xa = Array.of_list xs in
let strings =
List.map
(fun (frm, str, des, fil) ->
let x = StringExtra.make_wide str 10 in
Printf.sprintf "%s%s" x des)
xs
in
let active = Option.bind active (fun act -> ListExtra.indexSuchThat (fun (frm,_,_,_) -> frm = act) xs) in
let cb =
GEdit.combo_box_text
~strings
~use_markup:true
?active
?add_tearoffs
?focus_on_click
?has_frame
?wrap_width
?width
?height
?packing
?show
()
in
let get_active_output_format () =
let index = (fst cb)#active in
let (x,_,_,_) = xa.(index) in x
in
((fst cb), get_active_output_format)
ocamlbricks-0.90+bzr456.orig/DOT/dot.ml 0000644 0001750 0001750 00000114661 13175721005 016502 0 ustar lucas lucas (* This file is part of ocamlbricks
Copyright (C) 2010 Jean-Vincent Loddo
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see . *)
(* Do not remove the following comment: it's an ocamldoc workaround. *)
(** *)
#load "include_type_definitions_p4.cmo"
;;
INCLUDE DEFINITIONS "../DOT/dot.mli"
;;
type graph = {
strict : bool;
digraph : bool;
name : name;
statements : statement list;
}
and statement =
| Graph_default of graph_option (* name=val *)
| Graph_defaults of graph_option list (* graph [name=val,..] *)
| Node_defaults of node_option list (* node [name=val,..] *)
| Edge_defaults of edge_option list (* edge [name=val,..] *)
| Node of node_ident * (node_option list) (* id [name=val,...] *)
| Edge of node_ident * node_ident * (edge_option list) (* id -> id [name=val,...] *)
| Subgraph of name * (statement list) (* subgraph name { statements } *)
| Statement_list of statement list
and name = string
and graph_option = string
and node_option = string
and edge_option = string
let commacat = String.concat ","
let newlinecat = String.concat "\n"
let rec cotokens_of_statement tab edge_operator = function
| Graph_default graph_option -> [Printf.sprintf "%s%s" tab graph_option]
| Graph_defaults graph_option_list -> [Printf.sprintf "%sgraph [%s]" tab (commacat graph_option_list)]
| Node_defaults node_option_list -> [Printf.sprintf "%snode [%s]" tab (commacat node_option_list)]
| Edge_defaults edge_option_list -> [Printf.sprintf "%sedge [%s]" tab (commacat edge_option_list)]
| Node (node_ident, node_option_list) -> [Printf.sprintf "%s%s [%s]" tab node_ident (commacat node_option_list)]
| Edge (n1, n2, edge_option_list) -> [Printf.sprintf "%s%s %s %s [%s]" tab n1 edge_operator n2 (commacat edge_option_list)]
| Statement_list statement_list -> List.flatten (List.map (cotokens_of_statement tab edge_operator) statement_list)
| Subgraph (name, statement_list) ->
let tab' = (tab^" ") in
let first = Printf.sprintf "%ssubgraph %s {" tab name in
let last = Printf.sprintf "%s}" tab in
let rest = ListExtra.flatten ~acc:[last] (List.map (cotokens_of_statement tab' edge_operator) statement_list) in
first::rest
let cotokens_of_graph { strict = strict; digraph = digraph; name = name; statements = statements; } =
let strict = if strict then "strict " else "" in
let (digraph, edge_operator) = if digraph then ("digraph","->") else ("graph","--") in
let first = Printf.sprintf "%s%s %s {" strict digraph name in
let last = Printf.sprintf "}" in
let rest = ListExtra.flatten ~acc:[last] (List.map (cotokens_of_statement " " edge_operator) statements) in
first::rest
let print g =
begin
List.iter (Printf.printf "%s\n") (cotokens_of_graph g);
flush stdout;
end
let fprint filename g =
begin
let ch = open_out filename in
List.iter (Printf.fprintf ch "%s\n") (cotokens_of_graph g);
flush ch;
close_out ch;
end
let sprint g = newlinecat (cotokens_of_graph g)
let string_of_output_format = function
|`bmp-> "bmp"
|`canon->"canon"
|`dot->"dot"
|`xdot->"xdot"
|`cmap->"cmap"
| `dia->"dia"
|`eps->"eps"
|`fig->"fig"
|`gd->"gd"
|`gd2->"gd2"
|`gif->"gif"
|`hpgl->"hpgl"
|`ico->"ico"
|`imap->"imap"
|`cmapx->"cmapx"
|`imap_np->"imap_np"
|`cmapx_np->"cmapx_np"
|`ismap->"ismap"
|`jpg->"jpg"
|`pdf->"pdf"
|`plain->"plain"
|`plain_ext->"plain_ext"
|`png->"png"
|`ps->"ps"
|`ps2->"ps2"
|`svg->"svg"
|`svgz->"svgz"
|`tiff->"tiff"
|`vml->"vml"
|`vmlz->"vmlz"
|`vrml->"vrml"
|`wbmp->"wbmp"
(* |`xlib->"xlib" *)
let output_format_of_string = function
| "bmp" -> `bmp
| "canon" -> `canon
| "dot" -> `dot
| "xdot" -> `xdot
| "dia" -> `dia
| "cmap" -> `cmap
| "eps" -> `eps
| "fig" -> `fig
| "gd" -> `gd
| "gd2" -> `gd2
| "gif" -> `gif
| "hpgl" -> `hpgl
| "ico" -> `ico
| "imap" -> `imap
| "cmapx" -> `cmapx
| "imap_np" -> `imap_np
| "cmapx_np" -> `cmapx_np
| "ismap" -> `ismap
| "jpg" -> `jpg
| "pdf" -> `pdf
| "plain" -> `plain
| "plain_ext" -> `plain_ext
| "png" -> `png
| "ps" -> `ps
| "ps2" -> `ps2
| "svg" -> `svg
| "svgz" -> `svgz
| "tiff" -> `tiff
| "vml" -> `vml
| "vmlz" -> `vmlz
| "vrml" -> `vrml
| "wbmp" -> `wbmp
(* | "xlib" -> `xlib *)
| _ -> raise Not_found
let admissible_output_formats = [
`bmp; `canon; `dia; `dot; `xdot; `cmap; `eps; `fig; `gd; `gd2; `gif; `hpgl; `ico; `imap; `cmapx; `imap_np; `cmapx_np; `ismap;
`jpg; `pdf; `plain; `plain_ext; `png; `ps; `ps2; `svg; `svgz; `tiff; `vml; `vmlz; `vrml; `wbmp; (*`xlib;*)
]
let admissible_output_formats_as_strings =
List.map string_of_output_format admissible_output_formats
let output_format_description = function
| `bmp -> "Windows Bitmap Format"
| `canon | `dot | `xdot -> "Graphviz dot drawing program"
| `cmap -> "Client-side imagemap (deprecated)"
| `dia -> "Diagram creation program"
| `eps -> "Encapsulated PostScript"
| `fig -> "FIG vector drawing format"
| `gd -> "GD graphics library format"
| `gd2 -> "GD2 graphics library format"
| `gif -> "GIF Graphics Interchange Format"
| `hpgl -> "HP-GL subset of PCL"
| `ico -> "Icon Image File Format"
| `imap | `cmapx -> "Server- and client-side imagemaps"
| `imap_np | `cmapx_np -> "Server- and client-side imagemaps"
| `ismap -> "Server-side imagemap (deprecated)"
| `jpg -> "JPEG Joint Photographic Group"
| `pdf -> "PDF Portable Document Format"
| `plain | `plain_ext -> "Simple text format"
| `png -> "PNG Portable Network Graphics format"
| `ps -> "PostScript"
| `ps2 -> "PostScript for PDF"
| `svg -> "Scalable Vector Graphics"
| `svgz -> "Compressed Scalable Vector Graphics"
| `tiff -> "TIFF Tag Image File Format"
| `vml -> "VML Vector Markup Language"
| `vmlz -> "VML Compressed Vector Markup Language"
| `vrml -> "VRML Text file format"
| `wbmp -> "Wireless BitMap format"
(* | `xlib -> "Xlib canvas" *)
let make_image ?silent ?dotfile ?imgfile ?(imgtype=`png) g =
begin
let imgtype = string_of_output_format imgtype in
let dotfile = match dotfile with Some x -> x | None -> Filename.temp_file "Dot.make_image." ".dot" in
let imgfile = match imgfile with Some x -> x | None -> Filename.temp_file "Dot.make_image." ("."^imgtype) in
fprint dotfile g;
let silent = match silent with None -> "" | Some () -> "2>/dev/null" in
let cmd = Printf.sprintf "dot -T%s -o %s %s %s" imgtype imgfile dotfile silent in
if (Sys.command cmd) <> 0
then failwith (Printf.sprintf "Dot.make_image: dot doesn't like this graph (file: %s)" dotfile)
else ();
(dotfile, imgfile)
end
let display_fg ~silent g =
begin
let dotfile = Filename.temp_file "Dot.display." ".dot" in
let pngfile = Filename.temp_file "Dot.display." ".png" in
fprint dotfile g;
let cmd = Printf.sprintf "dot -Tpng -o %s %s %s" pngfile dotfile silent in
if (Sys.command cmd) <> 0
then failwith (Printf.sprintf "Dot.display (fg): dot doesn't like this graph (file: %s)" dotfile)
else ();
let cmd = Printf.sprintf "display %s %s" pngfile silent in
if (Sys.command cmd) <> 0
then failwith (Printf.sprintf "Dot.display (fg): display (imagemagick) doesn't like this png (file: %s)" pngfile)
else ();
Sys.remove dotfile;
Sys.remove pngfile;
end
(* The temporary file is not deleted. The correct implementation should use threads (or futures). *)
let display_bg ~silent g =
begin
let dotfile = "Dot.display.bg.dot" in
fprint dotfile g;
let cmd = Printf.sprintf "dot -Tpng %s %s | display %s &" dotfile silent silent in
if (Sys.command cmd) <> 0
then failwith (Printf.sprintf "Dot.display (bg): something goes wrong (dotfile: %s)" dotfile)
else ();
end
let display ?bg ?silent g =
let silent = match silent with None -> "" | Some () -> "2>/dev/null" in
match bg with None -> display_fg ~silent g | Some () -> display_bg ~silent g
(* Common functions for further modules. *)
module Common = struct
let string_of_color = function
| `RGB (r,g,b) -> Printf.sprintf "#%02x%02x%02x" r g b
| `HSV (h,s,v) -> Printf.sprintf "%f %f %f" h s v
| `name x -> x
end
module Html_like_constructors = struct
let append_to_ref options inject opt =
match opt with
| None -> ()
| Some x -> (options := (inject x)::!options)
let html_map f ?fontcolor ?fontname ?fontsize alpha : html_like =
let font_attributes = ref [] in
let append f x = append_to_ref font_attributes f x in
append (fun x -> `COLOR x) fontcolor;
append (fun x -> `FACE x) fontname;
append (fun x -> `POINT_SIZE x) fontsize;
match !font_attributes with
| [] -> (f alpha)
| fattrs -> (`FONT (fattrs, f alpha))
let html_of_text =
let f x = `text x in
html_map f
let html_of_table =
let f x = `TABLE x in
html_map f
let html_of_label =
let f = function
| (`escaped s) -> (`text [`string s])
| (`html h) -> h
in html_map f
let label_of_text ?fontcolor ?fontname ?fontsize x = `html (html_of_text ?fontcolor ?fontname ?fontsize x)
let label_of_table ?fontcolor ?fontname ?fontsize x = `html (html_of_table ?fontcolor ?fontname ?fontsize x)
let text_of_string ?br ?align s : text =
let attributes = ref [] in
let append f x = append_to_ref attributes f x in
append (fun x -> `ALIGN x) align;
match br with
| None -> [ `string s ]
| Some () -> [ `string s; `BR !attributes ]
let text_concat (ts:text list) : text = List.flatten ts
let table
?align ?valign ?bgcolor ?border ?cellborder ?cellpadding ?cellspacing
?fixedsize ?height ?href ?port ?target ?title ?tooltip ?width
row_list : table =
let attributes = ref [] in
let append f x = append_to_ref attributes f x in
append (fun x -> `ALIGN x) align;
append (fun x -> `BGCOLOR x) bgcolor;
append (fun x -> `BORDER x) border;
append (fun x -> `CELLBORDER x) cellborder;
append (fun x -> `CELLPADDING x) cellpadding;
append (fun x -> `CELLSPACING x) cellspacing;
append (fun x -> `FIXEDSIZE x) fixedsize;
append (fun x -> `HEIGHT x) height;
append (fun x -> `HREF x) href;
append (fun x -> `PORT x) port;
append (fun x -> `TARGET x) target;
append (fun x -> `TITLE x) title;
append (fun x -> `TOOLTIP x) tooltip;
append (fun x -> `VALIGN x) valign;
append (fun x -> `WIDTH x) width;
(!attributes, row_list)
let cell_map f ?align ?valign ?bgcolor ?border ?cellpadding
?cellspacing ?fixedsize ?height ?href ?port ?target ?title ?tooltip
?width ?colspan ?rowspan ?fontcolor ?fontname ?fontsize
alpha : cell =
let attributes = ref [] in
let append f x = append_to_ref attributes f x in
append (fun x -> `ALIGN x) align;
append (fun x -> `BGCOLOR x) bgcolor;
append (fun x -> `BORDER x) border;
append (fun x -> `CELLPADDING x) cellpadding;
append (fun x -> `CELLSPACING x) cellspacing;
append (fun x -> `FIXEDSIZE x) fixedsize;
append (fun x -> `HEIGHT x) height;
append (fun x -> `HREF x) href;
append (fun x -> `PORT x) port;
append (fun x -> `TARGET x) target;
append (fun x -> `TITLE x) title;
append (fun x -> `TOOLTIP x) tooltip;
append (fun x -> `VALIGN x) valign;
append (fun x -> `WIDTH x) width;
append (fun x -> `COLSPAN x) colspan;
append (fun x -> `ROWSPAN x) rowspan;
let font_attributes = ref [] in
let append f x = append_to_ref font_attributes f x in
append (fun x -> `COLOR x) fontcolor;
append (fun x -> `FACE x) fontname;
append (fun x -> `POINT_SIZE x) fontsize;
(!attributes, f alpha !font_attributes)
let cell_of_text =
let f text = function
| [] -> `html (`text text)
| fattrs -> `html (`FONT (fattrs, `text text))
in
cell_map f
let cell_of_string =
let f s = function
| [] -> `html (`text [`string s])
| fattrs -> `html (`FONT (fattrs, `text [`string s]))
in
cell_map f
let cell_of_table =
let f table = function
| [] -> `html (`TABLE table)
| fattrs -> `html (`FONT (fattrs, `TABLE table))
in
cell_map f
let cell_of_html =
let f html = function
| [] -> `html html
| fattrs -> `html (`FONT (fattrs, html))
in
cell_map f
let cell_of_label =
let f label =
let html = match label with
| (`escaped s) -> (`text [`string s])
| (`html h) -> h
in function
| [] -> `html html
| fattrs -> `html (`FONT (fattrs, html))
in
cell_map f
let cell_of_image
?align ?valign ?bgcolor ?border ?cellpadding ?cellspacing
?fixedsize ?height ?href ?port ?target ?title ?tooltip ?width
?colspan ?rowspan ?imagescale
filename : cell =
let attributes = ref [] in
let append f x = append_to_ref attributes f x in
append (fun x -> `ALIGN x) align;
append (fun x -> `BGCOLOR x) bgcolor;
append (fun x -> `BORDER x) border;
append (fun x -> `CELLPADDING x) cellpadding;
append (fun x -> `CELLSPACING x) cellspacing;
append (fun x -> `FIXEDSIZE x) fixedsize;
append (fun x -> `HEIGHT x) height;
append (fun x -> `HREF x) href;
append (fun x -> `PORT x) port;
append (fun x -> `TARGET x) target;
append (fun x -> `TITLE x) title;
append (fun x -> `TOOLTIP x) tooltip;
append (fun x -> `VALIGN x) valign;
append (fun x -> `WIDTH x) width;
append (fun x -> `COLSPAN x) colspan;
append (fun x -> `ROWSPAN x) rowspan;
let image_attributes = ref [] in
let append f x = append_to_ref image_attributes f x in
append (fun x -> `SCALE x) imagescale;
append (fun x -> `SRC x) (Some filename);
(!attributes, `IMG !image_attributes)
let label_of_image
?align ?valign ?bgcolor ?border ?cellborder ?cellpadding ?cellspacing
?fixedsize ?height ?href ?port ?target ?title ?tooltip ?width
?imagescale
filename =
let cell = cell_of_image
?align ?valign ?bgcolor ?border ?cellpadding ?cellspacing
?fixedsize ?height ?href ?port ?target ?title ?tooltip ?width
?imagescale
filename
in
let table = table ?border ?cellborder [[cell]] in
`html (html_of_table table)
end (* Html_like_constructors *)
module Html_like_printer = struct
(* let cat ?(tab="") = List.fold_left (fun s x -> Printf.sprintf "%s\n%s%s" s tab x) "" *)
let cat ?(sep="\n") ?(tab="") = function
| [] -> ""
| y::ys -> List.fold_left (fun s x -> Printf.sprintf "%s%s%s%s" s sep tab x) y ys
let string_of_color = Common.string_of_color
let attribute tab = function
| `ALIGN `CENTER -> Printf.sprintf "%sALIGN=\"%s\"" tab "CENTER"
| `ALIGN `LEFT -> Printf.sprintf "%sALIGN=\"%s\"" tab "LEFT"
| `ALIGN `RIGHT -> Printf.sprintf "%sALIGN=\"%s\"" tab "RIGHT"
| `BGCOLOR color -> Printf.sprintf "%sBGCOLOR=\"%s\"" tab (string_of_color color)
| `BORDER x -> Printf.sprintf "%sBORDER=\"%f\"" tab x
| `CELLBORDER x -> Printf.sprintf "%sCELLBORDER=\"%f\"" tab x
| `CELLPADDING x -> Printf.sprintf "%sCELLPADDING=\"%f\"" tab x
| `CELLSPACING x -> Printf.sprintf "%sCELLSPACING=\"%f\"" tab x
| `FIXEDSIZE b -> Printf.sprintf "%sFIXEDSIZE=\"%b\"" tab b
| `HEIGHT x -> Printf.sprintf "%sHEIGHT=\"%f\"" tab x
| `HREF s -> Printf.sprintf "%sHREF=\"%s\"" tab s
| `PORT s -> Printf.sprintf "%sPORT=\"%s\"" tab s
| `TARGET s -> Printf.sprintf "%sTARGET=\"%s\"" tab s
| `TITLE s -> Printf.sprintf "%sTITLE=\"%s\"" tab s
| `TOOLTIP s -> Printf.sprintf "%sTOOLTIP=\"%s\"" tab s
| `VALIGN `MIDDLE -> Printf.sprintf "%sVALIGN=\"%s\"" tab "MIDDLE"
| `VALIGN `BOTTOM -> Printf.sprintf "%sVALIGN=\"%s\"" tab "BOTTOM"
| `VALIGN `TOP -> Printf.sprintf "%sVALIGN=\"%s\"" tab "TOP"
| `WIDTH x -> Printf.sprintf "%sWIDTH=\"%f\"" tab x
(* font *)
| `COLOR color -> Printf.sprintf "%sCOLOR=\"%s\"" tab (string_of_color color)
| `FACE s -> Printf.sprintf "%sFACE=\"%s\"" tab s
| `POINT_SIZE i -> Printf.sprintf "%sPOINT-SIZE=\"%d\"" tab i
(* cell *)
| `COLSPAN i -> Printf.sprintf "%sCOLSPAN=\"%d\"" tab i
| `ROWSPAN i -> Printf.sprintf "%sROWSPAN=\"%d\"" tab i
(* image *)
| `SCALE `FALSE -> Printf.sprintf "%sSCALE=\"%s\"" tab "FALSE"
| `SCALE `TRUE -> Printf.sprintf "%sSCALE=\"%s\"" tab "TRUE"
| `SCALE `WIDTH -> Printf.sprintf "%sSCALE=\"%s\"" tab "WIDTH"
| `SCALE `HEIGHT -> Printf.sprintf "%sSCALE=\"%s\"" tab "HEIGHT"
| `SCALE `BOTH -> Printf.sprintf "%sSCALE=\"%s\"" tab "BOTH"
| `SRC s -> Printf.sprintf "%sSRC=\"%s\"" tab s
let rec html_like tab =
function
| `text is -> text is
| `TABLE tbl -> table tab tbl
| `FONT html -> font tab html
and string_or_br =
function
| `string s -> StringExtra.expand (function '>' -> Some ">" | '<' -> Some "<" | _ -> None ) s
| `BR attribute_list ->
let xs = List.map (attribute "") attribute_list in
let br_and_attrs = cat ~sep:" " ("
" br_and_attrs
and text string_or_br_list = cat ~sep:"" (List.map string_or_br string_or_br_list)
and table tab =
let tab' = tab ^ " " in
function
| (attribute_list, row_list) ->
let xs = List.map (attribute tab') attribute_list in
let attrs = cat xs in
let ys = List.map (row tab') row_list in
let rows = cat ~tab:tab' ys in
(* Printf.sprintf "%s" tab tab' attrs tab rows tab *)
Printf.sprintf "\n%s" tab attrs rows tab
and row tab =
let tab' = tab ^ " " in
function cell_list ->
let xs = List.map (cell tab') cell_list in
let cells = cat ~tab:tab' xs in
Printf.sprintf "%s\n%s\n%s
" tab cells tab
and cell_content tab = function
| `html h -> html_like tab h
(* In the case of an image, dot doesn't accept spaces among and !!!*)
| `IMG img -> image img
and cell tab =
let tab' = tab ^ " " in
function
| (cell_attribute_list, html_or_image) ->
let xs = List.map (attribute tab') cell_attribute_list in
let attrs = cat ~tab:tab' xs in
let content = cell_content tab' html_or_image in
Printf.sprintf "%s | %s | " tab attrs content
and font tab =
let tab' = tab ^ " " in
function
| (attribute_list, content) ->
let xs = List.map (attribute "") attribute_list in
let attrs = cat ~sep:" " ~tab:"" xs in
let content = html_like tab' content in
Printf.sprintf "%s" attrs content
and image attribute_list =
let xs = List.map (attribute "") attribute_list in
let attrs = cat xs in
Printf.sprintf "
" attrs
end
module String_of = struct
let size = function
| `force (x,y) -> Printf.sprintf "size=\"%f,%f!\"" x y
| `max (x,y) -> Printf.sprintf "size=\"%f,%f\"" x y
let page (x,y) = Printf.sprintf "page=\"%f,%f\"" x y
let pagedir = function
| `BL -> "pagedir=BL"
| `BR -> "pagedir=BR"
| `LB -> "pagedir=LB"
| `LT -> "pagedir=LT"
| `RB -> "pagedir=RB"
| `RT -> "pagedir=RT"
| `TL -> "pagedir=TL"
| `TR -> "pagedir=TR"
let rotate = Printf.sprintf "rotate=\"%f\""
let ratio = function
| `auto -> "ratio=\"auto\""
| `compress -> "ratio=\"compress\""
| `fill -> "ratio=\"fill\""
| `float x -> Printf.sprintf "ratio=\"%f\"" x
let margin (x,y) = Printf.sprintf "margin=\"%f,%f\"" x y
let pos (x,y) = Printf.sprintf "pos=\"%f,%f\"" x y
let center () = "center=\"1\""
let nodesep = Printf.sprintf "nodesep=\"%f\""
let ordering = function
| `inp -> "ordering=\"in\""
| `out -> "ordering=\"out\""
let outputorder = function
| `breadthfirst -> "outputorder=\"breadthfirst\""
| `edgesfirst -> "outputorder=\"edgesfirst\""
| `nodesfirst -> "outputorder=\"nodesfirst\""
let rank = function
| `max -> "rank=\"max\""
| `min -> "rank=\"min\""
| `same -> "rank=\"same\""
| `sink -> "rank=\"sink\""
| `source -> "rank=\"source\""
let rankdir = function
| `TB -> "rankdir=\"TB\""
| `BT -> "rankdir=\"BT\""
| `LR -> "rankdir=\"LR\""
| `RL -> "rankdir=\"RL\""
let ranksep = Printf.sprintf "ranksep=\"%f\""
let clusterrank = function
| `global -> "clusterrank=\"global\""
| `local -> "clusterrank=\"local\""
| `none -> "clusterrank=\"none\""
let nslimit = Printf.sprintf "nslimit=\"%f\""
let layers xs =
let ys = List.fold_left (fun s x -> s^":"^x) "" xs in
Printf.sprintf "layers=\"%s\"" ys
let string_of_color = Common.string_of_color
let color x = Printf.sprintf "color=\"%s\"" (string_of_color x)
let bgcolor x = Printf.sprintf "bgcolor=\"%s\"" (string_of_color x)
let href = Printf.sprintf "href=\"%s\""
let url = Printf.sprintf "url=\"%s\""
let stylesheet = Printf.sprintf "stylesheet=\"%s\""
let charset = Printf.sprintf "charset=\"%s\""
let comment = Printf.sprintf "comment=\"%s\""
let compound () = "compound=\"true\""
let concentrate () = "concentrate=\"true\""
let regular () = "regular=\"true\""
let fontcolor x = Printf.sprintf "fontcolor=\"%s\"" (string_of_color x)
let fillcolor x = Printf.sprintf "fillcolor=\"%s\"" (string_of_color x)
let pencolor x = Printf.sprintf "pencolor=\"%s\"" (string_of_color x)
let labelfontcolor x = Printf.sprintf "labelfontcolor=\"%s\"" (string_of_color x)
let fontname = Printf.sprintf "fontname=\"%s\""
let labelfontname = Printf.sprintf "labelfontname=\"%s\""
let fontpath xs =
let ys = List.fold_left (fun s x -> s^":"^x) "" xs in
Printf.sprintf "fontpath=\"%s\"" ys
let fontsize = Printf.sprintf "fontsize=\"%d\""
let labelfontsize = Printf.sprintf "labelfontsize=\"%d\""
let string_of_html_like (html :html_like) = Html_like_printer.html_like "" html
let gen_label label = function
| `escaped x -> Printf.sprintf "%s=\"%s\"" label x
| `html h -> Printf.sprintf "%s=<%s>" label (string_of_html_like h)
let label = gen_label "label"
let headlabel = gen_label "headlabel"
let taillabel = gen_label "taillabel"
let labeljust = function
| `c -> "labeljust=\"c\""
| `l -> "labeljust=\"l\""
| `r -> "labeljust=\"r\""
let labelloc = function
| `b -> "labelloc=\"b\""
| `t -> "labelloc=\"t\""
let nojustify () = "nojustify=\"true\""
let fixedsize () = "fixedsize=\"true\""
let constraint_off () = "constraint=\"false\""
let decorate () = "decorate=\"true\""
let labelfloat () = "labelfloat=\"true\""
let peripheries = Printf.sprintf "peripheries=\"%d\""
let quantum = Printf.sprintf "quantum=\"%f\""
let remincross () = "remincross=\"true\""
let samplepoints = Printf.sprintf "samplepoints=\"%d\""
let distortion = Printf.sprintf "distortion=\"%f\""
let group = Printf.sprintf "group=\"%s\""
let height = Printf.sprintf "height=\"%f\""
let orientation = Printf.sprintf "orientation=\"%f\""
let width = Printf.sprintf "width=\"%f\""
let headclip = Printf.sprintf "headclip=\"%b\""
let tailclip = Printf.sprintf "tailclip=\"%b\""
let string_of_style = function
| `bold -> "bold"
| `dashed -> "dashed"
| `diagonals -> "diagonals"
| `dotted -> "dotted"
| `filled -> "filled"
| `invis -> "invis"
| `rounded -> "rounded"
| `solid -> "solid"
let style xs =
let ys = List.map string_of_style xs in
let zs = List.fold_left (fun s x -> s^","^x) "" ys in
Printf.sprintf "style=\"%s\"" zs
let layer xs =
let ys = List.fold_left (fun s x -> s^":"^x) "" xs in
Printf.sprintf "layer=\"%s\"" ys
let string_of_shape = function
| `Mcircle -> "Mcircle"
| `Mdiamond -> "Mdiamond"
| `Msquare -> "Msquare"
| `box -> "box"
| `circle -> "circle"
| `diamond -> "diamond"
| `doublecircle -> "doublecircle"
| `doubleoctagon -> "doubleoctagon"
| `egg -> "egg"
| `ellipse -> "ellipse"
| `hexagon -> "hexagon"
| `house -> "house"
| `invhouse -> "invhouse"
| `invtrapezium -> "invtrapezium"
| `invtriangle -> "invtriangle"
| `none -> "none"
| `octagon -> "octagon"
| `parallelogram -> "parallelogram"
| `pentagon -> "pentagon"
| `plaintext -> "plaintext"
| `point -> "point"
| `rect -> "rect"
| `rectangle -> "rectangle"
| `septagon -> "septagon"
| `trapezium -> "trapezium"
| `triangle -> "triangle"
| `tripleoctagon -> "tripleoctagon"
(* Managed outside: *)
| `polygon (sides,skew) -> assert false
| `epsf filename -> assert false
let shape = function
| `polygon (sides,skew) -> Printf.sprintf "shape=\"polygon\", sides=\"%d\", skew=\"%d\"" sides skew
| `epsf filename -> Printf.sprintf "shape=\"epsf\", shapefile=\"%s\"" filename
| x -> Printf.sprintf "shape=\"%s\"" (string_of_shape x)
(* For node (dot-undocumented) option "image=filename" *)
let image = Printf.sprintf "image=\"%s\""
let string_of_arrow_type = function
| `Open -> "open"
| `box -> "box"
| `crow -> "crow"
| `diamond -> "diamond"
| `dot -> "dot"
| `ediamond -> "ediamond"
| `empty -> "empty"
| `halfopen -> "halfopen"
| `inv -> "inv"
| `invdot -> "invdot"
| `invempty -> "invempty"
| `invodot -> "invodot"
| `none -> "none"
| `normal -> "normal"
| `obox -> "obox"
| `odiamond -> "odiamond"
| `odot -> "odot"
| `tee -> "tee"
| `vee -> "vee"
let arrowhead x = Printf.sprintf "arrowhead=\"%s\"" (string_of_arrow_type x)
let arrowtail x = Printf.sprintf "arrowtail=\"%s\"" (string_of_arrow_type x)
let string_of_dir= function
| `back -> "back"
| `both -> "both"
| `forward -> "forward"
| `none -> "none"
let dir x = Printf.sprintf "dir=\"%s\"" (string_of_dir x)
let arrowsize = Printf.sprintf "arrowsize=\"%f\""
let labelangle = Printf.sprintf "labelangle=\"%f\""
let labeldistance = Printf.sprintf "labeldistance=\"%f\""
let string_of_compass_point = function
| `e -> "e"
| `n -> "n"
| `ne -> "ne"
| `nw -> "nw"
| `s -> "s"
| `se -> "se"
| `sw -> "sw"
| `w -> "w"
let head_or_tail_port label = function
| ident, None -> Printf.sprintf "%s=\"%s\"" label ident
| ident, (Some cp) -> Printf.sprintf "%s=\"%s:%s\"" label ident (string_of_compass_point cp)
let headport = head_or_tail_port "headport"
let tailport = head_or_tail_port "tailport"
let lhead = Printf.sprintf "lhead=\"%s\""
let ltail = Printf.sprintf "ltail=\"%s\""
let minlen = Printf.sprintf "minlen=\"%d\""
let samehead = Printf.sprintf "samehead=\"%s\""
let sametail = Printf.sprintf "sametail=\"%s\""
let weight = Printf.sprintf "weight=\"%f\""
let z = Printf.sprintf "z=\"%f\""
end
let append options injection conv opt =
match opt with
| None -> ()
| Some x -> (options := (injection (conv x))::!options)
module Extract = struct
let unit = function None -> false | Some () -> true
let bool ?(default=false) = function None -> default | Some b -> b
let ident ?(prefix="id") =
let counter = ref 0 in
function
| None -> let result = Printf.sprintf "%s%d" prefix !counter in ((incr counter); result)
| Some id -> id
end (* Extract *)
let map_graph_options f
?strict ?digraph ?name ?size ?page ?pagedir ?rotate ?ratio ?margin ?center ?nodesep
?ordering ?outputorder ?rank ?rankdir ?ranksep ?clusterrank ?nslimit ?layers ?color
?bgcolor ?href ?url ?stylesheet ?charset ?comment ?compound ?concentrate ?fontcolor ?fontname
?fontpath ?fontsize ?label ?labeljust ?labelloc ?nojustify ?quantum ?remincross ?samplepoints
statement_list =
let strict = Extract.unit strict in
let digraph = Extract.bool ~default:true digraph in
let name = Extract.ident ~prefix:"graph_" name in
(** Create the container of options: *)
let graph_options = ref [] in
let append f x = append graph_options (fun e-> Graph_default e) f x in
append (String_of.size) size;
append (String_of.page) page;
append (String_of.pagedir) pagedir;
append (String_of.rotate) rotate;
append (String_of.ratio) ratio;
append (String_of.margin) margin;
append (String_of.center) center;
append (String_of.nodesep) nodesep;
append (String_of.ordering) ordering;
append (String_of.outputorder) outputorder;
append (String_of.rank) rank;
append (String_of.rankdir) rankdir;
append (String_of.ranksep) ranksep;
append (String_of.clusterrank) clusterrank;
append (String_of.nslimit) nslimit;
append (String_of.layers) layers;
append (String_of.color) color;
append (String_of.bgcolor) bgcolor;
append (String_of.href) href;
append (String_of.url) url;
append (String_of.stylesheet) stylesheet;
append (String_of.charset) charset;
append (String_of.comment) comment;
append (String_of.compound) compound;
append (String_of.concentrate) concentrate;
append (String_of.fontcolor) fontcolor;
append (String_of.fontname) fontname;
append (String_of.fontpath) fontpath;
append (String_of.fontsize) fontsize;
append (String_of.label) label;
append (String_of.labeljust) labeljust;
append (String_of.labelloc) labelloc;
append (String_of.nojustify) nojustify;
append (String_of.quantum) quantum;
append (String_of.remincross) remincross;
append (String_of.samplepoints) samplepoints;
f strict digraph name statement_list graph_options
let graph =
let f strict digraph name statement_list graph_options =
{ strict = strict; digraph = digraph; name=name;
statements = List.append !graph_options statement_list; }
in map_graph_options f
let graph_default =
let map_graph_options_call =
let f strict digraph name statement_list graph_options =
Graph_defaults (List.map (function Graph_default x -> x | _ -> assert false) !graph_options)
in map_graph_options f
in
map_graph_options_call ?strict:None ?digraph:None ?name:None
let subgraph ?name ?rank statement_list =
let name = Extract.ident ~prefix:"subgraph_" name in
let statements = ref statement_list in
let append f x = append statements (fun e-> Graph_default e) f x in
append (String_of.rank) rank;
Subgraph (name, !statements)
let cluster
?name_suffix ?rank ?color ?bgcolor ?fillcolor ?pencolor ?fontcolor ?fontname ?fontsize
?label ?labeljust ?labelloc ?nojustify ?url ?peripheries ?style
statement_list =
let name = "cluster_"^(Extract.ident name_suffix) in
let statements = ref statement_list in
let append f x = append statements (fun e-> Graph_default e) f x in
append (String_of.rank) rank;
append (String_of.color) color;
append (String_of.bgcolor) bgcolor;
append (String_of.fillcolor) fillcolor;
append (String_of.pencolor) pencolor;
append (String_of.fontcolor) fontcolor;
append (String_of.fontname) fontname;
append (String_of.fontsize) fontsize;
append (String_of.label) label;
append (String_of.labeljust) labeljust;
append (String_of.labelloc) labelloc;
append (String_of.nojustify) nojustify;
append (String_of.url) url;
append (String_of.peripheries) peripheries;
append (String_of.style) style;
Subgraph (name, !statements)
let map_edge_options f
?url ?color ?comment ?arrowhead ?arrowtail ?dir ?arrowsize ?constraint_off ?decorate
?fontcolor ?fontname ?fontsize ?headclip ?headlabel ?headport ?tailclip ?taillabel ?tailport
?label ?labelangle ?labeldistance ?labelfloat ?labelfontcolor ?labelfontname ?labelfontsize
?layer ?lhead ?ltail ?minlen ?nojustify ?pos ?samehead ?sametail ?style ?weight
alpha =
let edge_options = ref [] in
let append f x = append edge_options (fun e->e) f x in
append (String_of.url) url;
append (String_of.color) color;
append (String_of.comment) comment;
append (String_of.arrowhead) arrowhead;
append (String_of.arrowtail) arrowtail;
append (String_of.dir) dir;
append (String_of.arrowsize) arrowsize;
append (String_of.constraint_off) constraint_off;
append (String_of.decorate) decorate;
append (String_of.fontcolor) fontcolor;
append (String_of.fontname) fontname;
append (String_of.fontsize) fontsize;
append (String_of.headclip) headclip;
append (String_of.headlabel) headlabel;
append (String_of.headport) headport;
append (String_of.tailclip) tailclip;
append (String_of.taillabel) taillabel;
append (String_of.tailport) tailport;
append (String_of.label) label;
append (String_of.labelangle) labelangle;
append (String_of.labeldistance) labeldistance;
append (String_of.labelfloat) labelfloat;
append (String_of.labelfontcolor) labelfontcolor;
append (String_of.labelfontname) labelfontname;
append (String_of.labelfontsize) labelfontsize;
append (String_of.layer) layer;
append (String_of.lhead) lhead;
append (String_of.ltail) ltail;
append (String_of.minlen) minlen;
append (String_of.nojustify) nojustify;
append (String_of.pos) pos;
append (String_of.samehead) samehead;
append (String_of.sametail) sametail;
append (String_of.style) style;
append (String_of.weight) weight;
f alpha edge_options
let edge =
let f = fun node_ident_head edge_options node_ident_tail -> Edge (node_ident_head, node_ident_tail, !edge_options) in
map_edge_options f
let edge_default =
let f _ edge_options = (Edge_defaults !edge_options) in
map_edge_options f
let map_node_options f
?url ?color ?comment ?distortion ?fillcolor ?fontcolor ?fontname ?fontsize ?fixedsize ?group ?height
?layer ?margin ?nojustify ?orientation ?peripheries ?pos ?regular ?shape ?image ?label ?style ?width ?z
node_ident =
let node_options = ref [] in
let append f x = append node_options (fun e->e) f x in
append (String_of.url) url;
append (String_of.color) color;
append (String_of.comment) comment;
append (String_of.distortion) distortion;
append (String_of.fillcolor) fillcolor;
append (String_of.fontcolor) fontcolor;
append (String_of.fontname) fontname;
append (String_of.fontsize) fontsize;
append (String_of.fixedsize) fixedsize;
append (String_of.group) group;
append (String_of.height) height;
append (String_of.layer) layer;
append (String_of.margin) margin;
append (String_of.nojustify) nojustify;
append (String_of.orientation) orientation;
append (String_of.peripheries) peripheries;
append (String_of.pos) pos;
append (String_of.regular) regular;
append (String_of.shape) shape;
append (String_of.image) image;
append (String_of.label) label;
append (String_of.style) style;
append (String_of.width) width;
append (String_of.z) z;
f node_ident node_options
let node =
let f = fun node_ident node_options -> Node (node_ident, !node_options) in
map_node_options f
let node_default =
let f _ node_options = (Node_defaults !node_options) in
map_node_options f
let phantom_fresh_name = Counter.make_string_generator ~prefix:"_phantom_" ()
(* shorthand *)
module Html = Html_like_constructors
(* Node redefinition, in order to manage the pseudo-option "outlabel" *)
let node
?url ?color ?comment ?distortion ?fillcolor ?fontcolor ?fontname ?fontsize ?fixedsize ?group ?height
?layer ?margin ?nojustify ?orientation ?peripheries ?pos ?regular ?shape ?image ?label ?style ?width ?z
?outlabel
node_ident =
let super = node in (* The redefined function *)
match outlabel with
| None ->
super
?url ?color ?comment ?distortion ?fillcolor ?fontcolor ?fontname ?fontsize ?fixedsize ?group ?height
?layer ?margin ?nojustify ?orientation ?peripheries ?pos ?regular ?shape ?image ?label ?style ?width ?z
node_ident
| Some outlabel ->
let wrapped_label =
(match label with
| None -> (`escaped node_ident)
| Some label -> label
)
in
let label =
let table_content = match outlabel with
| `north label ->
let l = Html.cell_of_label ~valign:`BOTTOM label in
let n = Html.cell_of_label ~valign:`TOP wrapped_label in
[[l];[n]]
| `south label ->
let l = Html.cell_of_label ~valign:`TOP label in
let n = Html.cell_of_label ~valign:`BOTTOM wrapped_label in
[[n];[l]]
| `east label ->
let l = Html.cell_of_label ~align:`LEFT label in
let n = Html.cell_of_label ~align:`RIGHT wrapped_label in
[[n;l]]
| `west label ->
let l = Html.cell_of_label ~align:`RIGHT label in
let n = Html.cell_of_label ~align:`LEFT wrapped_label in
[[l;n]]
in
Html.label_of_table
(Html.table
~align:`CENTER
~border:0.
~cellborder:0.
~cellspacing:0.
table_content)
in
super
?url ?color ?comment ?distortion ?fillcolor ?fontcolor ?fontname ?fontsize ?fixedsize ?group ?height
?layer ?margin ?nojustify ?orientation ?peripheries ?pos ?regular ?shape ?image ~label ?style ?width ?z
node_ident
let graph_of_list nns =
let sl = List.map (function (n1,n2) -> edge n1 n2) nns in
graph sl
include Html_like_constructors
let working_output_formats ?no_file_inspection () =
let g = (graph [node "good_luck"]) in
let dotfile = Filename.temp_file "Dot.make_image." ".dot" in
let imgfile = Filename.temp_file "Dot.make_image." ".img" in
let mill imgtype =
try
let _ = make_image ~silent:() ~imgtype ~dotfile ~imgfile g in
let file_output =
match no_file_inspection with
| Some () -> ""
| None ->
let cmd = Printf.sprintf "file -b -z %s" imgfile in
StringExtra.rstrip (UnixExtra.shell cmd)
in
Some (imgtype, (string_of_output_format imgtype), (output_format_description imgtype), file_output)
with _ -> None
in
let result = ListExtra.filter_map mill admissible_output_formats in
let () = List.iter Unix.unlink [dotfile; imgfile] in
result
(** Redefined with a cache: *)
let working_output_formats =
let cache1 = ref None in
let cache2 = ref None in
fun ?no_file_inspection () ->
let run_with_cache cache =
match !cache with
| None ->
let result = working_output_formats ?no_file_inspection () in
cache := Some result;
result
| Some result -> result
in
match no_file_inspection with
| None -> run_with_cache cache1
| Some () -> run_with_cache cache2
let working_output_formats_as_objects ?no_file_inspection () =
List.map
(fun (x,y,z,t) ->
object
method output_format = x
method output_format_as_string = y
method description = z
method file_command_output = t
end)
(working_output_formats ?no_file_inspection ())
ocamlbricks-0.90+bzr456.orig/Makefile 0000644 0001750 0001750 00000106746 13175721005 016401 0 ustar lucas lucas # This -*- makefile -*- is part of our build system for OCaml projects
# Copyright (C) 2008, 2009 Luca Saiu
# Copyright (C) 2008, 2010, 2016 Jean-Vincent Loddo
# Copyright (C) 2008, 2009, 2010, 2016 Université Paris 13
# Updated in 2008 by Jonathan Roudiere
# Thanks to JulioJu (https://github.com/JulioJu) for the patch
# about prefix_install
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# This is the revision of 2016-06-07.
######################################################################
# This make file is general-purpose: the actual project-dependant part
# should be written for each specific project in a 'Makefile.local'
# file.
#
# This contains some (simple) makefile magic which is only supported
# by GNU Make. Don't even try to use other make implementations.
######################################################################
######################################################################
# Implementation of targets. Note that the user is *not* supposed to
# override these, but only to define the project-dependant '-local'
# versions:
# Makefiles (this one as those in other parts) use extensively the bash shell
SHELL=/bin/bash
OCAMLBUILD = $$( $(call OCAMLBUILD_COMMAND_LINE) )
LIBRARYPREFIX=$(shell $(call READ_CONFIG, libraryprefix); echo $$libraryprefix)
OCAML_VERSION=$(shell $(call READ_CONFIG, ocaml_version); echo $$ocaml_version)
OCAML_LIBRARYPREFIX=$(shell $(call READ_CONFIG, ocaml_libraryprefix); echo $$ocaml_libraryprefix)
# The main target. Its implementation is entirely project-dependant:
main: ocamlbuild-stuff manually_pre_actions main-local data libraries programs manually_post_actions
@(echo "Success.")
# Build C modules (no one, by default):
c-modules:
@(mkdir _build &> /dev/null || true) && \
for x in $(C_OBJECTS_TO_LINK); do \
make _build/$$x.o; \
done
BUILD_FROM_STUFF = \
@( echo "Building $(1)..."; \
shopt -s execfail; set -e; \
for x in $(2); do \
echo "Building \"$$x\"..."; \
if $(MAKE) $$x; then \
echo "Ok, \"$$x\" was built with success."; \
else \
echo "FAILED when building \"$$x\"."; \
exit -1; \
fi; \
done; \
echo "Success: $(1) were built.")
# Build only data:
data: ocamlbuild-stuff data-local $(DATA)
$(call BUILD_FROM_STUFF, data, $(DATA))
# Build only native libraries:
native-libraries: ocamlbuild-stuff c-modules native-libraries-local $(NATIVE_LIBRARIES)
$(call BUILD_FROM_STUFF, native-libraries, $(NATIVE_LIBRARIES))
# Build only bytecode libraries:
byte-libraries: ocamlbuild-stuff c-modules byte-libraries-local $(BYTE_LIBRARIES)
$(call BUILD_FROM_STUFF, byte-libraries, $(BYTE_LIBRARIES))
# Build libraries; bytecode, native, or both:
libraries: c-modules libraries-local
@($(call BUILD_NATIVE_ANDOR_BYTECODE,libraries) ) # Spaces are ok
# Build programs; bytecode, native, or both:
programs: c-modules programs-local
@($(call BUILD_NATIVE_ANDOR_BYTECODE,programs) ) # Spaces are ok
# Build the native and/or bytecode version of $(1). $(1) may be either
# "libraries" or "programs". *Don't* put a space before the argument.
BUILD_NATIVE_ANDOR_BYTECODE = \
(if [ "$$( $(call NATIVE) )" == 'native' ]; then \
echo "Building native $(1)..."; \
if $(MAKE) native-$(1); then \
echo "Success: native $(1) were built."; \
else \
echo "FAILURE: could not build native $(1)."; \
exit -1; \
fi; \
else \
echo "NOT building native $(1)..."; \
fi; \
if [ "$$( $(call BYTE) )" == 'byte' ]; then \
echo "Builing bytecode $(1)..."; \
if $(MAKE) byte-$(1); then \
echo "Success: bytecode $(1) were built."; \
else \
echo "FAILURE: could not build bytecode $(1)."; \
exit -1; \
fi; \
else \
echo "NOT building bytecode $(1)..."; \
fi)
# Build only native programs:
native-programs: ocamlbuild-stuff native-programs-local $(NATIVE_PROGRAMS) $(ROOT_NATIVE_PROGRAMS)
$(call BUILD_FROM_STUFF, native-programs, $(NATIVE_PROGRAMS) $(ROOT_NATIVE_PROGRAMS))
# Build only bytecode programs:
byte-programs: ocamlbuild-stuff byte-programs-local $(BYTE_PROGRAMS) $(ROOT_BYTE_PROGRAMS)
$(call BUILD_FROM_STUFF, byte-programs, $(BYTE_PROGRAMS) $(ROOT_BYTE_PROGRAMS))
# 'all' is just an alias for 'main':
all: main
# In some projects we may need to build something more than 'main',
# but we do nothing more by default:
world: world-local main
@(echo 'Success.')
############################################################################
# Support for manually generated files (i.e. not generated with ocamlbuild)
############################################################################
# Example: (in your Makefile.local)
#
# foo.byte : manually_pre_actions
# foo.native : manually_pre_actions
#
# MANUALLY_PRE_COPY_IN_build = include_as_string_p4.ml USAGE.txt
# MANUALLY_PRE_MAKE_IN_build = include_as_string_p4.cmo
#
# _build/include_as_string_p4.cmo: include_as_string_p4.ml
# ocamlc -c -I +camlp4 camlp4lib.cma -pp camlp4of -o $@ $<
.PHONY : manually_pre_actions manually_post_actions
################################# PRE-ACTIONS support
# Files that must be copied in _build/ *before* the ocamlbuild processing.
MANUALLY_PRE_COPY_IN_build =
# Targets that must be created in _build/ *before* the ocamlbuild processing.
# For each foo.bar that appears in this list, you have to write a rule
# _build/foo.bar in your Makefile.local
MANUALLY_PRE_MAKE_IN_build =
manually_pre_actions:
$(call PERFORM_MANUALLY_PRE_ACTIONS, $(MANUALLY_PRE_COPY_IN_build),$(MANUALLY_PRE_MAKE_IN_build))
# Detect if "make clean" is required or copy and build manually targets
# specified in MANUALLY_PRE_COPY_IN_build and MANUALLY_PRE_MAKE_IN_build
PERFORM_MANUALLY_PRE_ACTIONS = \
@(\
if test -d _build/; \
then \
echo "Checking if files manually copied in _build/ have been modified..."; \
for x in $(1); do \
echo "Checking \"$$x\"..."; \
test ! -f _build/$$x || \
diff -q $$x _build/$$x 2>/dev/null || \
{ echo -e "********************\nmake clean required!\n********************"; exit 1; } ;\
done; \
else \
mkdir _build/; \
fi; \
for x in $(1); do echo "Manually pre-copying \"$$x\"..."; cp --parent -f $$x _build/; done; \
for y in $(2); do echo "Manually pre-building \"$$y\"..."; make _build/$$y || exit 1; done; \
)
################################# POST-ACTIONS support
# Files that must be copied in _build/ *after* the ocamlbuild processing.
MANUALLY_POST_COPY_IN_build =
# Targets that must be created in _build/ *after* the ocamlbuild processing.
# For each foo.bar that appears in this list, you have to write a rule
# _build/foo.bar in your Makefile.local
MANUALLY_POST_MAKE_IN_build =
manually_post_actions:
$(call PERFORM_MANUALLY_POST_ACTIONS, $(MANUALLY_POST_COPY_IN_build), $(MANUALLY_POST_MAKE_IN_build))
PERFORM_MANUALLY_POST_ACTIONS = \
@(\
for x in $(1); do echo "Manually post-copying \"$$x\"..."; cp --parent -f $$x _build/; done; \
for y in $(2); do echo "Manually post-building \"$$y\"..."; make _build/$$y || exit 1; done; \
)
############################################################################
# Other entries
# Edit all ml/mli files and Makefile.local with your $EDITOR
edit:
test -n "$$EDITOR" && eval $$EDITOR Makefile.local $$(find . \( -name "_build*" -o -name "meta.ml" -o -name "$(EXCLUDE_FROM_EDITING)" -o -name "version.ml" -o -name "gui.ml" -o -name myocamlbuild.ml \) -prune -o -type f -a \( -name "*.ml" -o -name "*.mli" \) -print) &
# Create the documentation
documentation: world documentation-local
chmod +x Makefile.d/doc.sh
Makefile.d/doc.sh -pp "$(PP_OPTION)" -e "$(UNDOCUMENTED)" -i $(DIRECTORIES_TO_INCLUDE)
doc: documentation
INDEX_HTML=_build/doc/html/index.html
browse:
test -f $(INDEX_HTML) || make documentation
test -n "$$BROWSER" && $$BROWSER $(INDEX_HTML)
# Install programs and libraries:
install: install-programs install-libraries install-data install-configuration install-documentation install-local
@(echo 'Success.')
# The user is free to override this to add custom targets to install into the
# $prefix_install/share/$name installation directory:
OTHER_DATA_TO_INSTALL =
# The user is free to override this to add custom targets to install into the
# $documentationprefix/$name installation directory:
OTHER_DOCUMENTATION_TO_INSTALL =
# Install the documentation from this package (_build/doc) into $prefix_install/share/$name:
install-documentation: META CONFIGME install-documentation-local
@($(call READ_CONFIG, documentationprefix); \
$(call READ_META, name); \
directory=$$documentationprefix/$$name; \
shopt -s nullglob; \
if [ -e _build/doc ]; then \
documentationifany=`ls -d _build/doc/*`; \
else \
documentationifany=''; \
fi; \
if [ "$$documentationifany" == "" ]; then \
echo "No documentation to install: ok, no problem..."; \
else \
echo "Installing $$name documentation into $$directory ..."; \
echo "Creating $$directory ..."; \
if mkdir -p $$directory; then \
echo "The directory $$directory was created with success."; \
else \
echo "Could not create $$directory"; \
exit -1; \
fi; \
echo "Copying $$name documentation to $$directory ..."; \
for x in COPYING README $$documentationifany $(OTHER_DOCUMENTATION_TO_INSTALL); do \
if cp -af $$x $$directory; then \
echo "Installed $$x into $$directory/"; \
else \
echo "Could not write $$directory/$$x."; \
exit -1; \
fi; \
done; \
echo "Documentation installation for $$name was successful."; \
fi)
# Just a handy alias:
install-doc: install-documentation
# Install the data from this package into $prefix_install/share/$name:
install-data: META CONFIGME main install-data-local
@($(call READ_CONFIG, prefix_install); \
$(call READ_META, name); \
directory=$$prefix_install/share/$$name; \
shopt -s nullglob; \
if [ -e share ]; then \
dataifany=`ls -d share/*`; \
else \
dataifany=''; \
fi; \
if [ "$$dataifany" == "" ]; then \
echo "No data to install: ok, no problem..."; \
else \
echo "Installing $$name data into $$directory ..."; \
echo "Creating $$directory ..."; \
if mkdir -p $$directory; then \
echo "The directory $$directory was created with success."; \
else \
echo "Could not create $$directory"; \
exit -1; \
fi; \
echo "Copying $$name data to $$directory ..."; \
for x in COPYING README $$dataifany $(OTHER_DATA_TO_INSTALL); do \
if cp -af $$x $$directory; then \
echo "Installed $$x into $$directory/"; \
else \
echo "Could not write $$directory/$$x."; \
exit -1; \
fi; \
done; \
echo "Data installation for $$name was successful."; \
fi)
# Install the software configuration files, if any:
install-configuration: META CONFIGME install-configuration-local
@($(call READ_CONFIG, configurationprefix); \
$(call READ_META, name); \
if [ -e etc ]; then \
echo "Installing configuration files into $$configurationprefix/$$name..."; \
mkdir -p $$configurationprefix/$$name; \
shopt -s nullglob; \
for file in etc/*; do \
basename=`basename $$file`; \
echo "Installing $$basename into $$configurationprefix/$$name..."; \
if ! cp $$file $$configurationprefix/$$name/; then \
echo "ERROR: Could not install $$basename into $$configurationprefix/$$name"; \
exit -1; \
fi; \
done; \
else \
echo "We don't have any configuration files to install."; \
fi)
# Uninstall the software configuration files, if any:
uninstall-configuration: CONFIGME uninstall-configuration-local
@($(call READ_CONFIG, configurationprefix); \
if [ -e etc ]; then \
echo "Removing configuration files from $$configurationprefix..."; \
shopt -s nullglob; \
for file in etc/*; do \
basename=`basename $$file`; \
echo "Uninstalling $$basename from $$configurationprefix..."; \
if ! rm -f $$configurationprefix/$$basename; then \
echo "ERROR: Could not remove $$basename from $$configurationprefix"; \
exit -1; \
fi; \
done; \
else \
echo "We don't have any configuration files to remove."; \
fi)
# Remove the data of this package from $prefix_install/share/$name:
uninstall-data: META CONFIGME uninstall-data-local
@( ($(call READ_CONFIG, prefix_install); \
$(call READ_META, name); \
directory=$$prefix_install/share/$$name; \
echo "Removing $$name data from $$prefix_install/share/..."; \
shopt -s nullglob; \
if rm -rf $$directory; then \
echo "The entire directory $$directory was removed."; \
else \
echo "Could not delete $$directory"; \
exit -1; \
fi); \
echo 'Data uninstallation was successful.')
# Remove the documentation of this package from $documentationprefix/$name:
uninstall-documentation: META CONFIGME uninstall-documentation-local
@( ($(call READ_CONFIG, documentationprefix); \
$(call READ_META, name); \
directory=$$documentationprefix/$$name; \
echo "Removing $$name documentation from $$documentationprefix..."; \
shopt -s nullglob; \
if rm -rf $$directory; then \
echo "The entire directory $$directory was removed."; \
else \
echo "Could not delete $$directory"; \
exit -1; \
fi); \
echo 'Documentation uninstallation was successful.')
# The user is free to override this to add custom targets to install into the
# $prefix_install/bin installation directory; the typical use of this would be
# installing scripts.
OTHER_PROGRAMS_TO_INSTALL =
# These are programs to be installed into $prefix_install/sbin
# instead of $prefix_install/bin:
ROOT_NATIVE_PROGRAMS =
ROOT_BYTE_PROGRAMS =
# Install the programs from this package into $prefix_install/bin:
install-programs: META CONFIGME programs install-programs-local
@($(call READ_CONFIG, prefix_install); \
$(call READ_META, name); \
echo "Creating $$prefix_install/bin/..."; \
(mkdir -p $$prefix_install/bin &> /dev/null || true); \
echo "Creating $$prefix_install/sbin/..."; \
(mkdir -p $$prefix_install/sbin &> /dev/null || true); \
echo "Installing programs from $$name into $$prefix_install/bin/..."; \
shopt -s nullglob; \
for file in $(OTHER_PROGRAMS_TO_INSTALL) _build/*.byte _build/*.native; do \
basename=`basename $$file`; \
if echo " $(ROOT_NATIVE_PROGRAMS) $(ROOT_BYTE_PROGRAMS) " | grep -q " $$basename "; then \
echo "Installing "`basename $$file`" as a \"root program\" into $$prefix_install/sbin..."; \
cp -a $$file $$prefix_install/sbin/; \
chmod +x $$prefix_install/sbin/$$basename; \
else \
echo "Installing "`basename $$file`" into $$prefix_install/bin..."; \
cp -a $$file $$prefix_install/bin/; \
chmod +x $$prefix_install/bin/$$basename; \
fi; \
done) && \
echo 'Program installation was successful.'
# Remove the programs from this package from $prefix_install/bin:
uninstall-programs: META CONFIGME main uninstall-programs-local
@($(call READ_CONFIG, prefix_install); \
$(call READ_META, name); \
echo "Removing $$name programs..."; \
shopt -s nullglob; \
for file in $(OTHER_PROGRAMS_TO_INSTALL) _build/*.byte _build/*.native; do \
basename=`basename $$file`; \
if echo " $(ROOT_NATIVE_PROGRAMS) $(ROOT_BYTE_PROGRAMS) " | grep -q " $$basename "; then \
echo -e "Removing the \"root program\" $$basename from $$prefix_install/sbin..."; \
export pathname=$$prefix_install/sbin/`basename $$file`; \
else \
echo -e "Removing $$basename from $$prefix_install/bin..."; \
export pathname=$$prefix_install/bin/`basename $$file`; \
fi; \
rm -f $$pathname; \
done) && \
echo 'Program uninstallation was successful.'
# The user is free to override this to add custom targets to install into the
# library installation directory:
OTHER_LIBRARY_FILES_TO_INSTALL =
# Install the library in this package into the path chosen at configuration time:
install-libraries: libraries install-libraries-local
@($(call READ_META,name); \
if [ "$(NATIVE_LIBRARIES) $(BYTE_LIBRARIES)" == " " ]; then \
echo "There are no native libraries to install: ok, no problem..."; \
else \
(echo "Installing $$name libraries into "$(LIBRARYPREFIX)"/$$name/..."; \
(mkdir -p $(LIBRARYPREFIX)/$$name &> /dev/null || true); \
shopt -s nullglob; \
cp -f META $(OTHER_LIBRARY_FILES_TO_INSTALL) \
_build/*.cma _build/*.cmxa _build/*.a _build/*.so \
`find _build/ -name \*.cm\[iox\] | grep -v /myocamlbuild` \
`find _build/ -name \*.mli | grep -v /myocamlbuild` \
$(LIBRARYPREFIX)/$$name/) && \
if test -d $(LIBRARYPREFIX)/stublibs/; then \
find _build/ -name "dll*.so" -exec cp -f "{}" $(LIBRARYPREFIX)/stublibs/ ";" ; \
fi; \
echo 'Library installation was successful.'; \
fi)
# Uninstall programs and libraries:
uninstall: uninstall-programs uninstall-libraries uninstall-data uninstall-configuration uninstall-documentation uninstall-local
@(echo 'Success.')
# Remove the library from the installation path chosen at configuration time:
uninstall-libraries: main uninstall-libraries-local
@(($(call READ_META,name); \
echo "Uninstalling $$name libraries from "$(LIBRARYPREFIX)" ..."; \
shopt -s nullglob; \
rm -rf $(LIBRARYPREFIX)/$$name/) && \
echo 'Library uninstallation was successful.')
# Make a source tarball:
dist: clean dist-local
@($(call READ_META, name, version); \
$(call FIX_VERSION); \
echo "Making the source tarball _build/$$name-$$version.tar.gz ..."; \
if [ -d .bzr ]; then \
$(MAKE) meta.ml.released; \
$(MAKE) ChangeLog; \
fi; \
mkdir -p _build/$$name-$$version; \
cp -af * _build/$$name-$$version/ &> /dev/null; \
(tar --exclude=_build --exclude=meta.ml --exclude=.bzr -C _build -czf \
_build/$$name-$$version.tar.gz $$name-$$version/ && \
rm -rf _build/$$name-$$version)) && \
if [ -d .bzr ]; then \
rm -f meta.ml.released ChangeLog; \
fi; \
echo "Success."
# These files are included also in binary tarballs:
FILES_TO_ALWAYS_DISTRIBUTE = \
COPYING README INSTALL AUTHORS THANKS META Makefile Makefile.local CONFIGME \
REQUIREMENTS NEWS ChangeLog
# Make a binary tarball:
dist-binary: dist-binary-local main documentation
@(($(call READ_META, name, version); \
$(call FIX_VERSION); \
architecture=$$(echo `uname -o`-`uname -m` | sed 's/\//-/g'); \
directoryname=$$name-$$version--binary-only--$$architecture; \
filename=$$directoryname.tar.gz; \
echo "Making the binary tarball _build/$$filename ..."; \
$(MAKE) ChangeLog; \
mkdir -p _build/$$directoryname; \
mkdir -p _build/$$directoryname/_build; \
shopt -s nullglob; \
for x in $(FILES_TO_ALWAYS_DISTRIBUTE) share doc etc; do \
cp $$x _build/$$directoryname &> /dev/null; \
done; \
for x in $(NATIVE_PROGRAMS) $(NATIVE_LIBRARIES) $(BYTE_PROGRAMS) $(BYTE_LIBRARIES); do \
cp _build/$$x _build/$$directoryname/_build; \
done; \
for x in `find _build/ -name \*.cmi | grep -v /my$(OCAMLBUILD) | grep -v _build/$$directoryname` \
`find _build/ -name \*.mli | grep -v /my$(OCAMLBUILD) | grep -v _build/$$directoryname` \
`find _build/ -name \*.cma | grep -v /my$(OCAMLBUILD) | grep -v _build/$$directoryname` \
`find _build/ -name \*.cmxa | grep -v /my$(OCAMLBUILD) | grep -v _build/$$directoryname` \
`find _build/ -name \*.a | grep -v /my$(OCAMLBUILD) | grep -v _build/$$directoryname` \
`find _build/ -name \*.byte | grep -v /my$(OCAMLBUILD) | grep -v _build/$$directoryname` \
`find _build/ -name \*.native | grep -v /my$(OCAMLBUILD) | grep -v _build/$$directoryname` \
; do \
cp $$x _build/$$directoryname/_build; \
done; \
for x in _build/*.docdir; do \
cp -af $$x _build/$$directoryname; \
done; \
for x in main main-local install-libraries-local install-programs-local \
install-local install-data-local clean clean-local \
documentation documentation-local install-documentation-local \
ocamlbuild-stuff \
; do \
echo "This dummy file prevents make from building the \"$$x\" target." \
> _build/$$directoryname/$$x; \
done; \
(tar czf _build/$$filename -C _build $$directoryname/ && \
(rm -rf _build/$$directoryname && \
rm -f ChangeLog))) && \
echo "Success.")
# Automatically generate a nice ChangeLog from bzr's history:
ChangeLog:
@(if ! [ -d .bzr ]; then \
echo 'No ChangeLog available (bzr metadata are missing)' > $@; \
else \
bzr log --gnu-changelog > $@; \
fi)
# Remove generated stuff (the ChangeLog is only removed if we have Darcs
# metadata to re-generate it):
clean: clean-local
@(rm -rf _build; \
find -name "_build*" -prune -o -type f -name \*~ -exec rm -f {} \;; \
find -name "_build*" -prune -o -type f -name \#\*\# -exec rm -f {} \;; \
find -name "_build*" -prune -o -type f -name core -exec rm -f {} \;; \
rm -f _tags meta.ml myocamlbuild.ml; \
if [ -d .bzr ]; then \
rm -f meta.ml.released ChangeLog; \
fi; \
echo "Success.")
# Meta-help about the targets defined in this make file:
targets:
@cat Makefile Makefile.local | grep -B 1 "^[a-z0-9_-]*[:]" | \
awk '/BEGIN/ {r=""} /^[#]/ { r=substr($$0,2); next; } /^[a-z0-9_-]*[-]local[:]/ {r=""; next} /^[a-z0-9_-]*[:]/{split($$0,a,/:/); printf("%s\r\t\t\t--- %s\n",a[1],r); r=""; next} {r=""}' | sort
######################################################################
# Default implementation for '-local' targets:
# All the user-definable '-local' targets have an empty implementation
# by default:
main-local:
world-local:
data-local:
native-libraries-local:
byte-libraries-local:
libraries-local:
native-programs-local:
byte-programs-local:
programs-local:
install-local:
uninstall-local:
install-programs-local:
uninstall-programs-local:
install-libraries-local:
uninstall-libraries-local:
install-data-local:
uninstall-data-local:
install-configuration-local:
uninstall-configuration-local:
install-documentation-local:
uninstall-documentation-local:
dist-local:
dist-binary-local:
documentation-local:
clean-local:
# Let's avoid confusion between all and main: they're the same thing
# for us, and we only support main-local:
all-local:
echo 'all-local does not exist. Use main-local instead'
exit 1
#####################################################################
# Default compilation flags. The user *is* expected to override or
# extend these:
DATA =
NATIVE_LIBRARIES =
BYTE_LIBRARIES =
NATIVE_PROGRAMS =
BYTE_PROGRAMS =
COMPILE_OPTIONS = -thread
PP_OPTION =
DIRECTORIES_TO_INCLUDE =
LIBRARIES_TO_LINK =
OBJECTS_TO_LINK =
C_OBJECTS_TO_LINK =
#####################################################################
# Default rules:
# Bytecode libraries:
%.cma: ocamlbuild-stuff c-modules
@($(OCAMLBUILD) $@)
# Native libraries:
%.cmxa: ocamlbuild-stuff c-modules
@($(OCAMLBUILD) $@)
# Bytecode programs:
%.byte: ocamlbuild-stuff c-modules
@($(call BUILD_WITH_OCAMLBUILD, $@) )
# Native programs:
%.native: ocamlbuild-stuff c-modules
@($(call BUILD_WITH_OCAMLBUILD, $@) )
# Build the target $(1) using OCamlBuild. ocamlbuild-stuff is assumed
# to be already generated.
BUILD_WITH_OCAMLBUILD = \
$(OCAMLBUILD) $@; \
if [ -e $@ ]; then \
rm $@; \
echo "Success: $@ was built"; \
else \
echo "FAILURE when building $@"; \
exit -1; \
fi
#####################################################################
# Some macros, used internally and possibly by Makefile.local:
#####################################################################
# Return 'native' if we have a native compiler available, otherwise
# ''.
NATIVE = \
(if which ocamlopt.opt &> /dev/null || which ocamlopt &> /dev/null ; then \
echo 'native'; \
else \
echo ''; \
fi)
# Return 'byte' if we have a bytecode compiler available, otherwise
# ''.
BYTE = \
(if which ocamlc.opt &> /dev/null || which ocamlc &> /dev/null; then \
echo 'byte'; \
else \
echo ''; \
fi)
# Return 'native' if we have a native compiler available, otherwise
# 'byte' if we have a byte compiler; otherwise fail.
NATIVE_OR_BYTE = \
(if [ "$$( $(call NATIVE) )" == 'native' ]; then \
echo 'native'; \
elif [ "$$( $(call BYTE) )" == 'byte' ]; then \
echo 'byte'; \
else \
echo 'FATAL ERROR: could not find an ocaml compiler' ">$$native< >$$byte<"; \
exit -1; \
fi)
PROCESSOR_NO = $(shell grep "^processor.*:" /proc/cpuinfo | sort | uniq | wc -l)
# The log location with respect to the directory _build/
# So, with respect to the Makefile, the log location is _build/_build/_log
OCAMLBUILD_LOG=_build/_log
LOGFILE=_build/$(OCAMLBUILD_LOG)
# Return the proper command line for ocamlbuild, including an option
# -byte-plugin if needed:
OCAMLBUILD_COMMAND_LINE = \
(if [ $$( $(call NATIVE_OR_BYTE) ) == 'byte' ]; then \
echo 'ocamlbuild -j $(PROCESSOR_NO) -byte-plugin -verbose 2 -log $(OCAMLBUILD_LOG) $(OCAMLBUILD_OPTIONS)'; \
else \
echo 'ocamlbuild -j $(PROCESSOR_NO) -verbose 2 -log $(OCAMLBUILD_LOG) $(OCAMLBUILD_OPTIONS)'; \
fi)
# Macro extracting, via source, the value associated to some keys
# $(2),..,$(9) in a file $(1).
# Example:
# $(call SOURCE_AND_TEST,CONFIGME,prefix);
# $(call SOURCE_AND_TEST,CONFIGME,prefix,libraryprefix);
SOURCE_AND_TEST = \
if ! source $(1) &> /dev/null; then \
echo 'Evaluating $(1) failed.'; \
exit 1; \
fi; \
for i in $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10); do \
CMD="VAL=$$`echo $$i`"; eval $$CMD; \
if test -z "$$VAL"; then \
echo "FATAL: $${i} is undefined in $(1)."; \
exit 1; \
fi; \
done; \
unset CMD VAL i
# Macro extracting, via grep, the value associated to keys
# $(2),..,$(9) in a file $(1).
# Examples:
# $(call GREP_AND_TEST,META,name);
# $(call GREP_AND_TEST,META,name,version);
GREP_AND_TEST = \
for i in $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9) $(10); do \
if ! CMD=`grep "^$$i=" $(1)`; then \
echo "FATAL: $$i is undefined in $(1)."; \
exit 1; \
fi; \
eval $$CMD; \
done; \
unset CMD i
# Instance of SOURCE_AND_TEST: source the file "CONFIGME" and test
# if the given names are defined
# Example:
# $(call READ_CONFIG,prefix,libraryprefix);
#
READ_CONFIG = \
$(call SOURCE_AND_TEST,CONFIGME,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),$(9),$(10))
# Instance of GREP_AND_TEST: read the file "META" searching for a names
# for all given names.
# Example:
# $(call READ_META,name,version);
#
READ_META = \
$(call GREP_AND_TEST,META,$(1),$(2),$(3),$(4),$(5),$(6),$(7),$(8),$(9),$(10))
# If the value of the 'version' variable contains the substring 'snapshot' then
# append to its value the current date, in hacker format. 'version' must be already
# defined. No arguments, no output.
FIX_VERSION = \
if echo $$version | grep snapshot &> /dev/null; then \
version="$$version-"`date +"%Y-%m-%d"`; \
fi
# A simple macro automatically finding all the subdirectories containing ML sources,
# setting the variable 'sourcedirectories' to a string containing all such
# subdirectories, alphabetically sorted, separated by spaces, and finally echo'ing
# the value of sourcedirectories:
SOURCE_SUBDIRECTORIES = \
sourcedirectories=''; \
for d in `find \( -path "_build*" -o -name "[.]bzr" -o -name "$(EXCLUDE_FROM_SOURCE_FINDING)" \) -prune -o -type d \
| grep -v /_build\$$ | grep -v /_build/ \
| grep -v ^.$$ | sort`; do \
if ls $$d/*.ml &> /dev/null || \
ls $$d/*.mli &> /dev/null || \
ls $$d/*.mll &> /dev/null || \
ls $$d/*.mly &> /dev/null ; then \
sourcedirectories+="$$d "; \
fi; \
done; \
echo $$sourcedirectories
# Set the shell variable $(1) as the string obtained by prefixing each token
# in $(2) with the prefix $(3): for example if the shell variable
# 'sourcedirectories' is set to './A ./B' then
# $(call ADD_PREFIX_TO_EACH_WORD, includes, $$sourcedirectories, -I)
# sets the shell variable 'includes' to '-I ./A -I ./B '.
# The value of $(1) is finally echo'ed.
ADD_PREFIX_TO_EACH_WORD = \
$(call SOURCE_SUBDIRECTORIES); \
result=''; \
for element in $(2); do \
result+="$(3) $$element "; \
done; \
$(1)=$$result; \
echo $$result
# This macro expands to the project name, extracted from META. No parameters.
# Example:
# echo "$(call PROJECT_NAME) is beautiful."
PROJECT_NAME = \
$$( $(call GREP_AND_TEST,META,name); \
echo $$name )
# Automatically generate _tags and the $(OCAMLBUILD) plugin. Note that the
# target name is never created as a file. This is intentional: those
# two targets should be re-generated every time.
ocamlbuild-stuff: _tags myocamlbuild.ml meta.ml
# We automatically generate the _tags file needed by OCamlBuild.
# Every subdirectory containing sources is included. This may be more than what's needed,
# but it will always work and require no per-project customization. sed is used to remove
# the initial './' from each directory. We refer some settings implemented in our (still
# automatically generated) $(OCAMLBUILD) plugin.
_tags:
@(echo -e "# This file is automatically generated. Please don't edit it.\n" > $@; \
for directory in $$( $(call SOURCE_SUBDIRECTORIES) ); do \
directory=`echo $$directory | sed s/^.\\\\///`; \
echo "<$$directory>: include" >> $@; \
done; \
echo >> $@; \
echo "<**/*.byte>: ourincludesettings, ourbytelinksettings, ourcmodules" >> $@; \
echo "<**/*.{ml,mli,byte,native,cma,cmxa}>: ourincludesettings" >> $@; \
echo "<**/*.{native,cma,cmxa}>: ourcmodules" >> $@ ; \
echo "<**/*.cmx>: ournativecompilesettings" >> $@; \
echo "<**/*.cmo>: ourbytecompilesettings" >> $@; \
echo "<**/*.native>: ourincludesettings, ournativelinksettings" >> $@; \
echo "<**/*.{ml,mli}>: ourocamldocsettings" >> $@ ; \
echo "<**/*.{ml,mli}>: ourppsettings" >> $@)
# We automatically generate the $(OCAMLBUILD) plugin customizing the build process
# with our user-specified options, include directories, etc.:
myocamlbuild.ml:
@(echo -e "(* This file is automatically generated. Please don't edit it. *)\n" > $@; \
echo -e "open Ocamlbuild_plugin;;" >> $@; \
echo -e "open Command;;" >> $@; \
echo -e "open Arch;;" >> $@; \
echo -e "open Format;;\n" >> $@; \
echo -en "let our_pp_options = [ " >> $@; \
echo "Just for debugging: PP_OPTION is \"$(PP_OPTION)\""; \
echo "Just for debugging: OCAML_LIBRARYPREFIX is \"$(OCAML_LIBRARYPREFIX)\""; \
echo "Just for debugging: LIBRARYPREFIX is \"$(LIBRARYPREFIX)\""; \
for x in $(PP_OPTION); do \
echo -en "A \"$$x\"; " >> $@; \
done; \
echo -e "];;" >> $@; \
echo -en "let our_compile_options = [ " >> $@; \
for x in $(COMPILE_OPTIONS); do \
echo -en "A \"$$x\"; " >> $@; \
done; \
echo -e "];;" >> $@; \
echo -en "let our_byte_compile_options = [ " >> $@; \
for x in $(BYTE_COMPILE_OPTIONS); do \
echo -en "A \"$$x\"; " >> $@; \
done; \
echo -e "];;" >> $@; \
echo -en "let our_native_compile_options = [ " >> $@; \
for x in $(NATIVE_COMPILE_OPTIONS); do \
echo -en "A \"$$x\"; " >> $@; \
done; \
echo -e "];;" >> $@; \
echo -en "let our_include_options = [ " >> $@; \
echo -en "A \"-I\"; A \"$(OCAML_LIBRARYPREFIX)\"; " >> $@; \
for x in $(DIRECTORIES_TO_INCLUDE); do \
if test -d $(OCAML_LIBRARYPREFIX)/$$x; then echo -en "A \"-I\"; A \"$(OCAML_LIBRARYPREFIX)/$$x\"; " >> $@; fi; \
done; \
for x in $(DIRECTORIES_TO_INCLUDE); do \
if test -d $(LIBRARYPREFIX)/$$x; then echo -en "A \"-I\"; A \"$(LIBRARYPREFIX)/$$x\"; " >> $@; fi; \
done; \
for x in $(DIRECTORIES_TO_INCLUDE); do \
if test -d ./$$x; then echo -en "A \"-I\"; A \"../$$x\"; " >> $@; fi; \
done; \
echo -e "];;" >> $@; \
echo -en "let our_c_modules = [ " >> $@; \
for x in $(C_OBJECTS_TO_LINK); do \
echo -en "A \"$$x.o\"; " >> $@; \
done; \
echo -e "];;" >> $@; \
echo -en "let our_c_modules_options = our_c_modules @ [ " >> $@; \
for x in $(C_OBJECTS_TO_LINK_OPTIONS); do \
echo -en "A \"$$x\"; " >> $@; \
done; \
echo -e "];;" >> $@; \
echo -en "let our_byte_link_options = our_include_options @ [ " >> $@; \
for x in $(LIBRARIES_TO_LINK); do \
echo -en "A \"$$x.cma\"; " >> $@; \
done; \
for x in $(OBJECTS_TO_LINK); do \
echo -en "A \"$$x.cmo\"; " >> $@; \
done; \
echo -e "];;" >> $@; \
echo -en "let our_native_link_options = our_include_options @ [ " >> $@; \
for x in $(LIBRARIES_TO_LINK); do \
echo -en "A \"$$x.cmxa\"; " >> $@; \
done; \
for x in $(OBJECTS_TO_LINK); do \
echo -en "A \"$$x.cmx\"; " >> $@; \
done; \
echo -e "];;\n" >> $@; \
echo -e "dispatch (function After_rules ->" >> $@; \
echo -e " flag [\"ocaml\"; \"compile\"; \"ourincludesettings\"]" >> $@; \
echo -e " (S (our_compile_options @ our_include_options));" >> $@; \
echo -e " flag [\"ocaml\"; \"compile\"; \"ourbytecompilesettings\"]" >> $@; \
echo -e " (S (our_byte_compile_options));" >> $@; \
echo -e " flag [\"ocaml\"; \"compile\"; \"ournativecompilesettings\"]" >> $@; \
echo -e " (S (our_native_compile_options));" >> $@; \
echo -e " flag [\"ocaml\"; \"pp\"; \"ourppsettings\"]" >> $@; \
echo -e " (S our_pp_options);" >> $@; \
echo -e " flag [\"ocaml\"; \"link\"; \"ourbytelinksettings\"]" >> $@; \
echo -e " (S (our_compile_options @ our_byte_link_options));" >> $@; \
echo -e " flag [\"ocaml\"; \"link\"; \"ournativelinksettings\"]" >> $@; \
echo -e " (S (our_compile_options @ our_native_link_options));" >> $@; \
echo -e " flag [\"ocaml\"; \"doc\"; \"ourocamldocsettings\"]" >> $@; \
echo -e " (S ([A \"-keep-code\"; A \"-colorize-code\"] @ our_include_options));" >> $@; \
echo -e " flag [\"ocaml\"; \"link\"; \"ourcmodules\"]" >> $@; \
echo -e " (S our_c_modules_options);" >> $@; \
echo -e " | _ -> ());;" >> $@)
# Auto-generate a source file including meta information and configuration-time
# settings, which become accessible at runtime:
meta.ml: META CONFIGME
@(echo "Building $@..." && \
$(call READ_META, name, version); \
$(call READ_CONFIG, prefix, prefix_install, configurationprefix, documentationprefix localeprefix); \
echo -e "(** Automatically generated meta-informations about the project and its building. *)" > $@ && \
echo -e "(* This file is automatically generated; please don't edit it. *)\n" >> $@ && \
echo -e "let name = \"$$name\";;" >> $@ && \
echo -e "let version = \"$$version\";;" >> $@ && \
echo -e "let prefix = \"$$prefix\";;" >> $@ && \
echo -e "let prefix_install = \"$$prefix_install\";;" >> $@ && \
echo -e "let ocaml_version = \"$(OCAML_VERSION)\";;" >> $@ && \
echo -e "let ocaml_libraryprefix = \"$(OCAML_LIBRARYPREFIX)\";;" >> $@ && \
echo -e "let libraryprefix = \"$(LIBRARYPREFIX)\";;" >> $@ && \
echo -e "let configurationprefix = \"$$configurationprefix\";;" >> $@ && \
echo -e "let localeprefix = \"$$localeprefix\";;" >> $@ && \
echo -e "let documentationprefix = \"$$documentationprefix\";;" >> $@ && \
echo -e "let uname = \"$(shell uname -srvmo)\";;" >> $@ && \
echo -e "let build_date = \"$(shell date '+%Y-%m-%d %k:%M:%S %z')\";;" >> $@ && \
if [ -d .bzr ]; then \
echo -e "let revision = \"$$(bzr revno)\";;" >> $@ && \
echo -e "let source_date = \"$$(bzr info --verbose | /bin/grep 'latest revision' | cut -d: -f2- | cut -d' ' -f3-)\";;" >> $@ && \
echo -e "let source_date_utc_yy_mm_dd = \"$$(./Makefile.d/bzr_date -- -u "+%Y-%m-%d")\";;" >> $@ ; \
else \
grep "let revision" > $@ && \
grep "let source_date" > $@ ; \
grep "let source_date_utc_yy_mm_dd" > $@ ; \
fi &&\
echo "Success.")
meta.ml.released: meta.ml
if [ -d .bzr ]; then \
cp $< $@; \
fi; \
###########################################################################
# Include the project-dependant file (if any) which implements the '-local'
# targets:
-include Makefile.local
-include RPMS/Makefile
ocamlbricks-0.90+bzr456.orig/Makefile.d/ 0000755 0001750 0001750 00000000000 13175721005 016662 5 ustar lucas lucas ocamlbricks-0.90+bzr456.orig/Makefile.d/test_with.sh 0000755 0001750 0001750 00000005240 13175721005 021234 0 ustar lucas lucas #!/bin/bash
# This file is part of our reusable OCaml BRICKS library
# Copyright (C) 2013 Jean-Vincent Loddo
# Copyright (C) 2013 Université Paris 13
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
TOPLEVEL=${1:-utop}
# ---
if [[ $2 = "lablgtk2" || $2 = "widgets" ]]; then
TEST_WIDGETS='
#require "lablgtk2.auto-init";;
let window = GWindow.window ~width:400 ~height:800 ~title:"Testing" ~border_width:10 ();;
let _ = window#connect#destroy ~callback:GMain.Main.quit ;;
let vbox = GPack.vbox ~packing:window#add () ;;
let packing = vbox#pack ~padding:5 ;;
let main () = let () = window#show () in GMain.main () ;;
let t = Thread.create main () ;;
let () = Printf.printf "---
You can create and try widgets simply in this way:
(defined objects are: window vbox packing)
---
let b = GButton.button ~packing ~label:\"my text\" () ;;
---";;
'
fi
which $TOPLEVEL &>/dev/null || {
echo "Error: $0: $TOPLEVEL not found; install it please."
exit 2
}
FLATTENED_DIRECTORY=_build/_build.flattened
if [[ ! -d $FLATTENED_DIRECTORY ]]; then
mkdir -p $FLATTENED_DIRECTORY
find _build -path $FLATTENED_DIRECTORY -prune -o -type f -exec cp -fl {} $FLATTENED_DIRECTORY/ \;
fi
PREAMBLE=$(mktemp)
cat > $PREAMBLE </dev/null; then
rlwrap $CMD || CODE=$?
else
echo "Suggestion: install rlwrap for testing with readline (on a debian/ubuntu: apt-get install rlwrap)"
$CMD || CODE=$?
fi
;;
esac
rm -f $PREAMBLE
exit $CODE
ocamlbricks-0.90+bzr456.orig/Makefile.d/ocamlmklib_wrapper.sh 0000755 0001750 0001750 00000003274 13175721005 023101 0 ustar lucas lucas #!/bin/bash
# This file is part of our reusable OCaml BRICKS library
# Copyright (C) 2009 Jean-Vincent Loddo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# Usage:
# ocamlmklib_wrapper $(OTHER_LIBRARY_FILES_TO_INSTALL)"
set -e
# Check script dependencies
type ocamlobjinfo
type ocamlmklib
type awk
function usage {
echo 'Usage (in a Makefile):'
echo '$(basename $0) $(C_OBJECTS_TO_LINK)'
exit 1
}
OBJECTS=$(for i in "$@"; do echo $i.o; done)
INCLUDES=$(builtin cd _build &>/dev/null; find -type d -printf "-I %p\n")
CMO=$(ocamlobjinfo _build/ocamlbricks.cma | awk '/Unit name/{x=tolower(substr($3,1,1)); r=substr($3,2); printf("%s%s.cmo\n",x,r);}')
CMX=$(ocamlobjinfo _build/ocamlbricks.cma | awk '/Unit name/{x=tolower(substr($3,1,1)); r=substr($3,2); printf("%s%s.cmx\n",x,r);}')
cd _build/
echo "Rebuilding library with ocamlmklib..."
echo '---'; set -x; ocamlc -a -linkall -dllib -locamlbricks_stubs -o ocamlbricks.cma $INCLUDES $CMO; set +x
echo '---'; set -x; ocamlopt -a -linkall -cclib -locamlbricks_stubs -o ocamlbricks.cmxa $INCLUDES $CMX; set +x;
ls -l ocamlbricks.cm{,x}a
ocamlbricks-0.90+bzr456.orig/Makefile.d/bzr_date 0000755 0001750 0001750 00000003414 13175721005 020404 0 ustar lucas lucas #!/bin/bash
# This file is part of marionnet
# Copyright (C) 2010 Jean-Vincent Loddo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# Parsing command line arguments
FORMAT='r:'
function parse_cmdline {
unset ARGS
while [[ $# -gt 0 ]]; do
OPTIND=1
while getopts ":h$FORMAT" flag; do
[[ ! $flag = '?' ]] || { echo "*** Illegal option -$OPTARG."; exit 1; }
eval "option_${flag}=$OPTIND"
eval "option_${flag}_arg='$OPTARG'"
done
for ((index=1; index