diff -Nru ocaml-dtools-0.4.1/debian/libdtools-ocaml-dev.doc-base ocaml-dtools-0.4.2/debian/libdtools-ocaml-dev.doc-base
--- ocaml-dtools-0.4.1/debian/libdtools-ocaml-dev.doc-base 2018-05-04 18:09:41.000000000 +0000
+++ ocaml-dtools-0.4.2/debian/libdtools-ocaml-dev.doc-base 1970-01-01 00:00:00.000000000 +0000
@@ -1,9 +0,0 @@
-Document: libdtools-ocaml-dev
-Title: OCaml daemon tools API documentation
-Author: Stéphane Gimenez
-Abstract: Documentation of the OCaml daemon tools API
-Section: Programming/OCaml
-
-Format: HTML
-Index: /usr/share/doc/libdtools-ocaml-dev/html/index.html
-Files: /usr/share/doc/libdtools-ocaml-dev/html/*
diff -Nru ocaml-dtools-0.4.1/debian/libdtools-ocaml-dev.docs ocaml-dtools-0.4.2/debian/libdtools-ocaml-dev.docs
--- ocaml-dtools-0.4.1/debian/libdtools-ocaml-dev.docs 2018-05-04 18:09:41.000000000 +0000
+++ ocaml-dtools-0.4.2/debian/libdtools-ocaml-dev.docs 2020-05-25 09:43:09.000000000 +0000
@@ -1,2 +1,2 @@
-README
-doc/html
+usr/doc/dtools/README.md
+usr/doc/dtools/CHANGES
diff -Nru ocaml-dtools-0.4.1/debian/libdtools-ocaml-dev.install.in ocaml-dtools-0.4.2/debian/libdtools-ocaml-dev.install.in
--- ocaml-dtools-0.4.1/debian/libdtools-ocaml-dev.install.in 2018-08-27 07:56:43.000000000 +0000
+++ ocaml-dtools-0.4.2/debian/libdtools-ocaml-dev.install.in 2020-05-25 09:42:15.000000000 +0000
@@ -1,2 +1 @@
-src/META src/*.cm* src/*.mli src/dtools_syslog.ml @OCamlStdlibDir@/dtools
-OPT: src/*.a @OCamlStdlibDir@/dtools
+@OCamlStdlibDir@/dtools/*
diff -Nru ocaml-dtools-0.4.1/debian/rules ocaml-dtools-0.4.2/debian/rules
--- ocaml-dtools-0.4.1/debian/rules 2018-05-04 18:09:41.000000000 +0000
+++ ocaml-dtools-0.4.2/debian/rules 2020-05-25 09:32:46.000000000 +0000
@@ -1,12 +1,22 @@
#!/usr/bin/make -f
-include /usr/share/cdbs/1/rules/debhelper.mk
-include /usr/share/cdbs/1/class/autotools.mk
-include /usr/share/cdbs/1/rules/ocaml.mk
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+DPKG_EXPORT_BUILDFLAGS = 1
+include /usr/share/dpkg/buildflags.mk
+include /usr/share/ocaml/ocamlvars.mk
-DESTDIR = $(CURDIR)/debian/tmp/$(OCAML_STDLIB_DIR)
-DEB_MAKE_INSTALL_TARGET := install OCAMLFIND_DESTDIR=$(DESTDIR) OCAMLFIND_LDCONF=ignore
+DESTDIR := $(CURDIR)/debian/tmp
+export OCAMLFIND_DESTDIR=$(DESTDIR)$(OCAML_STDLIB_DIR)
+export PKG_CONFIG_PATH=/usr/lib/$(DEB_BUILD_ARCH)/pkgconfig
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all
-build/libdtools-ocaml-dev::
- mkdir -p $(DESTDIR)
- make doc
+%:
+ dh $@ --with ocaml
+
+override_dh_auto_build:
+ dune build @install --verbose
+
+override_dh_auto_install:
+ mkdir -p $(DESTDIR)/$(OCAML_STDLIB_DIR)
+ dune install --prefix=$(DESTDIR)/usr --libdir=$(OCAMLFIND_DESTDIR) --verbose
+ dh_install
diff -Nru ocaml-dtools-0.4.1/debian/watch ocaml-dtools-0.4.2/debian/watch
--- ocaml-dtools-0.4.1/debian/watch 2018-05-04 18:09:41.000000000 +0000
+++ ocaml-dtools-0.4.2/debian/watch 2020-05-25 09:29:32.000000000 +0000
@@ -1,3 +1,3 @@
version=4
-opts=filenamemangle=s/.+\/(\d\S+)\/// \
- https://github.com/savonet/ocaml-dtools/releases .*download/\d\S+/ocaml-dtools-(\d\S+).tar.gz
+opts=filenamemangle=s/.+\/v?(\d\S+)\.tar\.gz/ocaml-dtools-$1\.tar\.gz/ \
+ https://github.com/savonet/ocaml-dtools/tags .*/v?(\d\S+)\.tar\.gz
diff -Nru ocaml-dtools-0.4.1/doc/html/Dtools.Conf.html ocaml-dtools-0.4.2/doc/html/Dtools.Conf.html
--- ocaml-dtools-0.4.1/doc/html/Dtools.Conf.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/Dtools.Conf.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,330 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-Dtools.Conf
-
-
-
-
-
-module Conf: sig
.. end
-Configuration management module.
-
-
-
-type
link = string
-
-Type for links between keys
-
-
-
-type
path = link list
-
-Type for paths between keys
-
-
-
-type
ut = <
-
-
-
-
- : string list
;
-
-
-
-
-
-
-descr : string
;
-
-
-
-
-
-
-kind : string option
;
-
-
-
-
-
-
-path : path -> ut
;
-
-
-
-
-
-
-plug : link -> ut -> unit
;
-
-
-
-
-
-
-routes : ut -> path list
;
-
-
-
-
-
-
-subs : link list
;
-
-
-
-
-
-
-ut : ut
;
-
-
->
-
-
-
-Type for untyped keys (or keys with unknown type)
-kind
: a string describing the type of this key
-descr
: a key description/title
-comments
: some comments on the key purposes
-plug
: a way to plug subkeys
-subs
: the list of link names to subkeys
-path
: a way to access subkeys
-routes
: a way to find paths to an other key
-
-
-
-type 'a
t = <
-
-
-
-
-alias : ?comments:string list -> ?descr:string -> (ut -> unit) -> 'a t
;
-
-
-
-
-
-
- : string list
;
-
-
-
-
-
-
-descr : string
;
-
-
-
-
-
-
-get : 'a
;
-
-
-
-
-
-
-get_d : 'a option
;
-
-
-
-
-
-
-kind : string option
;
-
-
-
-
-
-
-on_change : ('a -> unit) -> unit
;
-
-
-
-
-
-
-path : path -> ut
;
-
-
-
-
-
-
-plug : link -> ut -> unit
;
-
-
-
-
-
-
-routes : ut -> path list
;
-
-
-
-
-
-
-set : 'a -> unit
;
-
-
-
-
-
-
-set_d : 'a option -> unit
;
-
-
-
-
-
-
-subs : link list
;
-
-
-
-
-
-
-ut : ut
;
-
-
->
-
-
-
-Type for 'a keys
-ut
: cast to un untyped key
-set_d
: set the default value associated to the key
-get_d
: get the default value associated to the key
-set
: set the key value according to a user demmand
-get
: retrieve the resulting key value
-
-
-
-type
links = (link * ut ) list
-
-A set of connections to others keys
-
-
-
-exception Undefined of ut
-
-Raised on access to an undefined key (without default value)
-
-
-exception Invalid of string
-
-Raised when an invalid link has been specified
-
-
-exception Unbound of ut * string
-
-Raised when a specified link does not exist
-
-
-exception Bound of ut * string
-
-Raised when a specified link already exist
-
-
-exception Mismatch of ut
-
-Raised on access to a key with a mismatching type
-
-
-exception Cyclic of ut * ut
-
-Raised on cyclic plug
-
-
-exception Wrong_Conf of string * string
-
-Raised when bad configuration assignations are encountered
-
-
-exception File_Wrong_Conf of string * int * string
-
-Raised when bad configuration assignations are encountered
- inside configuration files
-
-
-type 'a
builder = ?d:'a -> ?p:(ut -> unit) -> ?l:links -> ?comments:string list -> string -> 'a t
-
-Receipt to build a 'a key
-
-
-
-val unit : unit builder
-val int : int builder
-val float : float builder
-val bool : bool builder
-val string : string builder
-val list : string list builder
-Some key builders
-
-
-val void : ?p:(ut -> unit) -> ?l:links -> ?comments:string list -> string -> ut
-A structural key builder
-
-
-val as_unit : ut -> unit t
-val as_int : ut -> int t
-val as_float : ut -> float t
-val as_bool : ut -> bool t
-val as_string : ut -> string t
-val as_list : ut -> string list t
-Casts to specificaly typed keys.
- Raises Mismatch
on mismatching cast.
-
-
-val path_of_string : string -> path
-Convert a dot separated string to a path
-
-
-val string_of_path : path -> string
-Convert a path to a dot separated string
-
-
-val descr : ?prefix:path -> ut -> string
-Generate a description table of a (sub)key
-
-
-val dump : ?prefix:path -> ut -> string
-Dump the configuration table for a (sub)key
-
-
-val conf_set : ut -> string -> unit
-Add a value to the configuration keys, according to the given
- correctly formated string: "type key :value"
- Raises Wrong_Conf
in badly formated cases.
-
-
-val conf_file : ut -> string -> unit
-Read configuration values from the file associated with the given
- filename.
- Raises File_Wrong_Conf
with filename line and and error message
- in case of a bad configuration file.
-
-
-val args : ut -> (string list * Arg.spec * string) list
-A set of command line options to be used with the Arg module.
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/Dtools.html ocaml-dtools-0.4.2/doc/html/Dtools.html
--- ocaml-dtools-0.4.1/doc/html/Dtools.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/Dtools.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-Dtools
-
-
-
-
-
-module Dtools: sig
.. end
-ocaml-dtools.
-Author(s): Stephane Gimenez
-
-
-
-module Conf : sig
.. end
-Configuration management module.
-
-
-module Init : sig
.. end
-Initialisation management module.
-
-
-module Log : sig
.. end
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/Dtools.Init.html ocaml-dtools-0.4.2/doc/html/Dtools.Init.html
--- ocaml-dtools-0.4.1/doc/html/Dtools.Init.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/Dtools.Init.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,89 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-Dtools.Init
-
-
-
-
-
-module Init: sig
.. end
-Initialisation management module.
- Allow to define procedures that must be executed at start up, and
- procedures that are to be executed at exit to have a clean quit.
-
-
-
-type
t
-
-
-val start : t
-Root start atom
-
-
-val stop : t
-Root stop atom
-
-
-val make : ?name:string -> ?depends:t list -> ?triggers:t list -> ?after:t list -> ?before:t list -> (unit -> unit) -> t
-Define a init atom associated with the given (unit -> unit)
- procedure, which eventualy depends on others atoms (these atoms
- will be executed before the one currently defined) an triggers
- other atoms (these atoms will be executed after the one currently
- defined). after
and before
allow to register the currently
- defined atom in the depend and triggers lists of other atoms.
-
-
-val at_start : ?name:string -> ?depends:t list -> ?triggers:t list -> ?after:t list -> ?before:t list -> (unit -> unit) -> t
-Same as make
plus a shortcut for "after Init.start".
-
-
-val at_stop : ?name:string -> ?depends:t list -> ?triggers:t list -> ?after:t list -> ?before:t list -> (unit -> unit) -> t
-Same as make
plus a shortcut for "before Init.stop".
-
-
-val exec : t -> unit
-Launch the execution of a given init atom.
-
-
-exception Root_prohibited of [ `Both | `Group | `User ]
-
-val init : ?prohibit_root:bool -> (unit -> unit) -> unit
-This fuction must be used to launch the main procedure of the
- program. It first execute the registered start atoms, then call
- the main procedure, then execute the registered stop atoms.
- Exceptions raised by the main procedure are catched, in order to
- close properly even in such cases. Exceptions are raised again
- after cleaning.
- When invoqued with ~prohibit_root:true
, it checks for root access
- rights (euid, egid) and exit in this case.
-
-
-exception StartError of exn
-
-exception StopError of exn
-
-val conf : Dtools.Conf.ut
-val conf_daemon : bool Dtools.Conf.t
-val conf_daemon_pidfile : bool Dtools.Conf.t
-val conf_daemon_pidfile_path : string Dtools.Conf.t
-val conf_concurrent : bool Dtools.Conf.t
-val conf_trace : bool Dtools.Conf.t
-val conf_catch_exn : bool Dtools.Conf.t
-val args : (string list * Arg.spec * string) list
-A set of command line options to be used with the Arg module.
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/Dtools.Log.html ocaml-dtools-0.4.2/doc/html/Dtools.Log.html
--- ocaml-dtools-0.4.1/doc/html/Dtools.Log.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/Dtools.Log.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,95 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-Dtools.Log
-
-
-
-
-
-module Log: sig
.. end
-
-type
t = <
-
-
-
-
-active : int -> bool
;
-
-
-
-
-
-
-f : 'a. int -> ('a, unit, string, unit) Pervasives.format4 -> 'a
;
-
-
->
-
-
-Type for loggers.
-
-
-
-type
custom_log = {
-
-
-
-
-timestamp : bool
;
-
-
-
-
-
-
-exec : string -> unit
;
-
-
-}
-
-
-
-val add_custom_log : string -> custom_log -> unit
-Add a custom logging functions.
-
-
-val rm_custom_log : string -> unit
-Remove a custom logging functions.
-
-
-val make : Dtools.Conf.path -> t
-Make a logger labeled according to the given path.
-
-
-val start : Dtools.Init.t
-An atom that starts the logging.
-
-
-val stop : Dtools.Init.t
-An atom that stops the logging.
-
-
-val conf : Dtools.Conf.ut
-val conf_level : int Dtools.Conf.t
-val conf_unix_timestamps : bool Dtools.Conf.t
-val conf_stdout : bool Dtools.Conf.t
-val conf_file : bool Dtools.Conf.t
-val conf_file_path : string Dtools.Conf.t
-val conf_file_append : bool Dtools.Conf.t
-val conf_file_perms : int Dtools.Conf.t
-val args : (string list * Arg.spec * string) list
-A set of command line options to be used with the Arg module.
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_attributes.html ocaml-dtools-0.4.2/doc/html/index_attributes.html
--- ocaml-dtools-0.4.1/doc/html/index_attributes.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_attributes.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of class attributes
-
-
-
-Index of class attributes
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_classes.html ocaml-dtools-0.4.2/doc/html/index_classes.html
--- ocaml-dtools-0.4.1/doc/html/index_classes.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_classes.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of classes
-
-
-
-Index of classes
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_class_types.html ocaml-dtools-0.4.2/doc/html/index_class_types.html
--- ocaml-dtools-0.4.1/doc/html/index_class_types.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_class_types.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of class types
-
-
-
-Index of class types
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_exceptions.html ocaml-dtools-0.4.2/doc/html/index_exceptions.html
--- ocaml-dtools-0.4.1/doc/html/index_exceptions.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_exceptions.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,75 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of exceptions
-
-
-
-Index of exceptions
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_extensions.html ocaml-dtools-0.4.2/doc/html/index_extensions.html
--- ocaml-dtools-0.4.1/doc/html/index_extensions.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_extensions.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of extensions
-
-
-
-Index of extensions
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index.html ocaml-dtools-0.4.2/doc/html/index.html
--- ocaml-dtools-0.4.1/doc/html/index.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_methods.html ocaml-dtools-0.4.2/doc/html/index_methods.html
--- ocaml-dtools-0.4.1/doc/html/index_methods.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_methods.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of class methods
-
-
-
-Index of class methods
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_modules.html ocaml-dtools-0.4.2/doc/html/index_modules.html
--- ocaml-dtools-0.4.1/doc/html/index_modules.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_modules.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of modules
-
-
-
-Index of modules
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_module_types.html ocaml-dtools-0.4.2/doc/html/index_module_types.html
--- ocaml-dtools-0.4.1/doc/html/index_module_types.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_module_types.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of module types
-
-
-
-Index of module types
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_types.html ocaml-dtools-0.4.2/doc/html/index_types.html
--- ocaml-dtools-0.4.1/doc/html/index_types.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_types.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of types
-
-
-
-Index of types
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/index_values.html ocaml-dtools-0.4.2/doc/html/index_values.html
--- ocaml-dtools-0.4.1/doc/html/index_values.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/index_values.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,211 +0,0 @@
-
-
-
-
-
-
-
-
-
-Index of values
-
-
-
-Index of values
-
-
-
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/style.css ocaml-dtools-0.4.2/doc/html/style.css
--- ocaml-dtools-0.4.1/doc/html/style.css 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/style.css 1970-01-01 00:00:00.000000000 +0000
@@ -1,41 +0,0 @@
-.keyword { font-weight : bold ; color : Red }
-.keywordsign { color : #C04600 }
-.superscript { font-size : 4 }
-.subscript { font-size : 4 }
-.comment { color : Green }
-.constructor { color : Blue }
-.type { color : #5C6585 }
-.string { color : Maroon }
-.warning { color : Red ; font-weight : bold }
-.info { margin-left : 3em; margin-right: 3em }
-.param_info { margin-top: 4px; margin-left : 3em; margin-right : 3em }
-.code { color : #465F91 ; }
-.typetable { border-style : hidden }
-.paramstable { border-style : hidden ; padding: 5pt 5pt}
-tr { background-color : White }
-td.typefieldcomment { background-color : #FFFFFF ; font-size: smaller ;}
-div.sig_block {margin-left: 2em}
-*:target { background: yellow; }
-body {font: 13px sans-serif; color: black; text-align: left; padding: 5px; margin: 0}
-h1 { font-size : 20pt ; text-align: center; }
-h2 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90BDFF ;padding: 2px; }
-h3 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90DDFF ;padding: 2px; }
-h4 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90EDFF ;padding: 2px; }
-h5 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90FDFF ;padding: 2px; }
-h6 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90BDFF ; padding: 2px; }
-div.h7 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #E0FFFF ; padding: 2px; }
-div.h8 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #F0FFFF ; padding: 2px; }
-div.h9 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #FFFFFF ; padding: 2px; }
-a {color: #416DFF; text-decoration: none}
-a:hover {background-color: #ddd; text-decoration: underline}
-pre { margin-bottom: 4px; font-family: monospace; }
-pre.verbatim, pre.codepre { }
-.indextable {border: 1px #ddd solid; border-collapse: collapse}
-.indextable td, .indextable th {border: 1px #ddd solid; min-width: 80px}
-.indextable td.module {background-color: #eee ; padding-left: 2px; padding-right: 2px}
-.indextable td.module a {color: 4E6272; text-decoration: none; display: block; width: 100%}
-.indextable td.module a:hover {text-decoration: underline; background-color: transparent}
-.deprecated {color: #888; font-style: italic}
-.indextable tr td div.info { margin-left: 2px; margin-right: 2px }
-ul.indexlist { margin-left: 0; padding-left: 0;}
-ul.indexlist li { list-style-type: none ; margin-left: 0; padding-left: 0; }
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/type_Dtools.Conf.html ocaml-dtools-0.4.2/doc/html/type_Dtools.Conf.html
--- ocaml-dtools-0.4.1/doc/html/type_Dtools.Conf.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/type_Dtools.Conf.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,67 +0,0 @@
-
-
-
-
-
-
-
-
-Dtools.Conf
-
-
-sig
- type link = string
- type path = Dtools .Conf .link list
- type ut =
- < comments : string list; descr : string; kind : string option;
- path : Dtools .Conf .path -> Dtools .Conf .ut;
- plug : Dtools .Conf .link -> Dtools .Conf .ut -> unit;
- routes : Dtools .Conf .ut -> Dtools .Conf .path list;
- subs : Dtools .Conf .link list; ut : Dtools .Conf .ut >
- type ' a t =
- < alias : ?comments:string list ->
- ?descr:string -> (Dtools .Conf .ut -> unit) -> ' a Dtools .Conf .t;
- comments : string list; descr : string; get : ' a; get_d : ' a option;
- kind : string option; on_change : (' a -> unit) -> unit;
- path : Dtools .Conf .path -> Dtools .Conf .ut;
- plug : Dtools .Conf .link -> Dtools .Conf .ut -> unit;
- routes : Dtools .Conf .ut -> Dtools .Conf .path list; set : ' a -> unit;
- set_d : ' a option -> unit; subs : Dtools .Conf .link list;
- ut : Dtools .Conf .ut >
- type links = (Dtools .Conf .link * Dtools .Conf .ut) list
- exception Undefined of Dtools .Conf .ut
- exception Invalid of string
- exception Unbound of Dtools .Conf .ut * string
- exception Bound of Dtools .Conf .ut * string
- exception Mismatch of Dtools .Conf .ut
- exception Cyclic of Dtools .Conf .ut * Dtools .Conf .ut
- exception Wrong_Conf of string * string
- exception File_Wrong_Conf of string * int * string
- type ' a builder =
- ?d:' a ->
- ?p:(Dtools .Conf .ut -> unit) ->
- ?l:Dtools .Conf .links ->
- ?comments:string list -> string -> ' a Dtools .Conf .t
- val unit : unit Dtools .Conf .builder
- val int : int Dtools .Conf .builder
- val float : float Dtools .Conf .builder
- val bool : bool Dtools .Conf .builder
- val string : string Dtools .Conf .builder
- val list : string list Dtools .Conf .builder
- val void :
- ?p:(Dtools .Conf .ut -> unit) ->
- ?l:Dtools .Conf .links -> ?comments:string list -> string -> Dtools .Conf .ut
- val as_unit : Dtools .Conf .ut -> unit Dtools .Conf .t
- val as_int : Dtools .Conf .ut -> int Dtools .Conf .t
- val as_float : Dtools .Conf .ut -> float Dtools .Conf .t
- val as_bool : Dtools .Conf .ut -> bool Dtools .Conf .t
- val as_string : Dtools .Conf .ut -> string Dtools .Conf .t
- val as_list : Dtools .Conf .ut -> string list Dtools .Conf .t
- val path_of_string : string -> Dtools .Conf .path
- val string_of_path : Dtools .Conf .path -> string
- val descr : ?prefix:Dtools .Conf .path -> Dtools .Conf .ut -> string
- val dump : ?prefix:Dtools .Conf .path -> Dtools .Conf .ut -> string
- val conf_set : Dtools .Conf .ut -> string -> unit
- val conf_file : Dtools .Conf .ut -> string -> unit
- val args : Dtools .Conf .ut -> (string list * Arg .spec * string) list
-end
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/type_Dtools.html ocaml-dtools-0.4.2/doc/html/type_Dtools.html
--- ocaml-dtools-0.4.1/doc/html/type_Dtools.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/type_Dtools.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,131 +0,0 @@
-
-
-
-
-
-
-
-
-Dtools
-
-
-sig
- module Conf :
- sig
- type link = string
- type path = Dtools .Conf .link list
- type ut =
- < comments : string list; descr : string; kind : string option;
- path : Dtools .Conf .path -> Dtools .Conf .ut;
- plug : Dtools .Conf .link -> Dtools .Conf .ut -> unit;
- routes : Dtools .Conf .ut -> Dtools .Conf .path list;
- subs : Dtools .Conf .link list; ut : Dtools .Conf .ut >
- type ' a t =
- < alias : ?comments:string list ->
- ?descr:string ->
- (Dtools .Conf .ut -> unit) -> ' a Dtools .Conf .t;
- comments : string list; descr : string; get : ' a;
- get_d : ' a option; kind : string option;
- on_change : (' a -> unit) -> unit;
- path : Dtools .Conf .path -> Dtools .Conf .ut;
- plug : Dtools .Conf .link -> Dtools .Conf .ut -> unit;
- routes : Dtools .Conf .ut -> Dtools .Conf .path list;
- set : ' a -> unit; set_d : ' a option -> unit;
- subs : Dtools .Conf .link list; ut : Dtools .Conf .ut >
- type links = (Dtools .Conf .link * Dtools .Conf .ut) list
- exception Undefined of Dtools .Conf .ut
- exception Invalid of string
- exception Unbound of Dtools .Conf .ut * string
- exception Bound of Dtools .Conf .ut * string
- exception Mismatch of Dtools .Conf .ut
- exception Cyclic of Dtools .Conf .ut * Dtools .Conf .ut
- exception Wrong_Conf of string * string
- exception File_Wrong_Conf of string * int * string
- type ' a builder =
- ?d:' a ->
- ?p:(Dtools .Conf .ut -> unit) ->
- ?l:Dtools .Conf .links ->
- ?comments:string list -> string -> ' a Dtools .Conf .t
- val unit : unit Dtools .Conf .builder
- val int : int Dtools .Conf .builder
- val float : float Dtools .Conf .builder
- val bool : bool Dtools .Conf .builder
- val string : string Dtools .Conf .builder
- val list : string list Dtools .Conf .builder
- val void :
- ?p:(Dtools .Conf .ut -> unit) ->
- ?l:Dtools .Conf .links ->
- ?comments:string list -> string -> Dtools .Conf .ut
- val as_unit : Dtools .Conf .ut -> unit Dtools .Conf .t
- val as_int : Dtools .Conf .ut -> int Dtools .Conf .t
- val as_float : Dtools .Conf .ut -> float Dtools .Conf .t
- val as_bool : Dtools .Conf .ut -> bool Dtools .Conf .t
- val as_string : Dtools .Conf .ut -> string Dtools .Conf .t
- val as_list : Dtools .Conf .ut -> string list Dtools .Conf .t
- val path_of_string : string -> Dtools .Conf .path
- val string_of_path : Dtools .Conf .path -> string
- val descr : ?prefix:Dtools .Conf .path -> Dtools .Conf .ut -> string
- val dump : ?prefix:Dtools .Conf .path -> Dtools .Conf .ut -> string
- val conf_set : Dtools .Conf .ut -> string -> unit
- val conf_file : Dtools .Conf .ut -> string -> unit
- val args : Dtools .Conf .ut -> (string list * Arg .spec * string) list
- end
- module Init :
- sig
- type t
- val start : Dtools .Init .t
- val stop : Dtools .Init .t
- val make :
- ?name:string ->
- ?depends:Dtools .Init .t list ->
- ?triggers:Dtools .Init .t list ->
- ?after:Dtools .Init .t list ->
- ?before:Dtools .Init .t list -> (unit -> unit) -> Dtools .Init .t
- val at_start :
- ?name:string ->
- ?depends:Dtools .Init .t list ->
- ?triggers:Dtools .Init .t list ->
- ?after:Dtools .Init .t list ->
- ?before:Dtools .Init .t list -> (unit -> unit) -> Dtools .Init .t
- val at_stop :
- ?name:string ->
- ?depends:Dtools .Init .t list ->
- ?triggers:Dtools .Init .t list ->
- ?after:Dtools .Init .t list ->
- ?before:Dtools .Init .t list -> (unit -> unit) -> Dtools .Init .t
- val exec : Dtools .Init .t -> unit
- exception Root_prohibited of [ ` Both | ` Group | ` User ]
- val init : ?prohibit_root:bool -> (unit -> unit) -> unit
- exception StartError of exn
- exception StopError of exn
- val conf : Dtools .Conf .ut
- val conf_daemon : bool Dtools .Conf .t
- val conf_daemon_pidfile : bool Dtools .Conf .t
- val conf_daemon_pidfile_path : string Dtools .Conf .t
- val conf_concurrent : bool Dtools .Conf .t
- val conf_trace : bool Dtools .Conf .t
- val conf_catch_exn : bool Dtools .Conf .t
- val args : (string list * Arg .spec * string) list
- end
- module Log :
- sig
- type t =
- < active : int -> bool;
- f : ' a. int -> (' a, unit, string, unit) Pervasives .format4 -> ' a >
- type custom_log = { timestamp : bool; exec : string -> unit; }
- val add_custom_log : string -> Dtools .Log .custom_log -> unit
- val rm_custom_log : string -> unit
- val make : Dtools .Conf .path -> Dtools .Log .t
- val start : Dtools .Init .t
- val stop : Dtools .Init .t
- val conf : Dtools .Conf .ut
- val conf_level : int Dtools .Conf .t
- val conf_unix_timestamps : bool Dtools .Conf .t
- val conf_stdout : bool Dtools .Conf .t
- val conf_file : bool Dtools .Conf .t
- val conf_file_path : string Dtools .Conf .t
- val conf_file_append : bool Dtools .Conf .t
- val conf_file_perms : int Dtools .Conf .t
- val args : (string list * Arg .spec * string) list
- end
-end
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/type_Dtools.Init.html ocaml-dtools-0.4.2/doc/html/type_Dtools.Init.html
--- ocaml-dtools-0.4.1/doc/html/type_Dtools.Init.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/type_Dtools.Init.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-Dtools.Init
-
-
-sig
- type t
- val start : Dtools .Init .t
- val stop : Dtools .Init .t
- val make :
- ?name:string ->
- ?depends:Dtools .Init .t list ->
- ?triggers:Dtools .Init .t list ->
- ?after:Dtools .Init .t list ->
- ?before:Dtools .Init .t list -> (unit -> unit) -> Dtools .Init .t
- val at_start :
- ?name:string ->
- ?depends:Dtools .Init .t list ->
- ?triggers:Dtools .Init .t list ->
- ?after:Dtools .Init .t list ->
- ?before:Dtools .Init .t list -> (unit -> unit) -> Dtools .Init .t
- val at_stop :
- ?name:string ->
- ?depends:Dtools .Init .t list ->
- ?triggers:Dtools .Init .t list ->
- ?after:Dtools .Init .t list ->
- ?before:Dtools .Init .t list -> (unit -> unit) -> Dtools .Init .t
- val exec : Dtools .Init .t -> unit
- exception Root_prohibited of [ ` Both | ` Group | ` User ]
- val init : ?prohibit_root:bool -> (unit -> unit) -> unit
- exception StartError of exn
- exception StopError of exn
- val conf : Dtools .Conf .ut
- val conf_daemon : bool Dtools .Conf .t
- val conf_daemon_pidfile : bool Dtools .Conf .t
- val conf_daemon_pidfile_path : string Dtools .Conf .t
- val conf_concurrent : bool Dtools .Conf .t
- val conf_trace : bool Dtools .Conf .t
- val conf_catch_exn : bool Dtools .Conf .t
- val args : (string list * Arg .spec * string) list
-end
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/doc/html/type_Dtools.Log.html ocaml-dtools-0.4.2/doc/html/type_Dtools.Log.html
--- ocaml-dtools-0.4.1/doc/html/type_Dtools.Log.html 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/doc/html/type_Dtools.Log.html 1970-01-01 00:00:00.000000000 +0000
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-Dtools.Log
-
-
-sig
- type t =
- < active : int -> bool;
- f : ' a. int -> (' a, unit, string, unit) Pervasives .format4 -> ' a >
- type custom_log = { timestamp : bool; exec : string -> unit; }
- val add_custom_log : string -> Dtools .Log .custom_log -> unit
- val rm_custom_log : string -> unit
- val make : Dtools .Conf .path -> Dtools .Log .t
- val start : Dtools .Init .t
- val stop : Dtools .Init .t
- val conf : Dtools .Conf .ut
- val conf_level : int Dtools .Conf .t
- val conf_unix_timestamps : bool Dtools .Conf .t
- val conf_stdout : bool Dtools .Conf .t
- val conf_file : bool Dtools .Conf .t
- val conf_file_path : string Dtools .Conf .t
- val conf_file_append : bool Dtools .Conf .t
- val conf_file_perms : int Dtools .Conf .t
- val args : (string list * Arg .spec * string) list
-end
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/dtools.opam ocaml-dtools-0.4.2/dtools.opam
--- ocaml-dtools-0.4.1/dtools.opam 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/dtools.opam 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1,29 @@
+# This file is generated by dune, edit dune-project instead
+opam-version: "2.0"
+version: "0.4.2"
+synopsis: "BLibrary providing various helper functions to make daemons"
+maintainer: ["Romain Beauxis "]
+authors: ["The Savonet Team "]
+license: "GPL"
+homepage: "https://github.com/savonet/ocaml-dtools"
+bug-reports: "https://github.com/savonet/ocaml-dtools/issues"
+depends: [
+ "ocaml" {>= "4.05.0"}
+ "dune" {>= "2.0"}
+]
+depopts: ["syslog"]
+build: [
+ ["dune" "subst"] {pinned}
+ [
+ "dune"
+ "build"
+ "-p"
+ name
+ "-j"
+ jobs
+ "@install"
+ "@runtest" {with-test}
+ "@doc" {with-doc}
+ ]
+]
+dev-repo: "git+https://github.com/savonet/ocaml-dtools.git"
diff -Nru ocaml-dtools-0.4.1/dune-project ocaml-dtools-0.4.2/dune-project
--- ocaml-dtools-0.4.1/dune-project 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/dune-project 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1,18 @@
+(lang dune 2.0)
+
+(name dtools)
+(version 0.4.2)
+(source (github savonet/ocaml-dtools))
+(license GPL)
+(authors "The Savonet Team ")
+(maintainers "Romain Beauxis ")
+
+(generate_opam_files true)
+
+(package
+ (name dtools)
+ (synopsis "Library providing various helper functions to make daemons")
+ (depends
+ (ocaml (>= 4.05.0))
+ (dune (>= 2.0)))
+ (depopts syslog))
diff -Nru ocaml-dtools-0.4.1/.github/workflows/ci.yml ocaml-dtools-0.4.2/.github/workflows/ci.yml
--- ocaml-dtools-0.4.1/.github/workflows/ci.yml 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/.github/workflows/ci.yml 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1,19 @@
+name: CI
+
+on: [push]
+
+jobs:
+ build:
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ steps:
+ - uses: actions/checkout@v1
+ - name: Setup OCaml
+ uses: avsm/setup-ocaml@v1.0
+ - name: Install syslog
+ run: opam install -y syslog
+ if: matrix.os != 'windows-latest'
+ - name: Install locally
+ run: opam install -y .
diff -Nru ocaml-dtools-0.4.1/.gitignore ocaml-dtools-0.4.2/.gitignore
--- ocaml-dtools-0.4.1/.gitignore 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/.gitignore 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1,5 @@
+_build/
+*.install
+.*sw*
+.merlin
+*~
\ No newline at end of file
diff -Nru ocaml-dtools-0.4.1/install-sh ocaml-dtools-0.4.2/install-sh
--- ocaml-dtools-0.4.1/install-sh 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/install-sh 1970-01-01 00:00:00.000000000 +0000
@@ -1,518 +0,0 @@
-#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2018-03-11.20; # UTC
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# 'make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-
-tab=' '
-nl='
-'
-IFS=" $tab$nl"
-
-# Set DOITPROG to "echo" to test this script.
-
-doit=${DOITPROG-}
-doit_exec=${doit:-exec}
-
-# Put in absolute file names if you don't have them in your path;
-# or use environment vars.
-
-chgrpprog=${CHGRPPROG-chgrp}
-chmodprog=${CHMODPROG-chmod}
-chownprog=${CHOWNPROG-chown}
-cmpprog=${CMPPROG-cmp}
-cpprog=${CPPROG-cp}
-mkdirprog=${MKDIRPROG-mkdir}
-mvprog=${MVPROG-mv}
-rmprog=${RMPROG-rm}
-stripprog=${STRIPPROG-strip}
-
-posix_mkdir=
-
-# Desired mode of installed file.
-mode=0755
-
-chgrpcmd=
-chmodcmd=$chmodprog
-chowncmd=
-mvcmd=$mvprog
-rmcmd="$rmprog -f"
-stripcmd=
-
-src=
-dst=
-dir_arg=
-dst_arg=
-
-copy_on_change=false
-is_target_a_directory=possibly
-
-usage="\
-Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
- or: $0 [OPTION]... SRCFILES... DIRECTORY
- or: $0 [OPTION]... -t DIRECTORY SRCFILES...
- or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
- --help display this help and exit.
- --version display version info and exit.
-
- -c (ignored)
- -C install only if different (preserve the last data modification time)
- -d create directories instead of installing files.
- -g GROUP $chgrpprog installed files to GROUP.
- -m MODE $chmodprog installed files to MODE.
- -o USER $chownprog installed files to USER.
- -s $stripprog installed files.
- -t DIRECTORY install into DIRECTORY.
- -T report an error if DSTFILE is a directory.
-
-Environment variables override the default commands:
- CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
- RMPROG STRIPPROG
-"
-
-while test $# -ne 0; do
- case $1 in
- -c) ;;
-
- -C) copy_on_change=true;;
-
- -d) dir_arg=true;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift;;
-
- --help) echo "$usage"; exit $?;;
-
- -m) mode=$2
- case $mode in
- *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
- echo "$0: invalid mode: $mode" >&2
- exit 1;;
- esac
- shift;;
-
- -o) chowncmd="$chownprog $2"
- shift;;
-
- -s) stripcmd=$stripprog;;
-
- -t)
- is_target_a_directory=always
- dst_arg=$2
- # Protect names problematic for 'test' and other utilities.
- case $dst_arg in
- -* | [=\(\)!]) dst_arg=./$dst_arg;;
- esac
- shift;;
-
- -T) is_target_a_directory=never;;
-
- --version) echo "$0 $scriptversion"; exit $?;;
-
- --) shift
- break;;
-
- -*) echo "$0: invalid option: $1" >&2
- exit 1;;
-
- *) break;;
- esac
- shift
-done
-
-# We allow the use of options -d and -T together, by making -d
-# take the precedence; this is for compatibility with GNU install.
-
-if test -n "$dir_arg"; then
- if test -n "$dst_arg"; then
- echo "$0: target directory not allowed when installing a directory." >&2
- exit 1
- fi
-fi
-
-if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
- # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- # Otherwise, the last argument is the destination. Remove it from $@.
- for arg
- do
- if test -n "$dst_arg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dst_arg"
- shift # fnord
- fi
- shift # arg
- dst_arg=$arg
- # Protect names problematic for 'test' and other utilities.
- case $dst_arg in
- -* | [=\(\)!]) dst_arg=./$dst_arg;;
- esac
- done
-fi
-
-if test $# -eq 0; then
- if test -z "$dir_arg"; then
- echo "$0: no input file specified." >&2
- exit 1
- fi
- # It's OK to call 'install-sh -d' without argument.
- # This can happen when creating conditional directories.
- exit 0
-fi
-
-if test -z "$dir_arg"; then
- if test $# -gt 1 || test "$is_target_a_directory" = always; then
- if test ! -d "$dst_arg"; then
- echo "$0: $dst_arg: Is not a directory." >&2
- exit 1
- fi
- fi
-fi
-
-if test -z "$dir_arg"; then
- do_exit='(exit $ret); exit $ret'
- trap "ret=129; $do_exit" 1
- trap "ret=130; $do_exit" 2
- trap "ret=141; $do_exit" 13
- trap "ret=143; $do_exit" 15
-
- # Set umask so as not to create temps with too-generous modes.
- # However, 'strip' requires both read and write access to temps.
- case $mode in
- # Optimize common cases.
- *644) cp_umask=133;;
- *755) cp_umask=22;;
-
- *[0-7])
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw='% 200'
- fi
- cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
- *)
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw=,u+rw
- fi
- cp_umask=$mode$u_plus_rw;;
- esac
-fi
-
-for src
-do
- # Protect names problematic for 'test' and other utilities.
- case $src in
- -* | [=\(\)!]) src=./$src;;
- esac
-
- if test -n "$dir_arg"; then
- dst=$src
- dstdir=$dst
- test -d "$dstdir"
- dstdir_status=$?
- else
-
- # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
- # might cause directories to be created, which would be especially bad
- # if $src (and thus $dsttmp) contains '*'.
- if test ! -f "$src" && test ! -d "$src"; then
- echo "$0: $src does not exist." >&2
- exit 1
- fi
-
- if test -z "$dst_arg"; then
- echo "$0: no destination specified." >&2
- exit 1
- fi
- dst=$dst_arg
-
- # If destination is a directory, append the input filename.
- if test -d "$dst"; then
- if test "$is_target_a_directory" = never; then
- echo "$0: $dst_arg: Is a directory" >&2
- exit 1
- fi
- dstdir=$dst
- dstbase=`basename "$src"`
- case $dst in
- */) dst=$dst$dstbase;;
- *) dst=$dst/$dstbase;;
- esac
- dstdir_status=0
- else
- dstdir=`dirname "$dst"`
- test -d "$dstdir"
- dstdir_status=$?
- fi
- fi
-
- case $dstdir in
- */) dstdirslash=$dstdir;;
- *) dstdirslash=$dstdir/;;
- esac
-
- obsolete_mkdir_used=false
-
- if test $dstdir_status != 0; then
- case $posix_mkdir in
- '')
- # Create intermediate dirs using mode 755 as modified by the umask.
- # This is like FreeBSD 'install' as of 1997-10-28.
- umask=`umask`
- case $stripcmd.$umask in
- # Optimize common cases.
- *[2367][2367]) mkdir_umask=$umask;;
- .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
- *[0-7])
- mkdir_umask=`expr $umask + 22 \
- - $umask % 100 % 40 + $umask % 20 \
- - $umask % 10 % 4 + $umask % 2
- `;;
- *) mkdir_umask=$umask,go-w;;
- esac
-
- # With -d, create the new directory with the user-specified mode.
- # Otherwise, rely on $mkdir_umask.
- if test -n "$dir_arg"; then
- mkdir_mode=-m$mode
- else
- mkdir_mode=
- fi
-
- posix_mkdir=false
- case $umask in
- *[123567][0-7][0-7])
- # POSIX mkdir -p sets u+wx bits regardless of umask, which
- # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
- ;;
- *)
- # Note that $RANDOM variable is not portable (e.g. dash); Use it
- # here however when possible just to lower collision chance.
- tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-
- trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
-
- # Because "mkdir -p" follows existing symlinks and we likely work
- # directly in world-writeable /tmp, make sure that the '$tmpdir'
- # directory is successfully created first before we actually test
- # 'mkdir -p' feature.
- if (umask $mkdir_umask &&
- $mkdirprog $mkdir_mode "$tmpdir" &&
- exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
- then
- if test -z "$dir_arg" || {
- # Check for POSIX incompatibilities with -m.
- # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
- # other-writable bit of parent directory when it shouldn't.
- # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
- test_tmpdir="$tmpdir/a"
- ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
- case $ls_ld_tmpdir in
- d????-?r-*) different_mode=700;;
- d????-?--*) different_mode=755;;
- *) false;;
- esac &&
- $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
- ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
- test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
- }
- }
- then posix_mkdir=:
- fi
- rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
- else
- # Remove any dirs left behind by ancient mkdir implementations.
- rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
- fi
- trap '' 0;;
- esac;;
- esac
-
- if
- $posix_mkdir && (
- umask $mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
- )
- then :
- else
-
- # The umask is ridiculous, or mkdir does not conform to POSIX,
- # or it failed possibly due to a race condition. Create the
- # directory the slow way, step by step, checking for races as we go.
-
- case $dstdir in
- /*) prefix='/';;
- [-=\(\)!]*) prefix='./';;
- *) prefix='';;
- esac
-
- oIFS=$IFS
- IFS=/
- set -f
- set fnord $dstdir
- shift
- set +f
- IFS=$oIFS
-
- prefixes=
-
- for d
- do
- test X"$d" = X && continue
-
- prefix=$prefix$d
- if test -d "$prefix"; then
- prefixes=
- else
- if $posix_mkdir; then
- (umask=$mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
- # Don't fail if two instances are running concurrently.
- test -d "$prefix" || exit 1
- else
- case $prefix in
- *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
- *) qprefix=$prefix;;
- esac
- prefixes="$prefixes '$qprefix'"
- fi
- fi
- prefix=$prefix/
- done
-
- if test -n "$prefixes"; then
- # Don't fail if two instances are running concurrently.
- (umask $mkdir_umask &&
- eval "\$doit_exec \$mkdirprog $prefixes") ||
- test -d "$dstdir" || exit 1
- obsolete_mkdir_used=true
- fi
- fi
- fi
-
- if test -n "$dir_arg"; then
- { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
- { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
- test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
- else
-
- # Make a couple of temp file names in the proper directory.
- dsttmp=${dstdirslash}_inst.$$_
- rmtmp=${dstdirslash}_rm.$$_
-
- # Trap to clean up those temp files at exit.
- trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-
- # Copy the file name to the temp name.
- (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-
- # and set any options; do chmod last to preserve setuid bits.
- #
- # If any of these fail, we abort the whole thing. If we want to
- # ignore errors from any of these, just make sure not to ignore
- # errors from the above "$doit $cpprog $src $dsttmp" command.
- #
- { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
- { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
- { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-
- # If -C, don't bother to copy if it wouldn't change the file.
- if $copy_on_change &&
- old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
- new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
- set -f &&
- set X $old && old=:$2:$4:$5:$6 &&
- set X $new && new=:$2:$4:$5:$6 &&
- set +f &&
- test "$old" = "$new" &&
- $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
- then
- rm -f "$dsttmp"
- else
- # Rename the file to the real destination.
- $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
-
- # The rename failed, perhaps because mv can't rename something else
- # to itself, or perhaps because mv is so ancient that it does not
- # support -f.
- {
- # Now remove or move aside any old file at destination location.
- # We try this two ways since rm can't unlink itself on some
- # systems and the destination file might be busy for other
- # reasons. In this case, the final cleanup might fail but the new
- # file should still install successfully.
- {
- test ! -f "$dst" ||
- $doit $rmcmd -f "$dst" 2>/dev/null ||
- { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
- { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
- } ||
- { echo "$0: cannot unlink or rename $dst" >&2
- (exit 1); exit 1
- }
- } &&
-
- # Now rename the file to the real destination.
- $doit $mvcmd "$dsttmp" "$dst"
- }
- fi || exit 1
-
- trap '' 0
- fi
-done
-
-# Local variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC0"
-# time-stamp-end: "; # UTC"
-# End:
diff -Nru ocaml-dtools-0.4.1/m4/base_checks.m4 ocaml-dtools-0.4.2/m4/base_checks.m4
--- ocaml-dtools-0.4.1/m4/base_checks.m4 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/m4/base_checks.m4 1970-01-01 00:00:00.000000000 +0000
@@ -1,175 +0,0 @@
-AC_DEFUN([AC_BASE_CHECKS],
-[AC_REQUIRE([AC_PROG_CC])
-
-dnl check for base compilers
-AC_CANONICAL_HOST()
-
-dnl Detect the target toolchain
-AC_MSG_CHECKING([target toolchain])
-case "${host_os}" in
- linux*)
- TARGET_TOOLCHAIN="linux"
- ;;
- mingw*)
- TARGET_TOOLCHAIN="mingw"
- ;;
- cygwin*)
- TARGET_TOOLCHAIN="cygwin"
- ;;
- darwin*)
- TARGET_TOOLCHAIN="darwin"
- ;;
- *)
- TARGET_TOOLCHAIN="other"
- ;;
-esac
-AC_MSG_RESULT([$TARGET_TOOLCHAIN])
-AC_SUBST(TARGET_TOOLCHAIN)
-
-# AC_CANONICAL_HOST needs those files
-AUTOCONF_INSTALL_FILES="config.guess config.sub install-sh m4/*.m4"
-AC_SUBST(AUTOCONF_INSTALL_FILES)
-
-AC_PROG_CC()
-AC_PROG_INSTALL()
-AC_CHECK_TOOL([AR],[ar],no)
-AC_SUBST(AR)
-AC_CHECK_OCAML_COMPILERS()
-
-dnl add some flags
-AC_DETECT_PIC_FLAGS()
-
-CXXFLAGS="$CXXFLAGS $PIC_FLAGS"
-CPPFLAGS="$CPPFLAGS $PIC_FLAGS"
-
-# Add prefix to compilation variables
-# if passed
-if test "x$prefix" != "xNONE"; then
- CFLAGS="$CFLAGS -I$prefix/include"
- LDFLAGS="$LDFLAGS -L$prefix/lib"
- CPPFLAGS="$CPPFLAGS -I$prefix/include"
- CXXFLAGS="$CXXFLAGS -I$prefix/include"
-fi
-])
-
-dnl Check for basic stuff
-dnl The following was stolen from mesa..
-dnl A few convenience macros for Mesa, mostly to keep all the platform
-dnl specifics out of configure.ac.
-
-dnl AC_DETECT_PIC_FLAGS()
-dnl
-dnl Find out whether to build PIC code using the option --enable-pic and
-dnl the configure enable_static/enable_shared settings. If PIC is needed,
-dnl figure out the necessary flags for the platform and compiler.
-dnl
-dnl The platform checks have been shamelessly taken from libtool and
-dnl stripped down to just what's needed for Mesa. See _LT_COMPILER_PIC in
-dnl /usr/share/aclocal/libtool.m4 or
-dnl http://git.savannah.gnu.org/gitweb/?p=libtool.git;a=blob;f=libltdl/m4/libtool.m4;hb=HEAD
-dnl
-AC_DEFUN([AC_DETECT_PIC_FLAGS],
-[AC_ARG_VAR([PIC_FLAGS], [compiler flags for PIC code])
-AC_ARG_ENABLE([pic],
- [AS_HELP_STRING([--disable-pic],
- [compile PIC objects @<:@default=enabled for shared builds
- on supported platforms@:>@])],
- [enable_pic="$enableval"
- test "x$enable_pic" = x && enable_pic=auto],
- [enable_pic=auto])
-dnl disable PIC by default for static builds
-if test "$enable_pic" = auto && test "$enable_static" = yes; then
- enable_pic=no
-fi
-dnl if PIC hasn't been explicitly disabled, try to figure out the flags
-if test "$enable_pic" != no; then
- AC_MSG_CHECKING([for $CC option to produce PIC])
- dnl allow the user's flags to override
- if test "x$PIC_FLAGS" = "x"; then
- dnl see if we're using GCC
- if test "x$GCC" = "xyes"; then
- case "$host_os" in
- aix*|beos*|cygwin*|irix5*|irix6*|osf3*|osf4*|osf5*)
- dnl PIC is the default for these OSes.
- ;;
- mingw*|os2*|pw32*)
- dnl This hack is so that the source file can tell whether
- dnl it is being built for inclusion in a dll (and should
- dnl export symbols for example).
- PIC_FLAGS="-DDLL_EXPORT"
- ;;
- darwin*|rhapsody*)
- dnl PIC is the default on this platform
- dnl Common symbols not allowed in MH_DYLIB files
- PIC_FLAGS="-fno-common"
- ;;
- hpux*)
- dnl PIC is the default for IA64 HP-UX and 64-bit HP-UX,
- dnl but not for PA HP-UX.
- case $host_cpu in
- hppa*64*|ia64*)
- ;;
- *)
- PIC_FLAGS="-fPIC"
- ;;
- esac
- ;;
- *)
- dnl Everyone else on GCC uses -fPIC
- PIC_FLAGS="-fPIC"
- ;;
- esac
- else dnl !GCC
- case "$host_os" in
- hpux9*|hpux10*|hpux11*)
- dnl PIC is the default for IA64 HP-UX and 64-bit HP-UX,
- dnl but not for PA HP-UX.
- case "$host_cpu" in
- hppa*64*|ia64*)
- dnl +Z the default
- ;;
- *)
- PIC_FLAGS="+Z"
- ;;
- esac
- ;;
- linux*|k*bsd*-gnu)
- case `basename "$CC"` in
- icc*|ecc*|ifort*)
- PIC_FLAGS="-KPIC"
- ;;
- pgcc*|pgf77*|pgf90*|pgf95*)
- dnl Portland Group compilers (*not* the Pentium gcc
- dnl compiler, which looks to be a dead project)
- PIC_FLAGS="-fpic"
- ;;
- ccc*)
- dnl All Alpha code is PIC.
- ;;
- xl*)
- dnl IBM XL C 8.0/Fortran 10.1 on PPC
- PIC_FLAGS="-qpic"
- ;;
- *)
- case `$CC -V 2>&1 | sed 5q` in
- *Sun\ C*|*Sun\ F*)
- dnl Sun C 5.9 or Sun Fortran
- PIC_FLAGS="-KPIC"
- ;;
- esac
- esac
- ;;
- solaris*)
- PIC_FLAGS="-KPIC"
- ;;
- sunos4*)
- PIC_FLAGS="-PIC"
- ;;
- esac
- fi
- fi
- AC_MSG_RESULT([$PIC_FLAGS])
-fi
-AC_SUBST([PIC_FLAGS])
-])dnl PIC_FLAGS
-
diff -Nru ocaml-dtools-0.4.1/m4/cpp_check_class.m4 ocaml-dtools-0.4.2/m4/cpp_check_class.m4
--- ocaml-dtools-0.4.1/m4/cpp_check_class.m4 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/m4/cpp_check_class.m4 1970-01-01 00:00:00.000000000 +0000
@@ -1,24 +0,0 @@
-dnl $1: linker lib name
-dnl $2: included file
-dnl $3: tested class
-dnl $4: emitted variable
-AC_DEFUN([AC_CPP_CHECK_CLASS],
-[AC_LANG_PUSH([C++])
- SAVED_LDFLAGS=$LDFLAGS
- LDFLAGS="$LDFLAGS -l$1"
- AC_MSG_CHECKING([for class $3 in $1 library])
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([#include <$2>],
- [$3 *x = NULL])],
- [TEST_LIBS="$TEST_LIBS -l$1"] [RESULT=1],
- [RESULT=])
- if test -z $RESULT; then
- AC_MSG_RESULT([not found])
- else
- AC_DEFINE([$4], [1], [Defined if class $3 has been found in $1 library])
- AC_MSG_RESULT([ok])
- fi
- $4=$RESULT
- AC_SUBST([$4])
- LDFLAGS=$SAVED_LDFLAGS
- AC_LANG_POP([C++])])
diff -Nru ocaml-dtools-0.4.1/m4/detect_binding.m4 ocaml-dtools-0.4.2/m4/detect_binding.m4
--- ocaml-dtools-0.4.1/m4/detect_binding.m4 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/m4/detect_binding.m4 1970-01-01 00:00:00.000000000 +0000
@@ -1,186 +0,0 @@
-dnl ===========================================================================
-dnl Helper macro to detect an optional binding
-
-m4_defun([AC_OCAML_COMPARE_VERSION],
- [if test -z "$2" ; then
- VERSION_OK=yes
- else
- AS_VERSION_COMPARE([$1],[$2],
- [VERSION_OK=],
- [VERSION_OK=yes],
- [VERSION_OK=yes])
-fi])
-
-m4_defun([AC_OCAML_CHECK_DEPS],
- [dnl
-m4_define([deps],[m4_translit([$1],['a-z'],['A-Z'])])
-DEPS_CHECK=yes
-for i in deps(); do
- eval "dep_check=\$W_$i"
- if test -z "${dep_check}"; then
- DEPS_CHECK=
- break
- fi
-done])
-
-m4_defun([AC_MSG_RESULT_NOT],
- [ifelse([$1],[],[AC_MSG_RESULT($2)],[AC_MSG_ERROR($2)])])
-
-m4_defun([AC_COND_PLUGIN],
- [ifelse([$1],[],
-[AC_ARG_ENABLE([$2-dynamic-plugin],
- AC_HELP_STRING(
- [--enable-$2-dynamic-plugin],
- [Compile $2 as an optional dynamic plugin.]))])])
-
-AC_DEFUN([AC_CHECK_OCAML_BINDING],[dnl
-
-m4_define([BINDING],[m4_translit([$1],['a-z.-'],['A-Z__'])])
-m4_define([binding],[m4_translit([$1],['A-Z.-'],['a-z__'])])
-
-dnl $1 = PKG_NAME
-dnl $2 = PKG_VERSION
-dnl $3 = PKG_DEPS
-dnl $4 = PKG_MANDATORY
-dnl $5 = PKG_USED (for instance sdl.mixer au lieu of sdl. Should only be used for bindings not provided by us..)
-dnl $6 = DYNAMIC_PLUGIN
-dnl $7 = PKG_CMA (used for duppy.syntax and flac.ogg when locally compiled..)
-
-if test -n "$5"; then
- BINDING_PKGS="$5"
-else
- BINDING_PKGS="$1"
-fi
-
-AC_ARG_WITH([binding()-dir],
- AC_HELP_STRING(
- [--with-binding()-dir=path],
- [look for ocaml-binding() library in "path" (autodetected by default)]))
-
-AC_COND_PLUGIN([$6],[$1])
-
-dnl Version stuff
-m4_define([VERSION_CHECK],[ifelse([$2],[],[],[ >= $2])])
-
-AC_MSG_CHECKING([for ocaml $1 module[]VERSION_CHECK()])
-
-OCAML_CHECK="${OCAMLFIND} query $1"
-
-dnl This (horrible) macro does the following:
-dnl Detect optional binding
-dnl If builtin and provided by ocamlfind,
-dnl fills liquidsoap_ocamlcflags with "-package deps" for
-dnl each dependency
-dnl If builtin and provided by us, fills
-dnl liquidsoap_ocamlcflags with "-I /path/to/ocaml-foo/src"
-dnl and liquidsoap_ocamllfflags with "foo.cmxa"
-dnl If plugin and provided by ocamlfind,
-dnl fills plugin_packages with "deps"
-dnl If plugin and provided by us, fills
-dnl plugin_ocamlcflags with "-I /path/to/ocaml-foo/src"
-dnl and plugin_ocamllflags with "foo.cmxa"
-dnl Ultimately, plugin_ocamlcflags and plugin_ocamllflags
-dnl are added to the global $PLUGINS_DATA variable and
-dnl $PLUGINS is updated with the name of this plugin.
-dnl W_plugin is set to "yes" for builtin compilation
-dnl and "binding" for plugin compilation.
-
-if test "x$enable_[]binding()_dynamic_plugin" = "xyes" ; then
- BINDING()_SHARED="yes"
- PLUGINS="$PLUGINS binding()"
-fi
-
-AC_OCAML_CHECK_DEPS([$3])
-if test -z $DEPS_CHECK; then
- AC_MSG_RESULT([[]binding() needs $3])
-else
- if test -z "${with_[]binding()_dir}" ; then
- if ! ${OCAML_CHECK} > /dev/null 2>&1 ; then
- AC_MSG_RESULT_NOT([$4],[Not found.])
- else
- BINDING()_version="`${OCAMLFIND} query -format "%v" $1 2>/dev/null`"
- AC_OCAML_COMPARE_VERSION([${[]BINDING()_version}],[$2])
- if test -z "${VERSION_OK}"; then
- AC_MSG_RESULT_NOT([$4],[requires version >= $2 found ${[]BINDING()_version}.])
- else
- if test -z "${[]BINDING()_SHARED}"; then
- BINDING()_PACKAGES="`${OCAMLFIND} query -separator " " -format "-package %p" $BINDING_PKGS 2>/dev/null`"
- liquidsoap_ocamlcflags="${liquidsoap_ocamlcflags} ${[]BINDING()_PACKAGES}"
- W_[]BINDING()=yes
- else
- []binding()_packages="`${OCAMLFIND} query -r -separator " " -format "%p" $BINDING_PKGS 2>/dev/null`"
- W_[]BINDING()=[]binding()
- fi
- LIBS_VERSIONS="${LIBS_VERSIONS} $1=$[]BINDING()_version"
- AC_MSG_RESULT(ok)
- fi
- fi
- else
- BINDING()_STOP_CHECK=
- BINDING()_version=changequote({,})"[unknown version]"changequote([,])
- BINDING()_requires=
- if test -r ${with_[]binding()_dir}/META >/dev/null 2>&1; then
- # Grab version
- BINDING()_version=`cat "${with_[]binding()_dir}/META" | grep version | cut -d'=' -f 2 | tr -d ' ' | tr -d '"' | head -n 1`
- AC_OCAML_COMPARE_VERSION([${[]BINDING()_version}],[$2])
- if test -z "${VERSION_OK}"; then
- AC_MSG_RESULT_NOT([$4],[requires version >= $2 found ${[]BINDING()_version}.])
- BINDING()_STOP_CHECK=yes
- fi
- BINDING()_requires=`cat "${with_[]binding()_dir}/META" | grep 'requires' | cut -d '=' -f 2 | tr -d '"'`
- BINDING()_path="${with_[]binding()_dir}"
- else
- BINDING()_path=`${OCAMLFIND} -query $1 2>/dev/null`
- if ! test -z "$2"; then
- AC_MSG_RESULT_NOT([$4],[cannot find version from META file.])
- BINDING()_STOP_CHECK=yes
- fi
- fi
- if test -z "${BINDING()_STOP_CHECK}"; then
- BINDING()_PACKAGES="`${OCAMLFIND} query -separator " " -format "-package %p" $BINGING_PKGS 2>/dev/null`"
- echo ${with_[]binding()_dir} | grep ^/ > /dev/null 2>&1 \
- || with_[]binding()_dir=${PWD}/${with_[]binding()_dir}
- if test -z "${[]BINDING()_SHARED}"; then
- liquidsoap_ocamlcflags="${liquidsoap_ocamlcflags} -I ${with_[]binding()_dir} ${[]BINDING()_PACKAGES}"
- else
- []binding()_ocamlcflags="-I ${with_[]binding()_dir} ${[]BINDING()_PACKAGES}"
- fi
- # We need to recurse here because
- #Â some package may not be registered using ocamlfind
- if test -n "$7"; then
- BINDING()_CMA=$7.${cma}
- else
- BINDING()_CMA=$1.${cma}
- fi
- for i in ${[]BINDING()_requires}; do
- BINDING()_PACKAGES="${[]BINDING()_PACKAGES} `${OCAMLFIND} query -separator " " -format "-package %p" $i 2>/dev/null`"
- done
- if test -z "${[]BINDING()_SHARED}"; then
- liquidsoap_ocamllflags="${liquidsoap_ocamllflags} ${[]BINDING()_PACKAGES} ${[]BINDING()_CMA}"
- W_[]BINDING()=yes
- else
- []binding()_ocamllflags="${[]BINDING()_PACKAGES} ${[]BINDING()_CMA}"
- W_[]BINDING()=[]binding()
- fi
- LIBS_VERSIONS="${LIBS_VERSIONS} $1=$[]BINDING()_version"
- AC_MSG_RESULT(ok)
- fi
- fi
-fi
-
-AC_SUBST(W_[]BINDING())
-if test -z "${W_[]BINDING()}" ; then
- w_[]BINDING()="no (requires $1)"
-else
- if test -z "${[]BINDING()_SHARED}"; then
- w_[]BINDING()=yes
- else
- PLUGINS_DATA="$PLUGINS_DATA
-[]binding()_ocamlcflags=${[]binding()_ocamlcflags}
-[]binding()_ocamllflags=${[]binding()_ocamllflags}
-[]binding()_packages=${[]binding()_packages}"
- w_[]BINDING()=plugin
- fi
-fi])
-
-
diff -Nru ocaml-dtools-0.4.1/m4/ocaml_compilers.m4 ocaml-dtools-0.4.2/m4/ocaml_compilers.m4
--- ocaml-dtools-0.4.1/m4/ocaml_compilers.m4 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/m4/ocaml_compilers.m4 1970-01-01 00:00:00.000000000 +0000
@@ -1,76 +0,0 @@
-AC_DEFUN([AC_CHECK_OCAML_COMPILERS],[
-OCAMLFIND_LDCONF=""
-AC_ARG_ENABLE([ldconf], AC_HELP_STRING([--disable-ldconf],[don't modify the dynamic loader configuration file (default is enable)]),[ac_enable_ldconf=$enableval],[ac_enable_ldconf=$enableval],[ac_enable_ldconf=yes])
-if test "$ac_enable_ldconf" = no ; then
- AC_MSG_RESULT([disabling modification of ld.conf])
- OCAMLFIND_LDCONF=dummy
-fi
-AC_SUBST(OCAMLFIND_LDCONF)
-
-# Check for Ocaml compilers
-
-AC_PROG_OCAML()
-
-AC_PROG_CAMLIDL()
-
-AC_PROG_OCAMLLEX()
-
-AC_PROG_OCAMLYACC()
-
-AC_PROG_CAMLP4()
-
-AC_PROG_FINDLIB()
-
-AC_CHECK_OCAML_STDLIB()
-
-# Check if caml/threads.h is present
-old_CFLAGS=$CFLAGS
-CFLAGS="$CFLAGS -I${OCAML_STDLIB}"
-AC_CHECK_HEADER([caml/threads.h],[CAML_THREADS=yes],[],[#include ])
-CFLAGS=${old_CFLAGS}
-
-AC_ARG_ENABLE([debugging],
- AC_HELP_STRING(
- [--disable-debugging],
- [disable debugging information (backtrace printing in particular)]))
-
-if test "$enable_debugging" \!= "no" ; then
- OCAMLFLAGS="$OCAMLFLAGS -g"
-fi
-
-AC_ARG_WITH([ocaml-warnings],
- AC_HELP_STRING(
- [--with-ocaml-warnings=WARNINGS],
- [Enable specific list of ocaml compiler warnings.]))
-
-if test -n "${with_ocaml_warnings}" ; then
- OCAMLFLAGS="$OCAMLFLAGS -w +${with_ocaml_warnings}"
-else
- OCAMLFLAGS="$OCAMLFLAGS -w +A-4@5-7@8-9@11@12@20-35-44-45-50"
-fi
-
-AC_ARG_ENABLE([profiling],
- AC_HELP_STRING(
- [--enable-profiling],
- [compile to generate profiling infomation]))
-if test "x$enable_profiling" = "xyes" ; then
- OCAMLNCFLAGS="$OCAMLNCFLAGS -p"
-fi
-AC_SUBST(OCAMLNCFLAGS)
-
-AC_ARG_ENABLE([nativecode],
- AC_HELP_STRING(
- [--disable-nativecode],
- [compile in bytecode]))
-
-AC_ARG_ENABLE([custom],
- AC_HELP_STRING(
- [--disable-custom],
- [disable custom mode for bytecode compilation (use if you know what you are doing)]))
-
-CAMLLIBPATH=$OCAMLLIB
-AC_SUBST(CAMLLIBPATH)
-
-AC_SUBST(CAMLIDL)
-AC_SUBST(OCAMLFLAGS)
-])
diff -Nru ocaml-dtools-0.4.1/m4/ocaml.m4 ocaml-dtools-0.4.2/m4/ocaml.m4
--- ocaml-dtools-0.4.1/m4/ocaml.m4 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/m4/ocaml.m4 1970-01-01 00:00:00.000000000 +0000
@@ -1,329 +0,0 @@
-dnl autoconf macros for OCaml
-dnl
-dnl Copyright © 2009 Richard W.M. Jones
-dnl Copyright © 2009 Stefano Zacchiroli
-dnl Copyright © 2000-2005 Olivier Andrieu
-dnl Copyright © 2000-2005 Jean-Christophe Filliâtre
-dnl Copyright © 2000-2005 Georges Mariano
-dnl
-dnl For documentation, please read the ocaml.m4 man page.
-
-AC_DEFUN([AC_PROG_OCAML],
-[dnl
- # checking for ocamlc
- AC_CHECK_TOOL([OCAMLC],[ocamlc],[no])
-
- if test "$OCAMLC" = "no"; then
- AC_MSG_ERROR(Cannot find ocamlc.)
- fi
-
- AC_SUBST([OCAMLC])
-
- OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'`
- AC_MSG_RESULT([OCaml version is $OCAMLVERSION])
- # Check if version is >= 3.12.0
- AC_MSG_CHECKING([if ocaml compiler supports first-class modules])
- AS_VERSION_COMPARE([$OCAMLVERSION],[3.12.0],[],[OCAML_HAS_FIRST_CLASS_MODULES="yes"],[OCAML_HAS_FIRST_CLASS_MODULES="yes"])
- if test -n "${OCAML_HAS_FIRST_CLASS_MODULES}"; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- fi
- AC_SUBST(OCAML_HAS_FIRST_CLASS_MODULES)
-
- # If OCAMLLIB is set, use it
- if test "$OCAMLLIB" = ""; then
- OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4`
- else
- AC_MSG_RESULT([OCAMLLIB previously set; preserving it.])
- fi
- AC_MSG_RESULT([OCaml library path is $OCAMLLIB])
-
- AC_SUBST([OCAMLVERSION])
- AC_SUBST([OCAMLLIB])
-
- # checking for ocamlopt
- AC_CHECK_TOOL_STRICT([OCAMLOPT],[ocamlopt],[no])
- OCAMLBEST=byte
- OCAML_DYNLINK=byte-dyn
- if test "$OCAMLOPT" = "no"; then
- AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.])
- else
- TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.])
- OCAMLOPT=no
- else
- OCAMLBEST="byte opt"
- OCAML_DYNLINK="byte-dyn opt-dyn"
- fi
- fi
-
- AC_SUBST([OCAMLBEST])
- AC_SUBST([OCAML_DYNLINK])
-
- # checking for ocamlc.opt
- AC_CHECK_TOOL_STRICT([OCAMLCDOTOPT],[ocamlc.opt],[no])
- if test "$OCAMLCDOTOPT" != "no"; then
- TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.])
- else
- OCAMLC=$OCAMLCDOTOPT
- fi
- fi
-
- # checking for ocamlopt.opt
- if test "$OCAMLOPT" != "no" ; then
- AC_CHECK_TOOL_STRICT([OCAMLOPTDOTOPT],[ocamlopt.opt],[no])
- if test "$OCAMLOPTDOTOPT" != "no"; then
- TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.])
- else
- OCAMLOPT=$OCAMLOPTDOTOPT
- fi
- fi
- fi
-
- AC_SUBST([OCAMLOPT])
-
- # checking for ocaml toplevel
- AC_CHECK_TOOL_STRICT([OCAML],[ocaml],[no])
-
- AC_SUBST([OCAML])
-
- # checking for ocamldep
- AC_CHECK_TOOL_STRICT([OCAMLDEP],[ocamldep],[no])
- if test "$OCAMLDEP" = "no"; then
- AC_MSG_ERROR(Cannot find ocamlmklib.)
- else
- AC_CHECK_TOOL_STRICT([OCAMLDEPOPT],[ocamldep.opt],[no])
- if test "$OCAMLDEPOPT" != "no"; then
- OCAMLDEP=$OCAMLDEPOPT
- fi
- fi
-
- AC_SUBST([OCAMLDEP])
-
- # checking for ocamlmktop
- AC_CHECK_TOOL_STRICT([OCAMLMKTOP],[ocamlmktop],[no])
-
- AC_SUBST([OCAMLMKTOP])
-
- # checking for ocamlmklib
- AC_CHECK_TOOL_STRICT([OCAMLMKLIB],[ocamlmklib],[no])
- if test "$OCAMLMKLIB" = "no"; then
- AC_MSG_ERROR(Cannot find ocamlmklib.)
- fi
-
- AC_SUBST([OCAMLMKLIB])
-
- # checking for ocamldoc
- AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no])
- if test "$OCAMLDOC" != "no"; then
- AC_CHECK_TOOL([OCAMLDOCOPT],[ocamldoc.opt],[no])
- if test "$OCAMLDOCOPT" != "no"; then
- OCAMLDOC=$OCAMLDOCOPT
- fi
- fi
-
- AC_SUBST([OCAMLDOC])
-
- # checking for ocamlbuild
- AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no])
-
- AC_SUBST([OCAMLBUILD])
-])
-
-
-AC_DEFUN([AC_PROG_OCAMLLEX],
-[dnl
- # checking for ocamllex
- AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no])
- if test "$OCAMLLEX" != "no"; then
- AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no])
- if test "$OCAMLLEXDOTOPT" != "no"; then
- OCAMLLEX=$OCAMLLEXDOTOPT
- fi
- fi
- AC_SUBST([OCAMLLEX])
-])
-
-AC_DEFUN([AC_PROG_OCAMLYACC],
-[dnl
- AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no])
- AC_SUBST([OCAMLYACC])
-])
-
-
-AC_DEFUN([AC_PROG_CAMLP4],
-[dnl
- AC_REQUIRE([AC_PROG_OCAML])dnl
-
-
- AC_ARG_ENABLE([camlp4],
- AC_HELP_STRING([--disable-camlp4],
- [disable camlp4 auto-detection.]))
-
- # checking for camlp4
- if test "x$enable_camlp4" != "xno"; then
- AC_CHECK_TOOL_STRICT([CAMLP4],[camlp4],[no])
- if test "$CAMLP4" != "no"; then
- TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p' | tr -d '\r'`
- if test "$TMPVERSION" != "$OCAMLVERSION" ; then
- AC_MSG_RESULT([versions differs from ocamlc])
- CAMLP4=no
- fi
- fi
- AC_SUBST([CAMLP4])
-
- # checking for companion tools
- AC_CHECK_TOOL_STRICT([CAMLP4BOOT],[camlp4boot],[no])
- AC_CHECK_TOOL_STRICT([CAMLP4O],[camlp4o],[no])
- AC_CHECK_TOOL_STRICT([CAMLP4OF],[camlp4of],[no])
- AC_CHECK_TOOL_STRICT([CAMLP4OOF],[camlp4oof],[no])
- AC_CHECK_TOOL_STRICT([CAMLP4ORF],[camlp4orf],[no])
- AC_CHECK_TOOL_STRICT([CAMLP4PROF],[camlp4prof],[no])
- AC_CHECK_TOOL_STRICT([CAMLP4R],[camlp4r],[no])
- AC_CHECK_TOOL_STRICT([CAMLP4RF],[camlp4rf],[no])
- else
- CAMLP4=no
- CAMLP4BOOT=no
- CAMLP4O=no
- CAMLP4OF=no
- CAMLP4OOF=no
- CAMLP4ORF=no
- CAMLP4PROF=no
- CAMLP4R=no
- CAMLP4RF=no
- fi
-
- AC_SUBST([CAMLP4BOOT])
- AC_SUBST([CAMLP4O])
- AC_SUBST([CAMLP4OF])
- AC_SUBST([CAMLP4OOF])
- AC_SUBST([CAMLP4ORF])
- AC_SUBST([CAMLP4PROF])
- AC_SUBST([CAMLP4R])
- AC_SUBST([CAMLP4RF])
-])
-
-AC_DEFUN([AC_PROG_CAMLIDL],
-[dnl
- AC_CHECK_TOOL(CAMLIDL,camlidl,no)
- AC_SUBST(CAMLIDL)
-])
-
-AC_DEFUN([AC_PROG_FINDLIB],
-[dnl
- AC_REQUIRE([AC_PROG_OCAML])dnl
-
- # checking for ocamlfind
- AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no])
- AC_SUBST([OCAMLFIND])
-])
-
-AC_DEFUN([AC_CHECK_OCAML_STDLIB],
-[dnl
- AC_REQUIRE([AC_PROG_FINDLIB])dnl
-
- AC_MSG_CHECKING([for ocaml standard library path])
- OCAML_STDLIB=`$OCAMLFIND printconf stdlib`
- AC_SUBST(OCAML_STDLIB)
- AC_MSG_RESULT([$OCAML_STDLIB])
-])
-
-dnl Thanks to Jim Meyering for working this next bit out for us.
-dnl XXX We should define AS_TR_SH if it's not defined already
-dnl (eg. for old autoconf).
-AC_DEFUN([AC_CHECK_OCAML_PKG],
-[dnl
- AC_REQUIRE([AC_PROG_FINDLIB])dnl
-
- AC_ARG_WITH([$1-dir],AC_HELP_STRING([--with-$1-dir=path],
- [use "path" as the location of ocaml-$1 (autodetected by default)]))
- AC_MSG_CHECKING([for OCaml library $1])
-
- unset found
- unset pkg
- found=no
- if test -z "$with_$1_dir"; then
- for pkg in $1 $2 ; do
- if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then
- AC_MSG_RESULT([found])
- AS_TR_SH([OCAML_PKG_$1])=$pkg
- AS_TR_SH([OCAML_DIR_$1])=`$OCAMLFIND query $1`
- found=yes
- break
- fi
- done
- else
- echo $with_$1_dir | grep ^/ > /dev/null 2>&1 || with_$1_dir=$PWD/$with_$1_dir
- AS_TR_SH([OCAML_PKG_$1])=no
- OCAML_DIR_$1="$with_$1_dir"
- found=yes
- fi
- if test "$found" = "no" ; then
- AC_MSG_RESULT([not found])
- AS_TR_SH([OCAML_HAS_$1])=no
- AS_TR_SH([OCAML_PKG_$1])=no
- else
- AS_TR_SH([OCAML_HAS_$1])=yes
- fi
-
- AC_SUBST(AS_TR_SH([OCAML_PKG_$1]))
-])
-
-
-AC_DEFUN([AC_CHECK_OCAML_MODULE],
-[dnl
- AC_MSG_CHECKING([for OCaml module $2])
-
- cat > conftest.ml <&5 2>&5 ; then
- found=yes
- break
- fi
- done
-
- if test "$found" ; then
- AC_MSG_RESULT([$$1])
- else
- AC_MSG_RESULT([not found])
- $1=no
- fi
- AC_SUBST([$1])
-])
-
-
-dnl XXX Cross-compiling
-AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE],
-[dnl
- AC_REQUIRE([AC_PROG_OCAML])dnl
- AC_MSG_CHECKING([for OCaml compiler word size])
- cat > conftest.ml < conftest.ml <.
-dnl
-dnl This program is free software; you can redistribute it and/or modify
-dnl it under the terms of the GNU General Public License as published by
-dnl the Free Software Foundation; either version 2 of the License, or
-dnl (at your option) any later version.
-dnl
-dnl This program is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU General Public License
-dnl along with this program; if not, write to the Free Software
-dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-dnl
-dnl As a special exception to the GNU General Public License, if you
-dnl distribute this file as part of a program that contains a
-dnl configuration script generated by Autoconf, you may include it under
-dnl the same distribution terms that you use for the rest of that program.
-
-dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
-dnl ----------------------------------
-AC_DEFUN([PKG_PROG_PKG_CONFIG],
-[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
-m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
-AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
-if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
- AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
-fi
-if test -n "$PKG_CONFIG"; then
- _pkg_min_version=m4_default([$1], [0.9.0])
- AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
- if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_ERROR([no])
- PKG_CONFIG=""
- fi
-
-fi[]dnl
-])dnl PKG_PROG_PKG_CONFIG
-
-AC_ARG_VAR([PKG_CONFIG_OPTIONS], [Additional options passed when invoking pkg-config])
-
-dnl PKG_CONFIG_CHECK_MODULE([name],[min-version])
-dnl min-version is optional
-AC_DEFUN([PKG_CONFIG_CHECK_MODULE],
-[if test -n "$2"; then
- PKGCONFIG_CHECK_VERSION=" >= $2"
-else
- PKGCONFIG_CHECK_VERSION=""
-fi
-AC_MSG_CHECKING([whether pkg-config knows about $1${PKGCONFIG_CHECK_VERSION}])
-if ! $PKG_CONFIG $PKG_CONFIG_OPTIONS --exists $1; then
- AC_MSG_ERROR([$1.pc not found.. Do you need to set PKG_CONFIG_PATH?])
-else
- if test -n "$2"; then
- if ! $PKG_CONFIG $PKG_CONFIG_OPTIONS --atleast-version=$2 $1; then
- $1_VERSION="`$PKG_CONFIG $PKG_CONFIG_OPTIONS --modversion $1`"
- AC_MSG_ERROR([requires version >= $2, found ${$1_VERSION}])
- else
- AC_MSG_RESULT([ok])
- fi
- else
- AC_MSG_RESULT([ok])
- fi
-fi
-CFLAGS="$CFLAGS `$PKG_CONFIG $PKG_CONFIG_OPTIONS --cflags $1`"
-CPPFLAGS="$CPPFLAGS `$PKG_CONFIG $PKG_CONFIG_OPTIONS --cflags $1`"
-LIBS="$LIBS `$PKG_CONFIG $PKG_CONFIG_OPTIONS --libs-only-l $1`"
-LDFLAGS="$LDFLAGS `$PKG_CONFIG $PKG_CONFIG_OPTIONS --libs-only-L $1`"
-])
diff -Nru ocaml-dtools-0.4.1/m4/strict_check_tool.m4 ocaml-dtools-0.4.2/m4/strict_check_tool.m4
--- ocaml-dtools-0.4.1/m4/strict_check_tool.m4 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/m4/strict_check_tool.m4 1970-01-01 00:00:00.000000000 +0000
@@ -1,7 +0,0 @@
-AC_DEFUN([AC_CHECK_TOOL_STRICT],
-[AC_CHECK_PROG([$1], [${ac_tool_prefix}$2], [${ac_tool_prefix}$2], [$3], [$4])])
-
-AC_DEFUN([AC_PATH_TOOL_STRICT],
-[AC_PATH_PROG([$1], [${ac_tool_prefix}$2], [$3])])
-
-
diff -Nru ocaml-dtools-0.4.1/Makefile ocaml-dtools-0.4.2/Makefile
--- ocaml-dtools-0.4.1/Makefile 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/Makefile 1970-01-01 00:00:00.000000000 +0000
@@ -1,45 +0,0 @@
-# Copyright 2003-2007 Savonet team
-
-SRC := src
-PROGNAME := ocaml-dtools
-DISTFILES := config.guess config.sub install-sh m4/*.m4 bootstrap CHANGES configure configure.ac \
- COPYING Makefile README Makefile.in \
- src/OCamlMakefile src/*Makefile.in src/META.in src/*.ml src/*.mli \
- doc/html
-VERSION := 0.4.1
-
-all:
- $(MAKE) -C $(SRC)
-
-clean:
- $(MAKE) -C $(SRC) clean
-
-install:
- $(MAKE) -C $(SRC) install
-
-uninstall:
- $(MAKE) -C $(SRC) uninstall
-
-update:
- $(MAKE) -C $(SRC) update
-
-distclean: clean
- rm -rf autom4te.cache config.log config.status
- rm -rf doc/html
- rm -f src/META src/Makefile
-
-doc:
- $(MAKE) -C src htdoc
- mkdir -p doc
- rm -rf doc/html
- mv src/doc/dtools/html doc
- rm -rf src/doc
-
-dist: doc
- mkdir $(PROGNAME)-$(VERSION)
- cp -R -L --parents $(DISTFILES) $(PROGNAME)-$(VERSION)
- tar zcvf ../$(PROGNAME)-$(VERSION).tar.gz $(PROGNAME)-$(VERSION)
- rm -rf $(PROGNAME)-$(VERSION)
-
-.PHONY: doc
-
diff -Nru ocaml-dtools-0.4.1/Makefile.in ocaml-dtools-0.4.2/Makefile.in
--- ocaml-dtools-0.4.1/Makefile.in 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/Makefile.in 1970-01-01 00:00:00.000000000 +0000
@@ -1,45 +0,0 @@
-# Copyright 2003-2007 Savonet team
-
-SRC := src
-PROGNAME := ocaml-dtools
-DISTFILES := @AUTOCONF_INSTALL_FILES@ bootstrap CHANGES configure configure.ac \
- COPYING Makefile README Makefile.in \
- src/OCamlMakefile src/*Makefile.in src/META.in src/*.ml src/*.mli \
- doc/html
-VERSION := @VERSION@
-
-all:
- $(MAKE) -C $(SRC)
-
-clean:
- $(MAKE) -C $(SRC) clean
-
-install:
- $(MAKE) -C $(SRC) install
-
-uninstall:
- $(MAKE) -C $(SRC) uninstall
-
-update:
- $(MAKE) -C $(SRC) update
-
-distclean: clean
- rm -rf autom4te.cache config.log config.status
- rm -rf doc/html
- rm -f src/META src/Makefile
-
-doc:
- $(MAKE) -C src htdoc
- mkdir -p doc
- rm -rf doc/html
- mv src/doc/dtools/html doc
- rm -rf src/doc
-
-dist: doc
- mkdir $(PROGNAME)-$(VERSION)
- cp -R -L --parents $(DISTFILES) $(PROGNAME)-$(VERSION)
- tar zcvf ../$(PROGNAME)-$(VERSION).tar.gz $(PROGNAME)-$(VERSION)
- rm -rf $(PROGNAME)-$(VERSION)
-
-.PHONY: doc
-
diff -Nru ocaml-dtools-0.4.1/.ocamlformat ocaml-dtools-0.4.2/.ocamlformat
--- ocaml-dtools-0.4.1/.ocamlformat 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/.ocamlformat 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1,9 @@
+profile = conventional
+break-separators = after
+space-around-lists = false
+doc-comments = before
+match-indent = 2
+match-indent-nested = always
+parens-ite
+exp-grouping = preserve
+module-item-spacing = compact
diff -Nru ocaml-dtools-0.4.1/README ocaml-dtools-0.4.2/README
--- ocaml-dtools-0.4.1/README 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/README 1970-01-01 00:00:00.000000000 +0000
@@ -1,48 +0,0 @@
-OCaml-dtools - OCaml daemon tools library
-=======================================================
-
-Author: Gimenez Stéphane
-Email: savonet-users@lists.sourceforge.net
-Homepage: http://savonet.sourceforge.net/
-
-Copyright (c) 2003-2006 the Savonet Team.
-
-
-Dependencies
-============
-To build this library you need to have OCaml 3.07. or later (available at
-http://caml.inria.fr) and ocamlfind also called findlib (available at
-http://www.ocaml-programming.de/packages/)
-
-
-Installation
-============
-
-To compile the program type:
-
-./configure
-make
-
-You can set specific build options with the configure script, see:
-
-./configure --help
-
-To install it, type as root:
-
-make install
-
-License
-=======
-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, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
diff -Nru ocaml-dtools-0.4.1/README.md ocaml-dtools-0.4.2/README.md
--- ocaml-dtools-0.4.1/README.md 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/README.md 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1,62 @@
+OCaml-dtools - OCaml daemon tools library
+=======================================================
+
+Author: Gimenez Stéphane
+Email: savonet-users@lists.sourceforge.net
+Homepage: http://savonet.sourceforge.net/
+
+Copyright (c) 2003-2020 the Savonet Team.
+
+
+Dependencies
+============
+To build this library you need to have OCaml 3.07. or later (available at
+http://caml.inria.fr) and ocamlfind also called findlib (available at
+http://www.ocaml-programming.de/packages/)
+
+
+Installation
+============
+
+This module is provided as part of the [opam](http://opam.ocaml.org/packages/dtools/). Recommended
+installation method is via `opam`:
+
+```
+opam install dtools
+```
+
+This installs the latest released version of this module.
+
+To compile the code from this repository, type:
+
+```
+dune build
+```
+
+To install the code from this repository using `opam`, type:
+
+```
+opam install .
+```
+
+To instal the code from this repository using `dune`:
+
+```
+dune install
+```
+
+License
+=======
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
diff -Nru ocaml-dtools-0.4.1/src/dtools_impl.ml ocaml-dtools-0.4.2/src/dtools_impl.ml
--- ocaml-dtools-0.4.1/src/dtools_impl.ml 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/src/dtools_impl.ml 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1,856 @@
+(**************************************************************************)
+(* ocaml-dtools *)
+(* Copyright (C) 2003-2010 The Savonet Team *)
+(**************************************************************************)
+(* 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 *)
+(* any later version. *)
+(**************************************************************************)
+(* Contact: savonet-devl@lists.sourceforge.net *)
+(**************************************************************************)
+
+(* $Id$ *)
+
+(**
+ ocaml-dtools
+ @author Stephane Gimenez
+*)
+
+module Conf = struct
+ type link = string
+
+ type path = link list
+
+ and ut =
+ < kind : string option
+ ; descr : string
+ ; comments : string list
+ ; plug : string -> ut -> unit
+ ; subs : string list
+ ; path : string list -> ut
+ ; routes : ut -> path list
+ ; ut : ut >
+
+ type 'a t =
+ < kind : string option
+ ; alias : ?comments:string list -> ?descr:string -> (ut -> unit) -> 'a t
+ ; descr : string
+ ; comments : string list
+ ; plug : string -> ut -> unit
+ ; subs : string list
+ ; path : string list -> ut
+ ; routes : ut -> path list
+ ; ut : ut
+ ; set_d : 'a option -> unit
+ ; get_d : 'a option
+ ; set : 'a -> unit
+ ; get : 'a
+ ; validate : ('a -> bool) -> unit
+ ; on_change : ('a -> unit) -> unit >
+
+ type links = (string * ut) list
+
+ type 'a builder =
+ ?d:'a ->
+ ?p:(ut -> unit) ->
+ ?l:links ->
+ ?comments:string list ->
+ string ->
+ 'a t
+
+ exception Undefined of ut
+ exception Invalid of string
+ exception Unbound of ut * string
+ exception Bound of ut * string
+ exception Mismatch of ut
+ exception Wrong_Conf of string * string
+ exception File_Wrong_Conf of string * int * string
+ exception Cyclic of ut * ut
+ exception Invalid_Value of ut
+
+ let path_sep_regexp = Str.regexp "\\."
+ let list_sep_regexp = Str.regexp ":"
+
+ let line_regexp =
+ Str.regexp
+ "^[ \t]*\\([a-zA-Z]+\\)[ \t]+\\([a-zA-Z0-9._-]+\\)[ \t]*:\\(.*\\)$"
+
+ let comment_regexp = Str.regexp "^[ ]*\\(#.*\\)?$"
+ let check s = if Str.string_match path_sep_regexp s 0 then raise (Invalid s)
+
+ let make kind ?(d : 'a option) ?(p : ut -> unit = fun _ -> ())
+ ?(l : links = []) ?(comments : string list = []) descr : 'a t =
+ object (self)
+ val kind : string option = kind
+
+ val mutable descr : string = descr
+
+ val mutable comments : string list = comments
+
+ val mutable links : links = []
+
+ val value_d : 'a option ref = ref d
+
+ val value : 'a option ref = ref None
+
+ val mutable validators : ('a -> bool) list = []
+
+ val mutable listeners : ('a -> unit) list = []
+
+ initializer
+ p self#ut;
+ List.iter (fun (s, t) -> self#plug s t) l
+
+ method subs = List.sort compare (List.map fst links)
+
+ method private sub (s : string) : ut =
+ check s;
+ try List.assoc s links with Not_found -> raise (Unbound (self#ut, s))
+
+ method path (l : string list) : ut =
+ match l with [] -> self#ut | s :: q -> (self#sub s)#path q
+
+ method routes (st : ut) =
+ (* todo: cache already accessed nodes *)
+ let rec aux l t =
+ match t = st with
+ | true -> [List.rev l]
+ | false ->
+ List.concat
+ (List.map (fun s -> aux (s :: l) (t#path [s])) t#subs)
+ in
+ aux [] self#ut
+
+ method kind = kind
+
+ method descr = descr
+
+ method private set_descr new_descr = descr <- new_descr
+
+ method comments = comments
+
+ method private set_comments new_comments = comments <- new_comments
+
+ method plug s t =
+ if t#routes self#ut <> [] then raise (Cyclic (self#ut, t));
+ if List.mem_assoc s links then raise (Bound (self#ut, s));
+ links <- (s, t) :: links
+
+ (* Nice hack. heh! *)
+ method alias ?comments ?descr p =
+ let maybe f x = match x with Some x -> f x | None -> () in
+ let old_comments = self#comments in
+ let old_descr = self#descr in
+ maybe self#set_comments comments;
+ maybe self#set_descr descr;
+ let key = Oo.copy self in
+ p key#ut;
+ self#set_comments old_comments;
+ self#set_descr old_descr;
+ key
+
+ method ut = (self :> ut)
+
+ method get_d : 'a option = !value_d
+
+ method set_d (v : 'a option) : unit = value_d := v
+
+ method get : 'a =
+ match !value with
+ | None -> (
+ match !value_d with
+ | None -> raise (Undefined self#ut)
+ | Some v -> v )
+ | Some v -> v
+
+ method set (v : 'a) : unit =
+ List.iter
+ (fun fn -> if not (fn v) then raise (Invalid_Value self#ut))
+ validators;
+ value := Some v;
+ List.iter (fun fn -> fn v) listeners
+
+ method validate (fn : 'a -> bool) : unit = validators <- fn :: validators
+
+ method on_change (fn : 'a -> unit) : unit = listeners <- fn :: listeners
+ end
+
+ let void ?p ?l ?comments descr = (make None ?p ?l ~d:None ?comments descr)#ut
+ let unit ?d = make (Some "unit") ?d
+ let int ?d = make (Some "int") ?d
+ let float ?d = make (Some "float") ?d
+ let bool ?d = make (Some "bool") ?d
+ let string ?d = make (Some "string") ?d
+ let list ?d = make (Some "list") ?d
+
+ (* Harmful function, do not use *)
+ let force_type c (t : ut) : 'a t =
+ match t#kind with
+ | Some x when x = c -> (Obj.magic t : 'a t)
+ | _ -> raise (Mismatch t)
+
+ let as_unit t : unit t = force_type "unit" t
+ let as_int t : int t = force_type "int" t
+ let as_float t : float t = force_type "float" t
+ let as_bool t : bool t = force_type "bool" t
+ let as_string t : string t = force_type "string" t
+ let as_list t : string list t = force_type "list" t
+ let path_of_string p = Str.split path_sep_regexp p
+ let string_of_path p = String.concat "." p
+
+ let get_string (t : ut) =
+ try
+ match t#kind with
+ | None -> None
+ | Some "unit" -> Some ""
+ | Some "int" -> Some (string_of_int (as_int t)#get)
+ | Some "float" -> Some (string_of_float (as_float t)#get)
+ | Some "bool" -> Some (string_of_bool (as_bool t)#get)
+ | Some "string" -> Some (as_string t)#get
+ | Some "list" -> Some (String.concat ":" (as_list t)#get)
+ | _ -> assert false
+ with Undefined _ -> None
+
+ let get_d_string (t : ut) =
+ let mapopt f = function None -> None | Some x -> Some (f x) in
+ try
+ match t#kind with
+ | None -> None
+ | Some "unit" -> mapopt (fun () -> "") (as_unit t)#get_d
+ | Some "int" -> mapopt string_of_int (as_int t)#get_d
+ | Some "float" -> mapopt string_of_float (as_float t)#get_d
+ | Some "bool" -> mapopt string_of_bool (as_bool t)#get_d
+ | Some "string" -> (as_string t)#get_d
+ | Some "list" -> mapopt (String.concat ":") (as_list t)#get_d
+ | _ -> assert false
+ with Undefined _ -> None
+
+ let descr ?(prefix = []) (t : ut) =
+ let rec aux prefix t =
+ let p s = if prefix = "" then s else prefix ^ "." ^ s in
+ let subs = List.map (function s -> aux (p s) (t#path [s])) t#subs in
+ Printf.sprintf "## %s\n" t#descr
+ ^ begin
+ match get_d_string t with
+ | None -> ""
+ | Some d -> Printf.sprintf "# default :%s\n" d
+ end
+ ^ begin
+ match (t#kind, get_string t) with
+ | Some k, None -> Printf.sprintf "#%s\t%-30s\n" k prefix
+ | Some k, Some p -> Printf.sprintf "%s\t%-30s :%s\n" k prefix p
+ | _ -> ""
+ end
+ ^ begin
+ match t#comments with
+ | [] -> ""
+ | l ->
+ "# comments:\n"
+ ^ String.concat ""
+ (List.map (fun s -> Printf.sprintf "# %s\n" s) l)
+ end
+ ^ "\n" ^ String.concat "" subs
+ in
+ aux (string_of_path prefix) (t#path prefix)
+
+ let dump ?(prefix = []) (t : ut) =
+ let rec aux prefix t =
+ let p s = if prefix = "" then s else prefix ^ "." ^ s in
+ let subs = List.map (function s -> aux (p s) (t#path [s])) t#subs in
+ begin
+ match t#kind with
+ | Some k -> (
+ match (get_d_string t, get_string t) with
+ | None, None -> Printf.sprintf "#%s\t%-30s\n" k prefix
+ | Some p, None -> Printf.sprintf "#%s\t%-30s :%s\n" k prefix p
+ | Some p, Some p' when p' = p ->
+ Printf.sprintf "#%s\t%-30s :%s\n" k prefix p
+ | _, Some p -> Printf.sprintf "%s\t%-30s :%s\n" k prefix p )
+ | _ -> ""
+ end
+ ^ String.concat "" subs
+ in
+ aux (string_of_path prefix) (t#path prefix)
+
+ let conf_set (t : ut) s =
+ if Str.string_match line_regexp s 0 then (
+ let val0 = Str.matched_group 1 s in
+ let val1 = Str.matched_group 2 s in
+ let val2 = Str.matched_group 3 s in
+ let st = t#path (path_of_string val1) in
+ match val0 with
+ | "unit" -> (
+ match val2 = "" with
+ | false -> raise (Wrong_Conf (s, "unit expected"))
+ | true -> (as_unit st)#set () )
+ | "int" ->
+ let i =
+ try int_of_string val2
+ with Invalid_argument _ ->
+ raise (Wrong_Conf (s, "integer expected"))
+ in
+ (as_int st)#set i
+ | "float" ->
+ let f =
+ try float_of_string val2
+ with Invalid_argument _ ->
+ raise (Wrong_Conf (s, "float expected"))
+ in
+ (as_float st)#set f
+ | "bool" ->
+ let b =
+ try bool_of_string val2
+ with Invalid_argument _ ->
+ raise (Wrong_Conf (s, "boolean expected"))
+ in
+ (as_bool st)#set b
+ | "string" ->
+ let s = val2 in
+ (as_string st)#set s
+ | "list" ->
+ let l = Str.split list_sep_regexp val2 in
+ (as_list st)#set l
+ | _ -> raise (Wrong_Conf (s, "unknown type")) )
+ else raise (Wrong_Conf (s, "syntax error"))
+
+ let conf_file t s =
+ let nb = ref 0 in
+ let f = open_in s in
+ try
+ while true do
+ nb := !nb + 1;
+ let l = input_line f in
+ if Str.string_match comment_regexp l 0 then ()
+ else begin
+ try conf_set t l
+ with Wrong_Conf (_, y) -> raise (File_Wrong_Conf (s, !nb, y))
+ end
+ done
+ with End_of_file -> ()
+
+ let args t =
+ [
+ ( ["--conf-file"; "-f"],
+ Arg.String (conf_file t),
+ "read the given configuration file" );
+ ( ["--conf-set"; "-s"],
+ Arg.String (conf_set t),
+ "apply the given configuration assignation" );
+ ( ["--conf-descr-key"],
+ Arg.String
+ (fun p ->
+ Printf.printf "%s" (descr ~prefix:(path_of_string p) t);
+ exit 0),
+ "describe a configuration key" );
+ ( ["--conf-descr"],
+ Arg.Unit
+ (fun () ->
+ Printf.printf "%s" (descr t);
+ exit 0),
+ "display a described table of the configuration keys" );
+ ( ["--conf-dump"],
+ Arg.Unit
+ (fun () ->
+ Printf.printf "%s" (dump t);
+ exit 0),
+ "dump the configuration state" );
+ ]
+end
+
+module Init = struct
+ let conf = Conf.void "initialization configuration"
+
+ (* Unix.fork is not implemented in Win32. *)
+ let daemon_conf =
+ if Sys.os_type <> "Win32" then conf else Conf.void "dummy conf"
+
+ let conf_daemon =
+ Conf.bool ~p:(daemon_conf#plug "daemon") ~d:false "run in daemon mode"
+
+ let conf_daemon_pidfile =
+ Conf.bool
+ ~p:(conf_daemon#plug "pidfile")
+ ~d:false "support for pidfile generation"
+
+ let conf_daemon_pidfile_path =
+ Conf.string ~p:(conf_daemon_pidfile#plug "path") "path to pidfile"
+
+ let conf_daemon_drop_user =
+ Conf.bool
+ ~p:(conf_daemon#plug "change_user")
+ ~d:false "Changes the effective user (drops privileges)."
+
+ let conf_daemon_user =
+ Conf.string
+ ~p:(conf_daemon_drop_user#plug "user")
+ ~d:"daemon" "User used to run the daemon."
+
+ let conf_daemon_group =
+ Conf.string
+ ~p:(conf_daemon_drop_user#plug "group")
+ ~d:"daemon" "Group used to run the daemon."
+
+ let conf_trace =
+ Conf.bool ~p:(conf#plug "trace") ~d:false "dump an initialization trace"
+
+ let conf_concurrent =
+ Conf.bool ~p:(conf#plug "concurrent") ~d:false
+ "run initialization using concurrent threads"
+
+ let conf_catch_exn =
+ Conf.bool ~p:(conf#plug "catch_exn") ~d:true
+ "catch exceptions, use false to backtrace exceptions"
+
+ type t = {
+ name : string;
+ mutable launched : bool;
+ mutable depends : t list;
+ mutable triggers : t list;
+ mutable mutex : Mutex.t;
+ f : unit -> unit;
+ }
+
+ let make ?(name = "") ?(depends = []) ?(triggers = []) ?(after = [])
+ ?(before = []) f =
+ let na =
+ { name; launched = false; depends; triggers; mutex = Mutex.create (); f }
+ in
+ List.iter (fun a -> a.triggers <- na :: a.triggers) after;
+ List.iter (fun a -> a.depends <- na :: a.depends) before;
+ na
+
+ let start = make ~name:"init-start" flush_all
+ let stop = make ~name:"init-stop" flush_all
+
+ let at_start ?name ?depends ?triggers ?after ?before f =
+ let a = make ?name ?depends ?triggers ?after ?before f in
+ start.triggers <- a :: start.triggers;
+ a
+
+ let at_stop ?name ?depends ?triggers ?after ?before f =
+ let a = make ?name ?depends ?triggers ?after ?before f in
+ stop.depends <- a :: stop.depends;
+ a
+
+ let exec a =
+ let log =
+ if conf_trace#get then fun s ->
+ let id = Thread.id (Thread.self ()) in
+ Printf.printf "init(%i):%-35s@%s\n%!" id a.name s
+ else fun _ -> ()
+ in
+ let rec exec a =
+ log "called";
+ Mutex.lock a.mutex;
+ try
+ if not a.launched then begin
+ a.launched <- true;
+ log "start";
+ log "start-depends";
+ mult_exec a.depends;
+ log "stop-depends";
+ log "start-atom";
+ a.f ();
+ log "stop-atom";
+ log "start-triggers";
+ mult_exec a.triggers;
+ log "stop-triggers";
+ log "stop"
+ end;
+ Mutex.unlock a.mutex;
+ log "return"
+ with e ->
+ Mutex.unlock a.mutex;
+ raise e
+ and mult_exec l =
+ match conf_concurrent#get with
+ | true ->
+ let ask x =
+ log (Printf.sprintf "exec %s" x.name);
+ Thread.create exec x
+ in
+ let threads = List.map ask l in
+ List.iter Thread.join threads
+ | false -> List.iter exec l
+ in
+ exec a
+
+ let rec wait_signal () =
+ try ignore (Thread.wait_signal [Sys.sigterm; Sys.sigint]) with
+ | Unix.Unix_error (Unix.EINTR, _, _) -> ()
+ | Sys_error s when s = "Thread.wait_signal: Interrupted system call" ->
+ wait_signal ()
+
+ exception StartError of exn
+ exception StopError of exn
+
+ (* Dummy functions in the case where
+ * Printexc does not have the required
+ * functions. *)
+ let get_backtrace () =
+ "ocaml-dtools not compiled with ocaml >= 3.11, cannot print stack backtrace"
+
+ (* For the compiler.. *)
+ let () = ignore (get_backtrace ())
+
+ open Printexc
+
+ let main f () =
+ begin
+ try exec start with e -> raise (StartError e)
+ end;
+ let quit pid = if Sys.os_type <> "Win32" then Unix.kill pid Sys.sigterm in
+ let thread pid =
+ try
+ f ();
+ quit pid
+ with e ->
+ let se = Printexc.to_string e in
+ Printf.eprintf
+ "init: exception encountered during main phase:\n %s\n%!" se;
+ Printf.eprintf "exception: %s\n%s%!" se (get_backtrace ());
+ if conf_catch_exn#get then quit pid else raise e
+ in
+ let th = Thread.create thread (Unix.getpid ()) in
+ if Sys.os_type <> "Win32" then wait_signal () else Thread.join th;
+ try exec stop with e -> raise (StopError e)
+
+ let catch f clean =
+ try
+ f ();
+ clean ()
+ with
+ | StartError e ->
+ Printf.eprintf
+ "init: exception encountered during start phase:\n %s\n%!"
+ (Printexc.to_string e);
+ clean ();
+ exit (-1)
+ | StopError e ->
+ Printf.eprintf
+ "init: exception encountered during stop phase:\n %s\n%!"
+ (Printexc.to_string e);
+ clean ();
+ exit (-1)
+
+ (** A function to reopen a file descriptor
+ * Thanks to Xavier Leroy!
+ * Ref: http://caml.inria.fr/pub/ml-archives/caml-list/2000/01/
+ * a7e3bbdfaab33603320d75dbdcd40c37.en.html
+ *)
+ let reopen_out outchan filename =
+ flush outchan;
+ let fd1 = Unix.descr_of_out_channel outchan in
+ let fd2 = Unix.openfile filename [Unix.O_WRONLY] 0o666 in
+ Unix.dup2 fd2 fd1;
+ Unix.close fd2
+
+ (** The same for inchan *)
+ let reopen_in inchan filename =
+ let fd1 = Unix.descr_of_in_channel inchan in
+ let fd2 = Unix.openfile filename [Unix.O_RDONLY] 0o666 in
+ Unix.dup2 fd2 fd1;
+ Unix.close fd2
+
+ let daemonize () =
+ if Unix.fork () <> 0 then exit 0;
+ (* Dettach from the console *)
+ if Unix.setsid () < 0 then exit 1;
+ (* Refork.. *)
+ if Unix.fork () <> 0 then exit 0;
+ (* Change umask to 0 *)
+ ignore (Unix.umask 0);
+ (* chdir to / *)
+ Unix.chdir "/";
+ if conf_daemon_pidfile#get then begin
+ (* Write PID to file *)
+ let filename = conf_daemon_pidfile_path#get in
+ let f = open_out filename in
+ let pid = Unix.getpid () in
+ output_string f (string_of_int pid);
+ output_char f '\n';
+ close_out f
+ end;
+ (* Reopen usual file descriptor *)
+ reopen_in stdin "/dev/null";
+ reopen_out stdout "/dev/null";
+ reopen_out stderr "/dev/null"
+
+ let cleanup_daemon () =
+ if conf_daemon_pidfile#get then (
+ try
+ let filename = conf_daemon_pidfile_path#get in
+ Sys.remove filename
+ with _ -> () )
+
+ exception Root_prohibited of [ `User | `Group | `Both ]
+
+ let exit_when_root () =
+ (* Change user.. *)
+ if conf_daemon_drop_user#get then begin
+ let grd = Unix.getgrnam conf_daemon_group#get in
+ let gid = grd.Unix.gr_gid in
+ if Unix.getegid () <> gid then Unix.setgid gid;
+ let pwd = Unix.getpwnam conf_daemon_user#get in
+ let uid = pwd.Unix.pw_uid in
+ if Unix.geteuid () <> uid then Unix.setuid uid
+ end;
+ match (Unix.geteuid (), Unix.getegid ()) with
+ | 0, 0 -> raise (Root_prohibited `Both)
+ | 0, _ -> raise (Root_prohibited `User)
+ | _, 0 -> raise (Root_prohibited `Group)
+ | _ -> ()
+
+ let init ?(prohibit_root = false) f =
+ if prohibit_root then exit_when_root ();
+ if conf_daemon#get && Sys.os_type <> "Win32" then daemonize ();
+ let signal_h _ = () in
+ Sys.set_signal Sys.sigterm (Sys.Signal_handle signal_h);
+ Sys.set_signal Sys.sigint (Sys.Signal_handle signal_h);
+ (* We block signals that would kill us,
+ * we'll wait for them and shutdown cleanly.
+ * On Windows this is impossible so the only way for the application
+ * to shutdown is to terminate the main function [f]. *)
+ if Sys.os_type <> "Win32" then
+ ignore (Unix.sigprocmask Unix.SIG_BLOCK [Sys.sigterm; Sys.sigint]);
+ let cleanup =
+ if conf_daemon#get && Sys.os_type <> "Win32" then cleanup_daemon
+ else fun () -> ()
+ in
+ catch (main f) cleanup
+
+ let args =
+ if Sys.os_type <> "Win32" then
+ [
+ ( ["--daemon"; "-d"],
+ Arg.Unit (fun () -> conf_daemon#set true),
+ "run in daemon mode" );
+ ]
+ else []
+end
+
+module Log = struct
+ type t =
+ < active : int -> bool
+ ; f : 'a. int -> ('a, unit, string, unit) format4 -> 'a >
+
+ type custom_log = { timestamp : bool; exec : string -> unit }
+
+ let log_ch = ref None
+
+ (* Custom logging methods. *)
+ let custom_log : (string, custom_log) Hashtbl.t = Hashtbl.create 0
+ let add_custom_log name f = Hashtbl.replace custom_log name f
+ let rm_custom_log name = Hashtbl.remove custom_log name
+ let conf = Conf.void "log configuration"
+ let conf_level = Conf.int ~p:(conf#plug "level") ~d:3 "general log level"
+
+ let conf_unix_timestamps =
+ Conf.bool
+ ~p:(conf#plug "unix_timestamps")
+ ~d:false
+ "display unix timestamps (subsecond accuracy, timezone independant)"
+
+ let conf_file = Conf.bool ~p:(conf#plug "file") ~d:true "log to file"
+ let conf_file_path = Conf.string ~p:(conf_file#plug "path") "path to log file"
+
+ let conf_file_append =
+ Conf.bool ~p:(conf_file#plug "append") ~d:true "append log to the file"
+
+ let conf_file_perms =
+ Conf.int ~p:(conf_file#plug "perms") ~d:0o600 "log file permissions"
+
+ let conf_stdout = Conf.bool ~p:(conf#plug "stdout") ~d:false "log to stdout"
+
+ let timestamp time =
+ match conf_unix_timestamps#get with
+ | true -> Printf.sprintf "%f" time
+ | false ->
+ let date = Unix.localtime time in
+ Printf.sprintf "%d/%02d/%02d %02d:%02d:%02d"
+ (date.Unix.tm_year + 1900) (date.Unix.tm_mon + 1) date.Unix.tm_mday
+ date.Unix.tm_hour date.Unix.tm_min date.Unix.tm_sec
+
+ let print (time, str) =
+ let to_stdout = conf_stdout#get in
+ let to_file = !log_ch <> None in
+ let timestamp = timestamp time in
+ let message = Printf.sprintf "%s %s" timestamp str in
+ begin
+ match to_stdout || to_file with
+ | true ->
+ let do_stdout () = Printf.printf "%s\n%!" message in
+ let do_file () =
+ match !log_ch with
+ | None -> ()
+ | Some ch -> Printf.fprintf ch "%s\n%!" message
+ in
+ if to_stdout then do_stdout ();
+ if to_file then do_file ()
+ | false -> ()
+ end;
+ let f _ x = x.exec (if x.timestamp then message else str) in
+ Hashtbl.iter f custom_log
+
+ (* Avoid interlacing logs *)
+ let log_mutex = Mutex.create ()
+ let log_condition = Condition.create ()
+ let log_queue = ref (Queue.create ())
+ let log_stop = ref false
+ let log_thread = ref None
+
+ let mutexify f x =
+ Mutex.lock log_mutex;
+ try
+ let ret = f x in
+ Mutex.unlock log_mutex;
+ ret
+ with e ->
+ Mutex.unlock log_mutex;
+ raise e
+
+ let rotate_queue () =
+ let new_q = Queue.create () in
+ mutexify
+ (fun () ->
+ let q = !log_queue in
+ log_queue := new_q;
+ q)
+ ()
+
+ let flush_queue () =
+ let rec flush q =
+ Queue.iter print q;
+ let q = rotate_queue () in
+ if not (Queue.is_empty q) then flush q
+ in
+ flush (rotate_queue ())
+
+ let log_thread_fn () =
+ let rec f () =
+ flush_queue ();
+ let log_stop =
+ mutexify
+ (fun () ->
+ if !log_stop then true
+ else begin
+ Condition.wait log_condition log_mutex;
+ !log_stop
+ end)
+ ()
+ in
+ if not log_stop then f ()
+ in
+ f ()
+
+ let proceed =
+ mutexify (fun entry ->
+ Queue.push entry !log_queue;
+ Condition.signal log_condition)
+
+ let build path =
+ let rec aux p l (t : Conf.ut) =
+ match p with
+ | [] -> t :: l
+ | s :: q ->
+ let st =
+ try t#path [s]
+ with Conf.Unbound _ ->
+ let c = Conf.int ~p:(t#plug s) "subordinate log level" in
+ c#ut
+ in
+ aux q (t :: l) st
+ in
+ aux path [] conf_level#ut
+
+ let make path : t =
+ let confs = build path in
+ let path_str = Conf.string_of_path path in
+ object (self : t)
+ val label = fun lvl -> "[" ^ path_str ^ ":" ^ string_of_int lvl ^ "]"
+
+ method active lvl =
+ let rec aux l =
+ match l with
+ | [] -> None
+ | t :: q -> (
+ match aux q with
+ | Some i -> Some i
+ | None -> (
+ try Some (Conf.as_int t)#get
+ with Conf.Undefined _ -> None ) )
+ in
+ match aux confs with None -> false | Some i -> i >= lvl
+
+ method f lvl =
+ match self#active lvl with
+ | true ->
+ let time = Unix.gettimeofday () in
+ Printf.ksprintf (fun s -> proceed (time, label lvl ^ " " ^ s))
+ | false -> Printf.ksprintf (fun _ -> ())
+ end
+
+ let init () =
+ let time = Unix.gettimeofday () in
+ let reopen_log =
+ if conf_file#get then begin
+ let opts =
+ [Open_wronly; Open_creat; Open_nonblock]
+ @ if conf_file_append#get then [Open_append] else [Open_trunc]
+ in
+ let log_file_path = conf_file_path#get in
+ let log_file_perms = conf_file_perms#get in
+ log_ch := Some (open_out_gen opts log_file_perms log_file_path);
+ fun _ ->
+ begin
+ match !log_ch with
+ | None -> ()
+ | Some ch ->
+ log_ch := None;
+ close_out ch
+ end;
+ log_ch := Some (open_out_gen opts log_file_perms log_file_path)
+ end
+ else fun _ -> ()
+ in
+ (* Re-open log file on SIGUSR1 -- for logrotate *)
+ if Sys.os_type <> "Win32" then
+ Sys.set_signal Sys.sigusr1 (Sys.Signal_handle reopen_log);
+ print (time, ">>> LOG START");
+ log_thread := Some (Thread.create log_thread_fn ())
+
+ let start = Init.make ~name:"init-log-start" ~before:[Init.start] init
+
+ let close () =
+ let time = Unix.gettimeofday () in
+ mutexify (fun () -> log_stop := true) ();
+ proceed (time, ">>> LOG END");
+ begin
+ match !log_thread with
+ | None -> ()
+ | Some th ->
+ Condition.signal log_condition;
+ Thread.join th
+ end;
+ match !log_ch with
+ | None -> ()
+ | Some ch ->
+ log_ch := None;
+ close_out ch
+
+ let stop = Init.make ~name:"init-log-stop" ~after:[Init.stop] close
+
+ let args =
+ [
+ ( ["--log-stdout"],
+ Arg.Unit (fun () -> conf_stdout#set true),
+ "log also to stdout" );
+ ( ["--log-file"; "-l"],
+ Arg.String
+ (fun s ->
+ conf_file#set true;
+ conf_file_path#set s),
+ "log file" );
+ ]
+end
diff -Nru ocaml-dtools-0.4.1/src/dtools.ml ocaml-dtools-0.4.2/src/dtools.ml
--- ocaml-dtools-0.4.1/src/dtools.ml 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/src/dtools.ml 2020-03-28 00:34:27.000000000 +0000
@@ -1,957 +1,21 @@
-
- (**************************************************************************)
- (* ocaml-dtools *)
- (* Copyright (C) 2003-2010 The Savonet Team *)
- (**************************************************************************)
- (* 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 *)
- (* any later version. *)
- (**************************************************************************)
- (* Contact: savonet-devl@lists.sourceforge.net *)
- (**************************************************************************)
+(**************************************************************************)
+(* ocaml-dtools *)
+(* Copyright (C) 2003-2010 The Savonet Team *)
+(**************************************************************************)
+(* 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 *)
+(* any later version. *)
+(**************************************************************************)
+(* Contact: savonet-devl@lists.sourceforge.net *)
+(**************************************************************************)
(* $Id$ *)
(**
- ocaml-dtools
+ ocaml-dtools.
@author Stephane Gimenez
*)
-module Conf =
-struct
-
- type link = string
- type path = link list
-
- and ut =
- <
- kind: string option;
- descr: string;
- comments: string list;
- plug: string -> ut -> unit;
- subs: string list;
- path: string list -> ut;
- routes: ut -> path list;
- ut: ut;
- >
-
- type 'a t =
- <
- kind: string option;
- alias:
- ?comments:string list ->
- ?descr:string ->
- (ut -> unit) -> 'a t;
- descr: string;
- comments: string list;
- plug: string -> ut -> unit;
- subs: string list;
- path: string list -> ut;
- routes: ut -> path list;
- ut: ut;
- set_d: 'a option -> unit;
- get_d: 'a option;
- set: 'a -> unit;
- get: 'a;
- on_change: ('a -> unit) -> unit
- >
-
- type links = (string * ut) list
-
- type 'a builder =
- ?d:'a ->
- ?p:(ut -> unit) ->
- ?l:links ->
- ?comments:string list ->
- string -> 'a t
-
- exception Undefined of ut
- exception Invalid of string
- exception Unbound of ut * string
- exception Bound of ut * string
- exception Mismatch of ut
- exception Wrong_Conf of string * string
- exception File_Wrong_Conf of string * int * string
- exception Cyclic of ut * ut
-
- let path_sep_regexp =
- Str.regexp "\\."
- let list_sep_regexp =
- Str.regexp ":"
- let line_regexp =
- Str.regexp
- "^[ \t]*\\([a-zA-Z]+\\)[ \t]+\\([a-zA-Z0-9._-]+\\)[ \t]*:\\(.*\\)$"
- let comment_regexp =
- Str.regexp "^[ ]*\\(#.*\\)?$"
-
- let check s =
- if Str.string_match path_sep_regexp s 0 then raise (Invalid (s))
-
- let make kind
- ?(d : 'a option)
- ?(p : ut -> unit = fun _ -> ())
- ?(l : links = [])
- ?(comments : string list = [])
- descr
- : 'a t =
- object (self)
-
- val kind : string option = kind
- val mutable descr : string = descr
- val mutable comments : string list = comments
-
- val mutable links : links = []
-
- val value_d : 'a option ref = ref d
- val value : 'a option ref = ref None
-
- val mutable listeners : ('a -> unit) list = []
-
- initializer
- p self#ut;
- List.iter (fun (s, t) -> self#plug s t) l
-
- method subs =
- List.sort compare (List.map fst links)
-
- method private sub (s : string) : ut =
- check s;
- begin try
- List.assoc s links
- with
- | Not_found -> raise (Unbound (self#ut, s))
- end
-
- method path (l : string list) : ut =
- begin match l with
- | [] -> self#ut
- | s :: q -> (self#sub s)#path q
- end
-
- method routes (st : ut) =
- (* todo: cache already accessed nodes *)
- let rec aux l t =
- begin match t = st with
- | true -> [List.rev l]
- | false ->
- List.concat (List.map (fun s -> aux (s :: l) (t#path [s])) t#subs)
- end
- in
- aux [] self#ut
-
- method kind = kind
-
- method descr = descr
- method private set_descr new_descr =
- descr <- new_descr
-
- method comments = comments
- method private set_comments new_comments =
- comments <- new_comments
-
- method plug s t =
- if t#routes self#ut <> [] then raise (Cyclic (self#ut, t));
- if List.mem_assoc s links then raise (Bound (self#ut, s));
- links <- (s, t) :: links
-
- (* Nice hack. heh! *)
- method alias ?comments ?descr p =
- let maybe f x =
- match x with
- | Some x -> f x
- | None -> ()
- in
- let old_comments = self#comments in
- let old_descr = self#descr in
- maybe self#set_comments comments ;
- maybe self#set_descr descr ;
- let key = Oo.copy self in
- p key#ut ;
- self#set_comments old_comments;
- self#set_descr old_descr;
- key
-
- method ut = (self :> ut)
-
- method get_d : 'a option = !value_d
-
- method set_d (v : 'a option) : unit = value_d := v
-
- method get : 'a =
- begin match !value with
- | None ->
- begin match !value_d with
- | None -> raise (Undefined (self#ut))
- | Some v -> v
- end
- | Some v -> v
- end
-
- method set (v : 'a) : unit =
- value := Some v;
- List.iter (fun fn -> fn v) listeners
-
- method on_change (fn : 'a -> unit) : unit =
- listeners <- fn::listeners
-
- end
-
- let void ?p ?l ?comments descr =
- (make None ?p ?l ~d:None ?comments descr)#ut
-
- let unit ?d = make (Some "unit") ?d
- let int ?d = make (Some "int") ?d
- let float ?d = make (Some "float") ?d
- let bool ?d = make (Some "bool") ?d
- let string ?d = make (Some "string") ?d
- let list ?d = make (Some "list") ?d
-
- (* Harmful function, do not use *)
- let force_type c (t : ut) : 'a t =
- begin match t#kind with
- | Some x when x = c -> (Obj.magic t : 'a t)
- | _ -> raise (Mismatch (t))
- end
-
- let as_unit t : unit t = force_type "unit" t
- let as_int t : int t = force_type "int" t
- let as_float t : float t = force_type "float" t
- let as_bool t : bool t = force_type "bool" t
- let as_string t : string t = force_type "string" t
- let as_list t : string list t = force_type "list" t
-
- let path_of_string p =
- Str.split path_sep_regexp p
- let string_of_path p =
- String.concat "." p
-
- let get_string (t : ut) =
- begin try
- begin match t#kind with
- | None -> None
- | Some "unit" -> Some ("")
- | Some "int" -> Some (string_of_int (as_int t)#get)
- | Some "float" -> Some (string_of_float (as_float t)#get)
- | Some "bool" -> Some (string_of_bool (as_bool t)#get)
- | Some "string" -> Some ((as_string t)#get)
- | Some "list" -> Some (String.concat ":" (as_list t)#get)
- | _ -> assert false
- end
- with
- | Undefined _ -> None
- end
-
- let get_d_string (t : ut) =
- let mapopt f = (function None -> None | Some x -> Some (f x)) in
- begin try
- begin match t#kind with
- | None -> None
- | Some "unit" -> mapopt (fun () -> "") (as_unit t)#get_d
- | Some "int" -> mapopt string_of_int (as_int t)#get_d
- | Some "float" -> mapopt string_of_float (as_float t)#get_d
- | Some "bool" -> mapopt string_of_bool (as_bool t)#get_d
- | Some "string" -> (as_string t)#get_d
- | Some "list" -> mapopt (String.concat ":") (as_list t)#get_d
- | _ -> assert false
- end
- with
- | Undefined _ -> None
- end
-
- let descr ?(prefix=[]) (t : ut) =
- let rec aux prefix t =
- let p s = if prefix = "" then s else prefix ^ "." ^ s in
- let subs =
- List.map (function s -> aux (p s) (t#path [s])) t#subs
- in
- Printf.sprintf "## %s\n" t#descr ^
- begin match get_d_string t with
- | None -> ""
- | Some d -> Printf.sprintf "# default :%s\n" d
- end ^
- begin match t#kind, get_string t with
- | Some k, None ->
- Printf.sprintf "#%s\t%-30s\n" k prefix
- | Some k, Some p ->
- Printf.sprintf "%s\t%-30s :%s\n" k prefix p
- | _ -> ""
- end ^
- begin match t#comments with
- | [] -> ""
- | l ->
- "# comments:\n" ^
- String.concat "" (List.map (fun s -> Printf.sprintf "# %s\n" s) l)
- end ^
- "\n" ^ String.concat "" subs
- in
- aux (string_of_path prefix) (t#path prefix)
-
- let dump ?(prefix=[]) (t : ut) =
- let rec aux prefix t =
- let p s = if prefix = "" then s else prefix ^ "." ^ s in
- let subs =
- List.map (function s -> aux (p s) (t#path [s])) t#subs
- in
- begin match t#kind with
- | Some k ->
- begin match get_d_string t, get_string t with
- | None, None ->
- Printf.sprintf "#%s\t%-30s\n" k prefix
- | Some p, None ->
- Printf.sprintf "#%s\t%-30s :%s\n" k prefix p
- | Some p, Some p' when p' = p ->
- Printf.sprintf "#%s\t%-30s :%s\n" k prefix p
- | _, Some p ->
- Printf.sprintf "%s\t%-30s :%s\n" k prefix p
- end
- | _ -> ""
- end ^
- String.concat "" subs
- in
- aux (string_of_path prefix) (t#path prefix)
-
- let conf_set (t: ut) s =
- if Str.string_match line_regexp s 0
- then
- let val0 = Str.matched_group 1 s in
- let val1 = Str.matched_group 2 s in
- let val2 = Str.matched_group 3 s in
- let st = t#path (path_of_string val1) in
- begin match val0 with
- | "unit" ->
- begin match val2 = "" with
- | false -> raise (Wrong_Conf (s, "unit expected"))
- | true -> (as_unit st)#set ()
- end
- | "int" ->
- let i =
- begin try int_of_string val2 with
- | Invalid_argument _ ->
- raise (Wrong_Conf (s, "integer expected"))
- end
- in
- (as_int st)#set i
- | "float" ->
- let f =
- begin try float_of_string val2 with
- | Invalid_argument _ ->
- raise (Wrong_Conf (s, "float expected"))
- end
- in
- (as_float st)#set f
- | "bool" ->
- let b =
- begin try bool_of_string val2 with
- | Invalid_argument _ ->
- raise (Wrong_Conf (s, "boolean expected"))
- end
- in
- (as_bool st)#set b
- | "string" ->
- let s = val2 in
- (as_string st)#set s
- | "list" ->
- let l = Str.split list_sep_regexp val2 in
- (as_list st)#set l
- | _ -> raise (Wrong_Conf (s, "unknown type"))
- end
- else raise (Wrong_Conf (s, "syntax error"))
-
- let conf_file t s =
- let nb = Pervasives.ref 0 in
- let f = open_in s in
- begin try
- while true do
- nb := !nb + 1;
- let l = input_line f in
- if Str.string_match comment_regexp l 0
- then ()
- else
- begin try conf_set t l with
- | Wrong_Conf (_,y) ->
- raise (File_Wrong_Conf (s,!nb,y))
- end
- done
- with
- | End_of_file -> ()
- end
-
- let args t =
- [
- ["--conf-file";"-f"],
- Arg.String (conf_file t),
- "read the given configuration file";
- ["--conf-set";"-s"],
- Arg.String (conf_set t),
- "apply the given configuration assignation";
- ["--conf-descr-key"],
- Arg.String (fun p ->
- Printf.printf "%s" (descr ~prefix:(path_of_string p) t); exit 0),
- "describe a configuration key";
- ["--conf-descr"],
- Arg.Unit (fun () ->
- Printf.printf "%s" (descr t); exit 0),
- "display a described table of the configuration keys";
- ["--conf-dump"],
- Arg.Unit (fun () ->
- Printf.printf "%s" (dump t); exit 0),
- "dump the configuration state";
- ]
-
-end
-
-module Init =
-struct
-
- let conf =
- Conf.void "initialization configuration"
- (* Unix.fork is not implemented in Win32. *)
- let daemon_conf =
- if Sys.os_type <> "Win32" then conf
- else Conf.void "dummy conf"
- let conf_daemon =
- Conf.bool ~p:(daemon_conf#plug "daemon") ~d:false
- "run in daemon mode"
- let conf_daemon_pidfile =
- Conf.bool ~p:(conf_daemon#plug "pidfile") ~d:false
- "support for pidfile generation"
- let conf_daemon_pidfile_path =
- Conf.string ~p:(conf_daemon_pidfile#plug "path")
- "path to pidfile"
- let conf_daemon_drop_user =
- Conf.bool ~p:(conf_daemon#plug "change_user") ~d:false
- "Changes the effective user (drops privileges)."
- let conf_daemon_user =
- Conf.string ~p:(conf_daemon_drop_user#plug "user")
- ~d:"daemon" "User used to run the daemon."
- let conf_daemon_group =
- Conf.string ~p:(conf_daemon_drop_user#plug "group")
- ~d:"daemon" "Group used to run the daemon."
- let conf_trace =
- Conf.bool ~p:(conf#plug "trace") ~d:false
- "dump an initialization trace"
- let conf_concurrent =
- Conf.bool ~p:(conf#plug "concurrent") ~d:false
- "run initialization using concurrent threads"
- let conf_catch_exn =
- Conf.bool ~p:(conf#plug "catch_exn") ~d:true
- "catch exceptions, use false to backtrace exceptions"
-
- type t =
- {
- name: string;
- mutable launched: bool;
- mutable depends: t list;
- mutable triggers: t list;
- mutable mutex: Mutex.t;
- f: unit -> unit;
- }
-
- let make ?(name="") ?(depends=[]) ?(triggers=[]) ?(after=[]) ?(before=[]) f =
- let na =
- {
- name = name;
- launched = false;
- depends = depends;
- triggers = triggers;
- mutex = Mutex.create ();
- f = f;
- }
- in
- List.iter (fun a -> a.triggers <- na :: a.triggers) after;
- List.iter (fun a -> a.depends <- na :: a.depends) before;
- na
-
- let start = make ~name:"init-start" flush_all
-
- let stop = make ~name:"init-stop" flush_all
-
- let at_start ?name ?depends ?triggers ?after ?before f =
- let a = make ?name ?depends ?triggers ?after ?before f in
- start.triggers <- a :: start.triggers;
- a
-
- let at_stop ?name ?depends ?triggers ?after ?before f =
- let a = make ?name ?depends ?triggers ?after ?before f in
- stop.depends <- a :: stop.depends;
- a
-
- let exec a =
- let log =
- if conf_trace#get then
- begin fun s ->
- let id = Thread.id (Thread.self ()) in
- Printf.printf "init(%i):%-35s@%s\n%!" id a.name s
- end
- else begin fun _ -> () end
- in
- let rec exec a =
- log "called";
- Mutex.lock a.mutex;
- try
- if not a.launched
- then begin
- a.launched <- true;
- log "start";
- log "start-depends";
- mult_exec a.depends;
- log "stop-depends";
- log "start-atom";
- a.f ();
- log "stop-atom";
- log "start-triggers";
- mult_exec a.triggers;
- log "stop-triggers";
- log "stop";
- end;
- Mutex.unlock a.mutex;
- log "return"
- with e -> Mutex.unlock a.mutex; raise e
- and mult_exec l =
- begin match conf_concurrent#get with
- | true ->
- let ask x =
- log (Printf.sprintf "exec %s" x.name);
- Thread.create exec x
- in
- let threads = List.map ask l in
- List.iter Thread.join threads
- | false -> List.iter exec l
- end
- in
- exec a
-
- let rec wait_signal () =
- begin try
- ignore (Thread.wait_signal [Sys.sigterm; Sys.sigint]);
- with
- | Unix.Unix_error (Unix.EINTR,_,_) -> ()
- | Sys_error("Thread.wait_signal: Interrupted system call") ->
- wait_signal ()
- end
-
- exception StartError of exn
- exception StopError of exn
-
- (* Dummy functions in the case where
- * Printexc does not have the required
- * functions. *)
- let get_backtrace () =
- "ocaml-dtools not compiled with ocaml >= 3.11, \
- cannot print stack backtrace"
-
- (* For the compiler.. *)
- let () = ignore (get_backtrace ())
-
- open Printexc
-
- let main f () =
- begin try exec start with e -> raise (StartError e) end;
- let quit pid =
- if Sys.os_type <> "Win32" then
- Unix.kill pid Sys.sigterm
- in
- let thread pid =
- begin try f (); quit pid with
- | e ->
- let se = Printexc.to_string e in
- Printf.eprintf
- "init: exception encountered during main phase:\n %s\n%!" se;
- Printf.eprintf "exception: %s\n%s%!" se (get_backtrace ());
- if conf_catch_exn#get then quit pid else raise e
- end
- in
- let th = Thread.create thread (Unix.getpid ()) in
- if Sys.os_type <> "Win32" then
- wait_signal ()
- else
- Thread.join th ;
- begin try exec stop with e -> raise (StopError e) end
-
- let catch f clean =
- begin try
- f (); clean ()
- with
- | StartError (e) ->
- Printf.eprintf
- "init: exception encountered during start phase:\n %s\n%!"
- (Printexc.to_string e);
- clean ();
- exit (-1)
- | StopError (e) ->
- Printf.eprintf
- "init: exception encountered during stop phase:\n %s\n%!"
- (Printexc.to_string e);
- clean ();
- exit (-1)
- end
-
- (** A function to reopen a file descriptor
- * Thanks to Xavier Leroy!
- * Ref: http://caml.inria.fr/pub/ml-archives/caml-list/2000/01/
- * a7e3bbdfaab33603320d75dbdcd40c37.en.html
- *)
- let reopen_out outchan filename =
- flush outchan;
- let fd1 = Unix.descr_of_out_channel outchan in
- let fd2 =
- Unix.openfile filename [Unix.O_WRONLY] 0o666
- in
- Unix.dup2 fd2 fd1;
- Unix.close fd2
-
- (** The same for inchan *)
- let reopen_in inchan filename =
- let fd1 = Unix.descr_of_in_channel inchan in
- let fd2 =
- Unix.openfile filename [Unix.O_RDONLY] 0o666
- in
- Unix.dup2 fd2 fd1;
- Unix.close fd2
-
- let daemonize () =
- if Unix.fork () <> 0 then exit 0 ;
- (* Dettach from the console *)
- if (Unix.setsid () < 0) then
- exit 1;
- (* Refork.. *)
- if Unix.fork () <> 0 then exit 0 ;
- (* Change umask to 0 *)
- ignore(Unix.umask 0) ;
- (* chdir to / *)
- Unix.chdir "/" ;
- if conf_daemon_pidfile#get then
- begin
- (* Write PID to file *)
- let filename = conf_daemon_pidfile_path#get in
- let f = open_out filename in
- let pid = Unix.getpid () in
- output_string f (string_of_int pid);
- output_char f '\n';
- close_out f
- end ;
- (* Reopen usual file descriptor *)
- reopen_in stdin "/dev/null";
- reopen_out stdout "/dev/null";
- reopen_out stderr "/dev/null"
-
- let cleanup_daemon () =
- if conf_daemon_pidfile#get then
- try
- let filename = conf_daemon_pidfile_path#get in
- Sys.remove filename
- with _ -> ()
-
- exception Root_prohibited of [`User|`Group|`Both]
-
- let exit_when_root () =
- (* Change user.. *)
- if conf_daemon_drop_user#get then
- begin
- let grd = Unix.getgrnam conf_daemon_group#get in
- let gid = grd.Unix.gr_gid in
- if Unix.getegid () <> gid then
- Unix.setgid gid ;
- let pwd = Unix.getpwnam conf_daemon_user#get in
- let uid = pwd.Unix.pw_uid in
- if Unix.geteuid () <> uid then
- Unix.setuid uid
- end;
- match Unix.geteuid (), Unix.getegid () with
- | 0,0 -> raise (Root_prohibited `Both)
- | 0,_ -> raise (Root_prohibited `User)
- | _,0 -> raise (Root_prohibited `Group)
- | _ -> ()
-
- let init ?(prohibit_root=false) f =
- if prohibit_root then exit_when_root ();
- if conf_daemon#get && Sys.os_type <> "Win32" then
- daemonize () ;
- let signal_h _ = () in
- Sys.set_signal Sys.sigterm (Sys.Signal_handle signal_h);
- Sys.set_signal Sys.sigint (Sys.Signal_handle signal_h);
- (* We block signals that would kill us,
- * we'll wait for them and shutdown cleanly.
- * On Windows this is impossible so the only way for the application
- * to shutdown is to terminate the main function [f]. *)
- if Sys.os_type <> "Win32" then
- ignore (Unix.sigprocmask Unix.SIG_BLOCK [Sys.sigterm; Sys.sigint]);
- let cleanup =
- if conf_daemon#get && Sys.os_type <> "Win32" then
- cleanup_daemon
- else
- (fun () -> ())
- in
- catch (main f) cleanup
-
- let args =
- if Sys.os_type <> "Win32" then
- [
- ["--daemon";"-d"],
- Arg.Unit (fun () -> conf_daemon#set true),
- "run in daemon mode";
- ]
- else []
-
-end
-
-module Log =
-struct
-
- type t =
- <
- active: int -> bool;
- f: 'a. int -> ('a, unit, string, unit) format4 -> 'a;
- >
-
- type custom_log =
- {
- timestamp : bool ;
- exec : string -> unit
- }
-
- let log_ch = ref None
-
- (* Custom logging methods. *)
- let custom_log : (string, custom_log) Hashtbl.t = Hashtbl.create 0
-
- let add_custom_log name f = Hashtbl.replace custom_log name f
- let rm_custom_log name = Hashtbl.remove custom_log name
-
- let conf =
- Conf.void "log configuration"
-
- let conf_level =
- Conf.int ~p:(conf#plug "level") ~d:3
- "general log level"
- let conf_unix_timestamps =
- Conf.bool ~p:(conf#plug "unix_timestamps") ~d:false
- "display unix timestamps (subsecond accuracy, timezone independant)"
- let conf_file =
- Conf.bool ~p:(conf#plug "file") ~d:true
- "log to file"
- let conf_file_path =
- Conf.string ~p:(conf_file#plug "path")
- "path to log file"
- let conf_file_append =
- Conf.bool ~p:(conf_file#plug "append") ~d:true
- "append log to the file"
- let conf_file_perms =
- Conf.int ~p:(conf_file#plug "perms") ~d:0o600
- "log file permissions"
- let conf_stdout =
- Conf.bool ~p:(conf#plug "stdout") ~d:false
- "log to stdout"
-
- let timestamp time =
- begin match conf_unix_timestamps#get with
- | true ->
- Printf.sprintf "%f" time
- | false ->
- let date = Unix.localtime time in
- Printf.sprintf "%d/%02d/%02d %02d:%02d:%02d"
- (date.Unix.tm_year+1900)
- (date.Unix.tm_mon+1)
- date.Unix.tm_mday
- date.Unix.tm_hour
- date.Unix.tm_min
- date.Unix.tm_sec
- end
-
- let print (time, str) =
- let to_stdout = conf_stdout#get in
- let to_file = !log_ch <> None in
- let timestamp = timestamp time in
- let message =
- Printf.sprintf "%s %s" timestamp str
- in
- begin match to_stdout || to_file with
- | true ->
- let do_stdout () =
- Printf.printf "%s\n%!" message;
- in
- let do_file () =
- begin match !log_ch with
- | None -> ()
- | Some ch -> Printf.fprintf ch "%s\n%!" message;
- end
- in
- if to_stdout then do_stdout ();
- if to_file then do_file ();
- | false -> ()
- end ;
- let f _ x = x.exec (if x.timestamp then message else str) in
- Hashtbl.iter f custom_log
-
- (* Avoid interlacing logs *)
- let log_mutex = Mutex.create ()
- let log_condition = Condition.create ()
- let log_queue = ref (Queue.create ())
- let log_stop = ref false
- let log_thread = ref None
-
- let mutexify f x =
- Mutex.lock log_mutex;
- try
- let ret = f x in
- Mutex.unlock log_mutex;
- ret
- with
- | e ->
- Mutex.unlock log_mutex;
- raise e
-
- let rotate_queue () =
- let new_q = Queue.create () in
- mutexify (fun () ->
- let q = !log_queue in
- log_queue := new_q;
- q) ()
-
- let flush_queue () =
- let rec flush q =
- Queue.iter print q;
- let q = rotate_queue () in
- if not (Queue.is_empty q) then
- flush q
- in
- flush (rotate_queue ())
-
- let log_thread_fn () =
- let rec f () =
- flush_queue ();
- let log_stop =
- mutexify (fun () ->
- if !log_stop then
- true
- else
- begin
- Condition.wait log_condition log_mutex;
- !log_stop
- end) ()
- in
- if not log_stop then
- f ()
- in
- f ()
-
- let proceed =
- mutexify (fun entry ->
- Queue.push entry !log_queue;
- Condition.signal log_condition)
-
- let build path =
- let rec aux p l (t : Conf.ut) =
- begin match p with
- | [] -> t :: l
- | s :: q ->
- let st =
- begin try t#path [s] with
- | Conf.Unbound _ ->
- let c = Conf.int ~p:(t#plug s) "subordinate log level" in
- c#ut
- end
- in
- aux q (t :: l) st
- end
- in
- aux path [] conf_level#ut
-
- let make path : t =
- let confs = build path in
- let path_str = Conf.string_of_path path in
- object (self : t)
- val label =
- (fun lvl -> "[" ^ path_str ^ ":" ^ (string_of_int lvl) ^ "]")
- method active lvl =
- let rec aux l =
- begin match l with
- | [] -> None
- | t :: q ->
- begin match aux q with
- | Some i -> Some i
- | None ->
- begin try Some ((Conf.as_int t)#get)
- with
- | Conf.Undefined _ -> None
- end
- end
- end
- in
- begin match aux confs with
- | None -> false
- | Some i -> i >= lvl
- end
- method f lvl =
- begin match self#active lvl with
- | true ->
- let time = Unix.gettimeofday () in
- Printf.ksprintf (fun s -> proceed (time, label lvl ^ " " ^ s))
- | false ->
- Printf.ksprintf (fun _ -> ())
- end
- end
-
- let init () =
- let time = Unix.gettimeofday () in
- let reopen_log =
- if conf_file#get then
- begin
- let opts =
- [Open_wronly; Open_creat; Open_nonblock]
- @ (if conf_file_append#get then [Open_append] else [Open_trunc])
- in
- let log_file_path = conf_file_path#get in
- let log_file_perms = conf_file_perms#get in
- log_ch := Some (open_out_gen opts log_file_perms log_file_path);
- (fun _ ->
- begin
- match !log_ch with
- | None -> ()
- | Some ch -> log_ch := None; close_out ch;
- end;
- log_ch := Some (open_out_gen opts log_file_perms log_file_path))
- end
- else (fun _ -> ())
- in
- (* Re-open log file on SIGUSR1 -- for logrotate *)
- if Sys.os_type <> "Win32" then
- Sys.set_signal Sys.sigusr1
- (Sys.Signal_handle reopen_log);
- print (time, ">>> LOG START");
- log_thread := Some (Thread.create log_thread_fn ())
-
- let start = Init.make ~name:"init-log-start" ~before:[Init.start] init
-
- let close () =
- let time = Unix.gettimeofday () in
- mutexify (fun () ->
- log_stop := true) ();
- proceed (time, ">>> LOG END");
- begin
- match !log_thread with
- | None -> ()
- | Some th ->
- Condition.signal log_condition;
- Thread.join th
- end;
- match !log_ch with
- | None -> ()
- | Some ch ->
- log_ch := None;
- close_out ch
-
- let stop = Init.make ~name:"init-log-stop" ~after:[Init.stop] close
-
- let args =
- [
- ["--log-stdout"],
- Arg.Unit (fun () -> conf_stdout#set true),
- "log also to stdout";
- ["--log-file";"-l"],
- Arg.String (fun s -> conf_file#set true; conf_file_path#set s),
- "log file";
- ]
-
-end
+include Dtools_impl
+include Dtools_syslog
diff -Nru ocaml-dtools-0.4.1/src/dtools.mli ocaml-dtools-0.4.2/src/dtools.mli
--- ocaml-dtools-0.4.1/src/dtools.mli 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/src/dtools.mli 2020-03-28 00:34:27.000000000 +0000
@@ -1,15 +1,14 @@
-
- (**************************************************************************)
- (* ocaml-dtools *)
- (* Copyright (C) 2003-2010 The Savonet Team *)
- (**************************************************************************)
- (* 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 *)
- (* any later version. *)
- (**************************************************************************)
- (* Contact: savonet-devl@lists.sourceforge.net *)
- (**************************************************************************)
+(**************************************************************************)
+(* ocaml-dtools *)
+(* Copyright (C) 2003-2010 The Savonet Team *)
+(**************************************************************************)
+(* 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 *)
+(* any later version. *)
+(**************************************************************************)
+(* Contact: savonet-devl@lists.sourceforge.net *)
+(**************************************************************************)
(* $Id$ *)
@@ -21,26 +20,22 @@
(**
Configuration management module.
*)
-module Conf :
-sig
-
+module Conf : sig
+ (** Type for links between keys *)
type link = string
- (** Type for links between keys *)
+ (** Type for paths between keys *)
type path = link list
- (** Type for paths between keys *)
type ut =
- <
- kind: string option;
- descr: string;
- comments: string list;
- plug: link -> ut -> unit;
- subs: link list;
- path: path -> ut;
- routes: ut -> path list;
- ut: ut;
- >
+ < kind : string option
+ ; descr : string
+ ; comments : string list
+ ; plug : link -> ut -> unit
+ ; subs : link list
+ ; path : path -> ut
+ ; routes : ut -> path list
+ ; ut : ut >
(** Type for untyped keys (or keys with unknown type)
- [kind]: a string describing the type of this key
@@ -53,25 +48,21 @@
*)
type 'a t =
- <
- kind: string option;
- alias:
- ?comments:string list ->
- ?descr:string ->
- (ut -> unit) -> 'a t;
- descr: string;
- comments: string list;
- plug: link -> ut -> unit;
- subs: link list;
- path: path -> ut;
- routes: ut -> path list;
- ut: ut;
- set_d: 'a option -> unit;
- get_d: 'a option;
- set: 'a -> unit;
- get: 'a;
- on_change: ('a -> unit) -> unit
- >
+ < kind : string option
+ ; alias : ?comments:string list -> ?descr:string -> (ut -> unit) -> 'a t
+ ; descr : string
+ ; comments : string list
+ ; plug : link -> ut -> unit
+ ; subs : link list
+ ; path : path -> ut
+ ; routes : ut -> path list
+ ; ut : ut
+ ; set_d : 'a option -> unit
+ ; get_d : 'a option
+ ; set : 'a -> unit
+ ; get : 'a
+ ; validate : ('a -> bool) -> unit
+ ; on_change : ('a -> unit) -> unit >
(** Type for 'a keys
- [ut]: cast to un untyped key
@@ -81,88 +72,102 @@
- [get]: retrieve the resulting key value
*)
+ (** A set of connections to others keys *)
type links = (link * ut) list
- (** A set of connections to others keys *)
+ (** Raised on access to an undefined key (without default value) *)
exception Undefined of ut
- (** Raised on access to an undefined key (without default value) *)
+
+ (** Raised when an invalid link has been specified *)
exception Invalid of string
- (** Raised when an invalid link has been specified *)
+
+ (** Raised when a specified link does not exist *)
exception Unbound of ut * string
- (** Raised when a specified link does not exist *)
+
+ (** Raised when a specified link already exist *)
exception Bound of ut * string
- (** Raised when a specified link already exist *)
+
+ (** Raised on access to a key with a mismatching type *)
exception Mismatch of ut
- (** Raised on access to a key with a mismatching type *)
+
+ (** Raised on cyclic plug *)
exception Cyclic of ut * ut
- (** Raised on cyclic plug *)
+ (** Raised on invalid value set *)
+ exception Invalid_Value of ut
+
+ (** Raised when bad configuration assignations are encountered *)
exception Wrong_Conf of string * string
- (** Raised when bad configuration assignations are encountered *)
+
+ (** Raised when bad configuration assignations are encountered
+ inside configuration files *)
exception File_Wrong_Conf of string * int * string
- (** Raised when bad configuration assignations are encountered
- inside configuration files *)
+ (** Receipt to build a 'a key *)
type 'a builder =
- ?d:'a ->
- ?p:(ut -> unit) ->
- ?l:links ->
- ?comments:string list ->
- string -> 'a t
- (** Receipt to build a 'a key *)
+ ?d:'a ->
+ ?p:(ut -> unit) ->
+ ?l:links ->
+ ?comments:string list ->
+ string ->
+ 'a t
val unit : unit builder
val int : int builder
val float : float builder
val bool : bool builder
val string : string builder
+
+ (** Some key builders *)
val list : string list builder
- (** Some key builders *)
+ (** A structural key builder *)
val void :
?p:(ut -> unit) -> ?l:links -> ?comments:string list -> string -> ut
- (** A structural key builder *)
val as_unit : ut -> unit t
val as_int : ut -> int t
val as_float : ut -> float t
val as_bool : ut -> bool t
val as_string : ut -> string t
- val as_list : ut -> string list t
- (**
+
+ (**
Casts to specificaly typed keys.
Raises [Mismatch] on mismatching cast.
*)
+ val as_list : ut -> string list t
+ (** Convert a dot separated string to a path *)
val path_of_string : string -> path
- (** Convert a dot separated string to a path *)
+
+ (** Convert a path to a dot separated string *)
val string_of_path : path -> string
- (** Convert a path to a dot separated string *)
+ (** Generate a description table of a (sub)key *)
val descr : ?prefix:path -> ut -> string
- (** Generate a description table of a (sub)key *)
- val dump : ?prefix:path -> ut -> string
- (** Dump the configuration table for a (sub)key *)
- val conf_set : ut -> string -> unit
- (**
+ (** Dump the configuration table for a (sub)key *)
+ val dump : ?prefix:path -> ut -> string
+
+ (**
Add a value to the configuration keys, according to the given
correctly formated string: "type key :value"
Raises [Wrong_Conf] in badly formated cases.
*)
- val conf_file : ut -> string -> unit
- (**
+ val conf_set : ut -> string -> unit
+
+ (**
Read configuration values from the file associated with the given
filename.
Raises [File_Wrong_Conf] with filename line and and error message
in case of a bad configuration file.
*)
+ val conf_file : ut -> string -> unit
- val args : ut -> (string list * Arg.spec * string) list
- (**
+ (**
A set of command line options to be used with the Arg module.
*)
-
+ val args : ut -> (string list * Arg.spec * string) list
end
(**
@@ -170,57 +175,64 @@
Allow to define procedures that must be executed at start up, and
procedures that are to be executed at exit to have a clean quit.
*)
-module Init :
-sig
-
+module Init : sig
type t
+ (** Root start atom *)
val start : t
- (** Root start atom *)
+
+ (** Root stop atom *)
val stop : t
- (** Root stop atom *)
- val make :
- ?name:string ->
- ?depends:(t list) -> ?triggers:(t list) ->
- ?after:(t list) -> ?before:(t list) ->
- (unit -> unit) -> t
- (**
+ (**
Define a init atom associated with the given [(unit -> unit)]
procedure, which eventualy depends on others atoms (these atoms
- will be executed before the one currently defined) an triggers
+ will be executed before the one currently defined) and triggers
other atoms (these atoms will be executed after the one currently
defined). [after] and [before] allow to register the currently
defined atom in the depend and triggers lists of other atoms.
*)
-
- val at_start :
+ val make :
?name:string ->
- ?depends:(t list) -> ?triggers:(t list) ->
- ?after:(t list) -> ?before:(t list) ->
- (unit -> unit) -> t
- (**
+ ?depends:t list ->
+ ?triggers:t list ->
+ ?after:t list ->
+ ?before:t list ->
+ (unit -> unit) ->
+ t
+
+ (**
Same as [make] plus a shortcut for "after Init.start".
*)
-
- val at_stop :
+ val at_start :
?name:string ->
- ?depends:(t list) -> ?triggers:(t list) ->
- ?after:(t list) -> ?before:(t list) ->
- (unit -> unit) -> t
- (**
+ ?depends:t list ->
+ ?triggers:t list ->
+ ?after:t list ->
+ ?before:t list ->
+ (unit -> unit) ->
+ t
+
+ (**
Same as [make] plus a shortcut for "before Init.stop".
*)
+ val at_stop :
+ ?name:string ->
+ ?depends:t list ->
+ ?triggers:t list ->
+ ?after:t list ->
+ ?before:t list ->
+ (unit -> unit) ->
+ t
- val exec : t -> unit
- (**
+ (**
Launch the execution of a given init atom.
*)
+ val exec : t -> unit
- exception Root_prohibited of [`User|`Group|`Both]
+ exception Root_prohibited of [ `User | `Group | `Both ]
- val init : ?prohibit_root:bool -> (unit -> unit) -> unit
- (**
+ (**
This fuction must be used to launch the main procedure of the
program. It first execute the registered start atoms, then call
the main procedure, then execute the registered stop atoms.
@@ -230,6 +242,7 @@
When invoqued with [~prohibit_root:true], it checks for root access
rights (euid, egid) and exit in this case.
*)
+ val init : ?prohibit_root:bool -> (unit -> unit) -> unit
exception StartError of exn
exception StopError of exn
@@ -242,56 +255,46 @@
val conf_trace : bool Conf.t
val conf_catch_exn : bool Conf.t
- val args : (string list * Arg.spec * string) list
- (**
+ (**
A set of command line options to be used with the Arg module.
*)
-
+ val args : (string list * Arg.spec * string) list
end
-
-module Log :
-sig
-
- type t =
- <
- active: int -> bool;
- f: 'a. int -> ('a, unit, string, unit) format4 -> 'a;
- >
- (**
+module Log : sig
+ (**
Type for loggers.
*)
+ type t =
+ < active : int -> bool
+ ; f : 'a. int -> ('a, unit, string, unit) format4 -> 'a >
- type custom_log =
- {
- timestamp : bool ;
- exec : string -> unit
- }
+ type custom_log = { timestamp : bool; exec : string -> unit }
- val add_custom_log : string -> custom_log -> unit
- (**
+ (**
Add a custom logging functions.
*)
+ val add_custom_log : string -> custom_log -> unit
- val rm_custom_log : string -> unit
- (**
+ (**
Remove a custom logging functions.
*)
+ val rm_custom_log : string -> unit
- val make : Conf.path -> t
- (**
+ (**
Make a logger labeled according to the given path.
*)
+ val make : Conf.path -> t
- val start : Init.t
- (**
+ (**
An atom that starts the logging.
*)
+ val start : Init.t
- val stop : Init.t
- (**
+ (**
An atom that stops the logging.
*)
+ val stop : Init.t
val conf : Conf.ut
val conf_level : int Conf.t
@@ -302,9 +305,8 @@
val conf_file_append : bool Conf.t
val conf_file_perms : int Conf.t
- val args : (string list * Arg.spec * string) list
- (**
+ (**
A set of command line options to be used with the Arg module.
*)
-
+ val args : (string list * Arg.spec * string) list
end
diff -Nru ocaml-dtools-0.4.1/src/dtools_syslog.impl.ml ocaml-dtools-0.4.2/src/dtools_syslog.impl.ml
--- ocaml-dtools-0.4.1/src/dtools_syslog.impl.ml 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/src/dtools_syslog.impl.ml 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1,45 @@
+(**************************************************************************)
+(* ocaml-dtools *)
+(* Copyright (C) 2003-2010 The Savonet Team *)
+(**************************************************************************)
+(* 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 *)
+(* any later version. *)
+(**************************************************************************)
+(* Contact: savonet-devl@lists.sourceforge.net *)
+(**************************************************************************)
+
+(* $Id$ *)
+
+(* Syslog logging. *)
+
+open Dtools_impl
+
+let conf_syslog =
+ Conf.bool ~p:(Log.conf#plug "syslog") ~d:false "Enable syslog logging."
+
+let conf_program =
+ Conf.string
+ ~p:(conf_syslog#plug "program")
+ ~d:(Filename.basename Sys.executable_name)
+ "Name of the program."
+
+let conf_facility =
+ Conf.string ~p:(conf_syslog#plug "facility") ~d:"DAEMON" "Logging facility."
+
+let logging = ref None
+
+let () =
+ let start () =
+ if conf_syslog#get then (
+ let facility = Syslog.facility_of_string conf_facility#get in
+ let program = Printf.sprintf "%s[%d]" conf_program#get (Unix.getpid ()) in
+ let log = Syslog.openlog ~facility program in
+ logging := Some log;
+ let exec s = Syslog.syslog log `LOG_INFO s in
+ Log.add_custom_log program { Log.timestamp = false; exec } )
+ in
+ let stop () = match !logging with Some x -> Syslog.closelog x | _ -> () in
+ ignore (Init.at_start ~before:[Log.start] start);
+ ignore (Init.at_stop ~after:[Log.stop] stop)
diff -Nru ocaml-dtools-0.4.1/src/dtools_syslog.ml ocaml-dtools-0.4.2/src/dtools_syslog.ml
--- ocaml-dtools-0.4.1/src/dtools_syslog.ml 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/src/dtools_syslog.ml 1970-01-01 00:00:00.000000000 +0000
@@ -1,56 +0,0 @@
- (**************************************************************************)
- (* ocaml-dtools *)
- (* Copyright (C) 2003-2010 The Savonet Team *)
- (**************************************************************************)
- (* 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 *)
- (* any later version. *)
- (**************************************************************************)
- (* Contact: savonet-devl@lists.sourceforge.net *)
- (**************************************************************************)
-
- (* $Id$ *)
-
- (* Syslog logging. *)
-
-open Dtools
-
-let conf_syslog =
- Conf.bool ~p:(Log.conf#plug "syslog") ~d:false
- "Enable syslog logging."
-let conf_program =
- Conf.string ~p:(conf_syslog#plug "program")
- ~d:(Filename.basename Sys.executable_name)
- "Name of the program."
-let conf_facility =
- Conf.string ~p:(conf_syslog#plug "facility") ~d:"DAEMON"
- "Logging facility."
-
-let logging = ref None
-
-let () =
- let start () =
- if conf_syslog#get then
- let facility =
- Syslog.facility_of_string conf_facility#get
- in
- let program =
- Printf.sprintf "%s[%d]" conf_program#get (Unix.getpid ())
- in
- let log = Syslog.openlog ~facility program in
- logging := Some log ;
- let exec s = Syslog.syslog log `LOG_INFO s in
- Log.add_custom_log
- program { Log.
- timestamp = false ;
- exec = exec }
- in
- let stop () =
- match !logging with
- | Some x -> Syslog.closelog x
- |_ -> ()
- in
- ignore (Dtools.Init.at_start ~before:[Log.start] start) ;
- ignore (Dtools.Init.at_stop ~after:[Log.stop] stop)
-
diff -Nru ocaml-dtools-0.4.1/src/dtools_syslog.noop.ml ocaml-dtools-0.4.2/src/dtools_syslog.noop.ml
--- ocaml-dtools-0.4.1/src/dtools_syslog.noop.ml 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/src/dtools_syslog.noop.ml 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1 @@
+(* noop *)
diff -Nru ocaml-dtools-0.4.1/src/dune ocaml-dtools-0.4.2/src/dune
--- ocaml-dtools-0.4.1/src/dune 1970-01-01 00:00:00.000000000 +0000
+++ ocaml-dtools-0.4.2/src/dune 2020-03-28 00:34:27.000000000 +0000
@@ -0,0 +1,13 @@
+(library
+ (name dtools)
+ (public_name dtools)
+ (libraries
+ str
+ threads
+ unix
+ (select
+ dtools_syslog.ml
+ from
+ (syslog -> dtools_syslog.impl.ml)
+ (-> dtools_syslog.noop.ml)))
+ (synopsis "Library providing various helper functions to make daemons"))
diff -Nru ocaml-dtools-0.4.1/src/Makefile.in ocaml-dtools-0.4.2/src/Makefile.in
--- ocaml-dtools-0.4.1/src/Makefile.in 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/src/Makefile.in 1970-01-01 00:00:00.000000000 +0000
@@ -1,43 +0,0 @@
-# Copyright 2003-2006 Savonet team
-
-OCAMLMAKEFILE = OCamlMakefile
-
-OCAMLFIND = @OCAMLFIND@
-OCAMLFIND_LDCONF= @OCAMLFIND_LDCONF@
-OCAMLC = @OCAMLC@
-OCAMLOPT = @OCAMLOPT@
-OCAMLMKTOP = @OCAMLMKTOP@
-OCAMLMKLIB = @OCAMLMKLIB@
-OCAMLCP = @OCAMLCP@
-OCAMLDEP = @OCAMLDEP@
-OCAMLLEX = @OCAMLLEX@
-OCAMLYACC = @OCAMLYACC@
-OCAMLDOC = @OCAMLDOC@
-LATEX = @LATEX@
-DVIPS = @DVIPS@
-PS2PDF = @PS2PDF@
-OCAMLLIBPATH = @CAMLLIBPATH@
-OCAMLBEST = @OCAMLBEST@
-
-THREADS = "yes"
-SOURCES = dtools.ml dtools.mli @SYSLOG_FILES@
-RESULT = dtools
-LIBINSTALL_FILES = $(wildcard *.cma *.cmxa *.cmx *.mli *.cmi *.a)
-OCAMLLDFLAGS = -linkall
-INCDIRS = @INC@
-NO_CUSTOM = yes
-OCAMLFLAGS = @OCAMLFLAGS@
-
-all: $(OCAMLBEST)
-
-byte: byte-code-library
-
-opt: native-code-library
-
-install: libinstall
-
-uninstall: libuninstall
-
-update: uninstall install
-
--include $(OCAMLMAKEFILE)
diff -Nru ocaml-dtools-0.4.1/src/META.in ocaml-dtools-0.4.2/src/META.in
--- ocaml-dtools-0.4.1/src/META.in 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/src/META.in 1970-01-01 00:00:00.000000000 +0000
@@ -1,6 +0,0 @@
-name="dtools"
-version="@PACKAGE_VERSION@"
-description="OCaml deamon tools library"
-requires="@REQUIRES@"
-archive(byte) = "dtools.cma"
-archive(native) = "dtools.cmxa"
diff -Nru ocaml-dtools-0.4.1/src/OCamlMakefile ocaml-dtools-0.4.2/src/OCamlMakefile
--- ocaml-dtools-0.4.1/src/OCamlMakefile 2018-09-11 05:09:44.000000000 +0000
+++ ocaml-dtools-0.4.2/src/OCamlMakefile 1970-01-01 00:00:00.000000000 +0000
@@ -1,1137 +0,0 @@
-###########################################################################
-# OCamlMakefile
-# Copyright (C) 1999-2004 Markus Mottl
-#
-# For updates see:
-# http://www.oefai.at/~markus/ocaml_sources
-#
-# $Id$
-#
-###########################################################################
-
-# Modified by damien for .glade.ml compilation
-
-# Set these variables to the names of the sources to be processed and
-# the result variable. Order matters during linkage!
-
-ifndef SOURCES
- SOURCES := foo.ml
-endif
-export SOURCES
-
-ifndef RES_CLIB_SUF
- RES_CLIB_SUF := _stubs
-endif
-export RES_CLIB_SUF
-
-ifndef RESULT
- RESULT := foo
-endif
-export RESULT
-
-export LIB_PACK_NAME
-
-ifndef DOC_FILES
- DOC_FILES := $(filter %.mli, $(SOURCES))
-endif
-export DOC_FILES
-
-export BCSUFFIX
-export NCSUFFIX
-
-ifndef TOPSUFFIX
- TOPSUFFIX := .top
-endif
-export TOPSUFFIX
-
-# Eventually set include- and library-paths, libraries to link,
-# additional compilation-, link- and ocamlyacc-flags
-# Path- and library information needs not be written with "-I" and such...
-# Define THREADS if you need it, otherwise leave it unset (same for
-# USE_CAMLP4)!
-
-export THREADS
-export VMTHREADS
-export ANNOTATE
-export USE_CAMLP4
-
-export INCDIRS
-export LIBDIRS
-export EXTLIBDIRS
-export RESULTDEPS
-export OCAML_DEFAULT_DIRS
-
-export LIBS
-export CLIBS
-
-export OCAMLFLAGS
-export OCAMLNCFLAGS
-export OCAMLBCFLAGS
-
-export OCAMLLDFLAGS
-export OCAMLNLDFLAGS
-export OCAMLBLDFLAGS
-
-ifndef OCAMLCPFLAGS
- OCAMLCPFLAGS := a
-endif
-
-export OCAMLCPFLAGS
-
-export PPFLAGS
-
-export YFLAGS
-export IDLFLAGS
-
-export OCAMLDOCFLAGS
-
-export OCAMLFIND_INSTFLAGS
-
-export DVIPSFLAGS
-
-export STATIC
-
-# Add a list of optional trash files that should be deleted by "make clean"
-export TRASH
-
-#################### variables depending on your OCaml-installation
-
-ifdef MINGW
- export MINGW
- WIN32 := 1
- CFLAGS_WIN32 := -mno-cygwin
-endif
-ifdef MSVC
- export MSVC
- WIN32 := 1
- ifndef STATIC
- CPPFLAGS_WIN32 := -DCAML_DLL
- endif
- CFLAGS_WIN32 += -nologo
- EXT_OBJ := obj
- EXT_LIB := lib
- ifeq ($(CC),gcc)
- # work around GNU Make default value
- ifdef THREADS
- CC := cl -MT
- else
- CC := cl
- endif
- endif
- ifeq ($(CXX),g++)
- # work around GNU Make default value
- CXX := $(CC)
- endif
- CFLAG_O := -Fo
-endif
-ifdef WIN32
- EXT_CXX := cpp
- EXE := .exe
-endif
-
-ifndef EXT_OBJ
- EXT_OBJ := o
-endif
-ifndef EXT_LIB
- EXT_LIB := a
-endif
-ifndef EXT_CXX
- EXT_CXX := cc
-endif
-ifndef EXE
- EXE := # empty
-endif
-ifndef CFLAG_O
- CFLAG_O := -o # do not delete this comment (preserves trailing whitespace)!
-endif
-
-export CC
-export CXX
-export CFLAGS
-export CXXFLAGS
-export LDFLAGS
-export CPPFLAGS
-
-ifndef RPATH_FLAG
- RPATH_FLAG := -R
-endif
-export RPATH_FLAG
-
-ifndef MSVC
-ifndef PIC_CFLAGS
- PIC_CFLAGS := -fPIC
-endif
-ifndef PIC_CPPFLAGS
- PIC_CPPFLAGS := -DPIC
-endif
-endif
-
-export PIC_CFLAGS
-export PIC_CPPFLAGS
-
-BCRESULT := $(addsuffix $(BCSUFFIX), $(RESULT))
-NCRESULT := $(addsuffix $(NCSUFFIX), $(RESULT))
-TOPRESULT := $(addsuffix $(TOPSUFFIX), $(RESULT))
-
-ifndef OCAMLFIND
- OCAMLFIND := ocamlfind
-endif
-export OCAMLFIND
-
-ifndef OCAMLC
- OCAMLC := ocamlc
-endif
-export OCAMLC
-
-ifndef OCAMLOPT
- OCAMLOPT := ocamlopt
-endif
-export OCAMLOPT
-
-ifndef OCAMLMKTOP
- OCAMLMKTOP := ocamlmktop
-endif
-export OCAMLMKTOP
-
-ifndef OCAMLCP
- OCAMLCP := ocamlcp
-endif
-export OCAMLCP
-
-ifndef OCAMLDEP
- OCAMLDEP := ocamldep
-endif
-export OCAMLDEP
-
-ifndef OCAMLLEX
- OCAMLLEX := ocamllex
-endif
-export OCAMLLEX
-
-ifndef OCAMLYACC
- OCAMLYACC := ocamlyacc
-endif
-export OCAMLYACC
-
-ifndef OCAMLMKLIB
- OCAMLMKLIB := ocamlmklib
-endif
-export OCAMLMKLIB
-
-ifndef OCAML_GLADECC
- OCAML_GLADECC := lablgladecc2
-endif
-export OCAML_GLADECC
-
-ifndef OCAML_GLADECC_FLAGS
- OCAML_GLADECC_FLAGS :=
-endif
-export OCAML_GLADECC_FLAGS
-
-ifndef CAMELEON_REPORT
- CAMELEON_REPORT := report
-endif
-export CAMELEON_REPORT
-
-ifndef CAMELEON_REPORT_FLAGS
- CAMELEON_REPORT_FLAGS :=
-endif
-export CAMELEON_REPORT_FLAGS
-
-ifndef CAMELEON_ZOGGY
- CAMELEON_ZOGGY := camlp4o pa_zog.cma pr_o.cmo
-endif
-export CAMELEON_ZOGGY
-
-ifndef CAMELEON_ZOGGY_FLAGS
- CAMELEON_ZOGGY_FLAGS :=
-endif
-export CAMELEON_ZOGGY_FLAGS
-
-ifndef OXRIDL
- OXRIDL := oxridl
-endif
-export OXRIDL
-
-ifndef CAMLIDL
- CAMLIDL := camlidl
-endif
-export CAMLIDL
-
-ifndef CAMLIDLDLL
- CAMLIDLDLL := camlidldll
-endif
-export CAMLIDLDLL
-
-ifndef NOIDLHEADER
- MAYBE_IDL_HEADER := -header
-endif
-export NOIDLHEADER
-
-export NO_CUSTOM
-
-ifndef CAMLP4
- CAMLP4 := camlp4
-endif
-export CAMLP4
-
-ifndef REAL_OCAMLFIND
- ifdef PACKS
- ifndef CREATE_LIB
- ifdef THREADS
- PACKS += threads
- endif
- endif
- empty :=
- space := $(empty) $(empty)
- comma := ,
- ifdef PREDS
- PRE_OCAML_FIND_PREDICATES := $(subst $(space),$(comma),$(PREDS))
- PRE_OCAML_FIND_PACKAGES := $(subst $(space),$(comma),$(PACKS))
- OCAML_FIND_PREDICATES := -predicates $(PRE_OCAML_FIND_PREDICATES)
- # OCAML_DEP_PREDICATES := -syntax $(PRE_OCAML_FIND_PREDICATES)
- OCAML_FIND_PACKAGES := $(OCAML_FIND_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
- OCAML_DEP_PACKAGES := $(OCAML_DEP_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
- else
- OCAML_FIND_PACKAGES := -package $(subst $(space),$(comma),$(PACKS))
- OCAML_DEP_PACKAGES :=
- endif
- OCAML_FIND_LINKPKG := -linkpkg
- REAL_OCAMLFIND := $(OCAMLFIND)
- endif
-endif
-
-export OCAML_FIND_PACKAGES
-export OCAML_DEP_PACKAGES
-export OCAML_FIND_LINKPKG
-export REAL_OCAMLFIND
-
-ifndef OCAMLDOC
- OCAMLDOC := ocamldoc
-endif
-export OCAMLDOC
-
-ifndef LATEX
- LATEX := latex
-endif
-export LATEX
-
-ifndef DVIPS
- DVIPS := dvips
-endif
-export DVIPS
-
-ifndef PS2PDF
- PS2PDF := ps2pdf
-endif
-export PS2PDF
-
-ifndef OCAMLMAKEFILE
- OCAMLMAKEFILE := OCamlMakefile
-endif
-export OCAMLMAKEFILE
-
-ifndef OCAMLLIBPATH
- OCAMLLIBPATH := \
- $(shell $(OCAMLC) 2>/dev/null -where || echo /usr/lib/ocaml)
-endif
-export OCAMLLIBPATH
-
-ifndef OCAML_LIB_INSTALL
- OCAML_LIB_INSTALL := $(OCAMLLIBPATH)/contrib
-endif
-export OCAML_LIB_INSTALL
-
-###########################################################################
-
-#################### change following sections only if
-#################### you know what you are doing!
-
-# delete target files when a build command fails
-.PHONY: .DELETE_ON_ERROR
-.DELETE_ON_ERROR:
-
-# for pedants using "--warn-undefined-variables"
-export MAYBE_IDL
-export REAL_RESULT
-export CAMLIDLFLAGS
-export THREAD_FLAG
-export RES_CLIB
-export MAKEDLL
-export ANNOT_FLAG
-export C_OXRIDL
-export SUBPROJS
-export CFLAGS_WIN32
-export CPPFLAGS_WIN32
-
-INCFLAGS :=
-
-SHELL := /bin/sh
-
-MLDEPDIR := ._d
-BCDIDIR := ._bcdi
-NCDIDIR := ._ncdi
-
-FILTER_EXTNS := %.mli %.ml %.mll %.mly %.idl %.oxridl %.c %.$(EXT_CXX) %.rep %.zog %.glade
-
-FILTERED := $(filter $(FILTER_EXTNS), $(SOURCES))
-SOURCE_DIRS := $(filter-out ./, $(sort $(dir $(FILTERED))))
-
-FILTERED_REP := $(filter %.rep, $(FILTERED))
-DEP_REP := $(FILTERED_REP:%.rep=$(MLDEPDIR)/%.d)
-AUTO_REP := $(FILTERED_REP:.rep=.ml)
-
-FILTERED_ZOG := $(filter %.zog, $(FILTERED))
-DEP_ZOG := $(FILTERED_ZOG:%.zog=$(MLDEPDIR)/%.d)
-AUTO_ZOG := $(FILTERED_ZOG:.zog=.ml)
-
-FILTERED_GLADE := $(filter %.glade, $(FILTERED))
-DEP_GLADE := $(FILTERED_GLADE:%.glade=$(MLDEPDIR)/%.d)
-AUTO_GLADE := $(FILTERED_GLADE:.glade=.ml)
-
-FILTERED_ML := $(filter %.ml, $(FILTERED))
-DEP_ML := $(FILTERED_ML:%.ml=$(MLDEPDIR)/%.d)
-
-FILTERED_MLI := $(filter %.mli, $(FILTERED))
-DEP_MLI := $(FILTERED_MLI:.mli=.di)
-
-FILTERED_MLL := $(filter %.mll, $(FILTERED))
-DEP_MLL := $(FILTERED_MLL:%.mll=$(MLDEPDIR)/%.d)
-AUTO_MLL := $(FILTERED_MLL:.mll=.ml)
-
-FILTERED_MLY := $(filter %.mly, $(FILTERED))
-DEP_MLY := $(FILTERED_MLY:%.mly=$(MLDEPDIR)/%.d) $(FILTERED_MLY:.mly=.di)
-AUTO_MLY := $(FILTERED_MLY:.mly=.mli) $(FILTERED_MLY:.mly=.ml)
-
-FILTERED_IDL := $(filter %.idl, $(FILTERED))
-DEP_IDL := $(FILTERED_IDL:%.idl=$(MLDEPDIR)/%.d) $(FILTERED_IDL:.idl=.di)
-C_IDL := $(FILTERED_IDL:%.idl=%_stubs.c)
-ifndef NOIDLHEADER
- C_IDL += $(FILTERED_IDL:.idl=.h)
-endif
-OBJ_C_IDL := $(FILTERED_IDL:%.idl=%_stubs.$(EXT_OBJ))
-AUTO_IDL := $(FILTERED_IDL:.idl=.mli) $(FILTERED_IDL:.idl=.ml) $(C_IDL)
-
-FILTERED_OXRIDL := $(filter %.oxridl, $(FILTERED))
-DEP_OXRIDL := $(FILTERED_OXRIDL:%.oxridl=$(MLDEPDIR)/%.d) $(FILTERED_OXRIDL:.oxridl=.di)
-AUTO_OXRIDL := $(FILTERED_OXRIDL:.oxridl=.mli) $(FILTERED_OXRIDL:.oxridl=.ml) $(C_OXRIDL)
-
-FILTERED_C_CXX := $(filter %.c %.$(EXT_CXX), $(FILTERED))
-OBJ_C_CXX := $(FILTERED_C_CXX:.c=.$(EXT_OBJ))
-OBJ_C_CXX := $(OBJ_C_CXX:.$(EXT_CXX)=.$(EXT_OBJ))
-
-PRE_TARGETS += $(AUTO_MLL) $(AUTO_MLY) $(AUTO_IDL) $(AUTO_OXRIDL) $(AUTO_ZOG) $(AUTO_REP) $(AUTO_GLADE)
-
-ALL_DEPS := $(DEP_ML) $(DEP_MLI) $(DEP_MLL) $(DEP_MLY) $(DEP_IDL) $(DEP_OXRIDL) $(DEP_ZOG) $(DEP_REP) $(DEP_GLADE)
-
-MLDEPS := $(filter %.d, $(ALL_DEPS))
-MLIDEPS := $(filter %.di, $(ALL_DEPS))
-BCDEPIS := $(MLIDEPS:%.di=$(BCDIDIR)/%.di)
-NCDEPIS := $(MLIDEPS:%.di=$(NCDIDIR)/%.di)
-
-ALLML := $(filter %.mli %.ml %.mll %.mly %.idl %.oxridl %.rep %.zog %.glade, $(FILTERED))
-
-IMPLO_INTF := $(ALLML:%.mli=%.mli.__)
-IMPLO_INTF := $(foreach file, $(IMPLO_INTF), \
- $(basename $(file)).cmi $(basename $(file)).cmo)
-IMPLO_INTF := $(filter-out %.mli.cmo, $(IMPLO_INTF))
-IMPLO_INTF := $(IMPLO_INTF:%.mli.cmi=%.cmi)
-
-IMPLX_INTF := $(IMPLO_INTF:.cmo=.cmx)
-
-INTF := $(filter %.cmi, $(IMPLO_INTF))
-IMPL_CMO := $(filter %.cmo, $(IMPLO_INTF))
-IMPL_CMX := $(IMPL_CMO:.cmo=.cmx)
-IMPL_ASM := $(IMPL_CMO:.cmo=.asm)
-IMPL_S := $(IMPL_CMO:.cmo=.s)
-
-OBJ_LINK := $(OBJ_C_IDL) $(OBJ_C_CXX)
-OBJ_FILES := $(IMPL_CMO:.cmo=.$(EXT_OBJ)) $(OBJ_LINK)
-
-EXECS := $(addsuffix $(EXE), \
- $(sort $(TOPRESULT) $(BCRESULT) $(NCRESULT)))
-ifdef WIN32
- EXECS += $(BCRESULT).dll $(NCRESULT).dll
-endif
-
-CLIB_BASE := $(RESULT)$(RES_CLIB_SUF)
-ifneq ($(strip $(OBJ_LINK)),)
- RES_CLIB := lib$(CLIB_BASE).$(EXT_LIB)
-endif
-
-ifdef WIN32
-DLLSONAME := $(CLIB_BASE).dll
-else
-DLLSONAME := dll$(CLIB_BASE).so
-endif
-
-NONEXECS := $(INTF) $(IMPL_CMO) $(IMPL_CMX) $(IMPL_ASM) $(IMPL_S) \
- $(OBJ_FILES) $(PRE_TARGETS) $(BCRESULT).cma $(NCRESULT).cmxa \
- $(NCRESULT).$(EXT_LIB) $(BCRESULT).cmi $(BCRESULT).cmo \
- $(NCRESULT).cmi $(NCRESULT).cmx $(NCRESULT).o \
- $(RES_CLIB) $(IMPL_CMO:.cmo=.annot) \
- $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(LIB_PACK_NAME).cmx $(LIB_PACK_NAME).o
-
-ifndef STATIC
- NONEXECS += $(DLLSONAME)
-endif
-
-ifndef LIBINSTALL_FILES
- LIBINSTALL_FILES := $(RESULT).mli $(RESULT).cmi $(RESULT).cma \
- $(RESULT).cmxa $(RESULT).$(EXT_LIB) $(RES_CLIB)
- ifndef STATIC
- ifneq ($(strip $(OBJ_LINK)),)
- LIBINSTALL_FILES += $(DLLSONAME)
- endif
- endif
-endif
-
-export LIBINSTALL_FILES
-
-ifdef WIN32
- # some extra stuff is created while linking DLLs
- NONEXECS += $(BCRESULT).$(EXT_LIB) $(BCRESULT).exp $(NCRESULT).exp $(CLIB_BASE).exp $(CLIB_BASE).lib
-endif
-
-TARGETS := $(EXECS) $(NONEXECS)
-
-# If there are IDL-files
-ifneq ($(strip $(FILTERED_IDL)),)
- MAYBE_IDL := -cclib -lcamlidl
-endif
-
-ifdef USE_CAMLP4
- CAMLP4PATH := \
- $(shell $(CAMLP4) -where 2>/dev/null || echo /usr/lib/camlp4)
- INCFLAGS := -I $(CAMLP4PATH)
- CINCFLAGS := -I$(CAMLP4PATH)
-endif
-
-DINCFLAGS := $(INCFLAGS) $(SOURCE_DIRS:%=-I %) $(OCAML_DEFAULT_DIRS:%=-I %)
-INCFLAGS := $(DINCFLAGS) $(INCDIRS:%=-I %)
-CINCFLAGS += $(SOURCE_DIRS:%=-I%) $(INCDIRS:%=-I%) $(OCAML_DEFAULT_DIRS:%=-I%)
-
-ifndef MSVC
-CLIBFLAGS += $(SOURCE_DIRS:%=-L%) $(LIBDIRS:%=-L%) \
- $(EXTLIBDIRS:%=-L%) $(EXTLIBDIRS:%=-Wl,$(RPATH_FLAG)%) \
- $(OCAML_DEFAULT_DIRS:%=-L%)
-endif
-
-ifndef PROFILING
- INTF_OCAMLC := $(OCAMLC)
-else
- ifndef THREADS
- INTF_OCAMLC := $(OCAMLCP) -p $(OCAMLCPFLAGS)
- else
- # OCaml does not support profiling byte code
- # with threads (yet), therefore we force an error.
- ifndef REAL_OCAMLC
- $(error Profiling of multithreaded byte code not yet supported by OCaml)
- endif
- INTF_OCAMLC := $(OCAMLC)
- endif
-endif
-
-ifndef MSVC
-COMMON_LDFLAGS := $(LDFLAGS:%=-ccopt %) $(SOURCE_DIRS:%=-ccopt -L%) \
- $(LIBDIRS:%=-ccopt -L%) $(EXTLIBDIRS:%=-ccopt -L%) \
- $(EXTLIBDIRS:%=-ccopt -Wl,$(RPATH_FLAG)%) \
- $(OCAML_DEFAULT_DIRS:%=-ccopt -L%)
-else
-COMMON_LDFLAGS := -ccopt "/link -NODEFAULTLIB:LIBC $(LDFLAGS:%=%) $(SOURCE_DIRS:%=-LIBPATH:%) \
- $(LIBDIRS:%=-LIBPATH:%) $(EXTLIBDIRS:%=-LIBPATH:%) \
- $(OCAML_DEFAULT_DIRS:%=-LIBPATH:%) "
-endif
-
-CLIBS_OPTS := $(CLIBS:%=-cclib -l%)
-ifdef MSVC
- ifndef STATIC
- # MSVC libraries do not have 'lib' prefix
- CLIBS_OPTS := $(CLIBS:%=-cclib %.lib)
- endif
-endif
-
-ifneq ($(strip $(OBJ_LINK)),)
- ifdef CREATE_LIB
- OBJS_LIBS := -cclib -l$(CLIB_BASE) $(CLIBS_OPTS) $(MAYBE_IDL)
- else
- OBJS_LIBS := $(OBJ_LINK) $(CLIBS_OPTS) $(MAYBE_IDL)
- endif
-else
- OBJS_LIBS := $(CLIBS_OPTS) $(MAYBE_IDL)
-endif
-
-# If we have to make byte-code
-ifndef REAL_OCAMLC
- BYTE_OCAML := y
-
- # EXTRADEPS is added dependencies we have to insert for all
- # executable files we generate. Ideally it should be all of the
- # libraries we use, but it's hard to find the ones that get searched on
- # the path since I don't know the paths built into the compiler, so
- # just include the ones with slashes in their names.
- EXTRADEPS := $(addsuffix .cma,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
- SPECIAL_OCAMLFLAGS := $(OCAMLBCFLAGS)
-
- REAL_OCAMLC := $(INTF_OCAMLC)
-
- REAL_IMPL := $(IMPL_CMO)
- REAL_IMPL_INTF := $(IMPLO_INTF)
- IMPL_SUF := .cmo
-
- DEPFLAGS :=
- MAKE_DEPS := $(MLDEPS) $(BCDEPIS)
-
- ifdef CREATE_LIB
- CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
- CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
- ifndef STATIC
- ifneq ($(strip $(OBJ_LINK)),)
- MAKEDLL := $(DLLSONAME)
- ALL_LDFLAGS := -dllib $(DLLSONAME)
- endif
- endif
- endif
-
- ifndef NO_CUSTOM
- ifneq "$(strip $(OBJ_LINK) $(THREADS) $(MAYBE_IDL) $(CLIBS))" ""
- ALL_LDFLAGS += -custom
- endif
- endif
-
- ALL_LDFLAGS += $(INCFLAGS) $(OCAMLLDFLAGS) $(OCAMLBLDFLAGS) \
- $(COMMON_LDFLAGS) $(LIBS:%=%.cma)
- CAMLIDLDLLFLAGS :=
-
- ifdef THREADS
- ifdef VMTHREADS
- THREAD_FLAG := -vmthread
- else
- THREAD_FLAG := -thread
- endif
- ifndef CREATE_LIB
- ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
- ifndef REAL_OCAMLFIND
- ALL_LDFLAGS := unix.cma threads.cma $(ALL_LDFLAGS)
- endif
- endif
- endif
-
-# we have to make native-code
-else
- EXTRADEPS := $(addsuffix .cmxa,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
- ifndef PROFILING
- SPECIAL_OCAMLFLAGS := $(OCAMLNCFLAGS)
- PLDFLAGS :=
- else
- SPECIAL_OCAMLFLAGS := -p $(OCAMLNCFLAGS)
- PLDFLAGS := -p
- endif
-
- REAL_IMPL := $(IMPL_CMX)
- REAL_IMPL_INTF := $(IMPLX_INTF)
- IMPL_SUF := .cmx
-
- CPPFLAGS := -DNATIVE_CODE $(CPPFLAGS)
-
- DEPFLAGS := -native
- MAKE_DEPS := $(MLDEPS) $(NCDEPIS)
-
- ALL_LDFLAGS := $(PLDFLAGS) $(INCFLAGS) $(OCAMLLDFLAGS) \
- $(OCAMLNLDFLAGS) $(COMMON_LDFLAGS)
- CAMLIDLDLLFLAGS := -opt
-
- ifndef CREATE_LIB
- ALL_LDFLAGS += $(LIBS:%=%.cmxa)
- else
- CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
- CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
- endif
-
- ifdef THREADS
- THREAD_FLAG := -thread
- ifndef CREATE_LIB
- ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
- ifndef REAL_OCAMLFIND
- ALL_LDFLAGS := unix.cmxa threads.cmxa $(ALL_LDFLAGS)
- endif
- endif
- endif
-endif
-
-export MAKE_DEPS
-
-ifdef ANNOTATE
- ANNOT_FLAG := -dtypes
-else
-endif
-
-ALL_OCAMLCFLAGS := $(THREAD_FLAG) $(ANNOT_FLAG) $(OCAMLFLAGS) \
- $(INCFLAGS) $(SPECIAL_OCAMLFLAGS)
-
-ifdef make_deps
- -include $(MAKE_DEPS)
- PRE_TARGETS :=
-endif
-
-###########################################################################
-# USER RULES
-
-# Call "OCamlMakefile QUIET=" to get rid of all of the @'s.
-QUIET=@
-
-# generates byte-code (default)
-byte-code: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
- REAL_RESULT="$(BCRESULT)" make_deps=yes
-bc: byte-code
-
-byte-code-nolink: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
- REAL_RESULT="$(BCRESULT)" make_deps=yes
-bcnl: byte-code-nolink
-
-top: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(TOPRESULT) \
- REAL_RESULT="$(BCRESULT)" make_deps=yes
-
-# generates native-code
-
-native-code: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
- REAL_RESULT="$(NCRESULT)" \
- REAL_OCAMLC="$(OCAMLOPT)" \
- make_deps=yes
-nc: native-code
-
-native-code-nolink: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
- REAL_RESULT="$(NCRESULT)" \
- REAL_OCAMLC="$(OCAMLOPT)" \
- make_deps=yes
-ncnl: native-code-nolink
-
-# generates byte-code libraries
-byte-code-library: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
- $(RES_CLIB) $(BCRESULT).cma \
- REAL_RESULT="$(BCRESULT)" \
- CREATE_LIB=yes \
- make_deps=yes
-bcl: byte-code-library
-
-# generates native-code libraries
-native-code-library: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
- $(RES_CLIB) $(NCRESULT).cmxa \
- REAL_RESULT="$(NCRESULT)" \
- REAL_OCAMLC="$(OCAMLOPT)" \
- CREATE_LIB=yes \
- make_deps=yes
-ncl: native-code-library
-
-ifdef WIN32
-# generates byte-code dll
-byte-code-dll: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
- $(RES_CLIB) $(BCRESULT).dll \
- REAL_RESULT="$(BCRESULT)" \
- make_deps=yes
-bcd: byte-code-dll
-
-# generates native-code dll
-native-code-dll: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
- $(RES_CLIB) $(NCRESULT).dll \
- REAL_RESULT="$(NCRESULT)" \
- REAL_OCAMLC="$(OCAMLOPT)" \
- make_deps=yes
-ncd: native-code-dll
-endif
-
-# generates byte-code with debugging information
-debug-code: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
- REAL_RESULT="$(BCRESULT)" make_deps=yes \
- OCAMLFLAGS="-g $(OCAMLFLAGS)" \
- OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
-dc: debug-code
-
-debug-code-nolink: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
- REAL_RESULT="$(BCRESULT)" make_deps=yes \
- OCAMLFLAGS="-g $(OCAMLFLAGS)" \
- OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
-dcnl: debug-code-nolink
-
-# generates byte-code libraries with debugging information
-debug-code-library: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
- $(RES_CLIB) $(BCRESULT).cma \
- REAL_RESULT="$(BCRESULT)" make_deps=yes \
- CREATE_LIB=yes \
- OCAMLFLAGS="-g $(OCAMLFLAGS)" \
- OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
-dcl: debug-code-library
-
-# generates byte-code for profiling
-profiling-byte-code: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
- REAL_RESULT="$(BCRESULT)" PROFILING="y" \
- make_deps=yes
-pbc: profiling-byte-code
-
-# generates native-code
-
-profiling-native-code: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
- REAL_RESULT="$(NCRESULT)" \
- REAL_OCAMLC="$(OCAMLOPT)" \
- PROFILING="y" \
- make_deps=yes
-pnc: profiling-native-code
-
-# generates byte-code libraries
-profiling-byte-code-library: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
- $(RES_CLIB) $(BCRESULT).cma \
- REAL_RESULT="$(BCRESULT)" PROFILING="y" \
- CREATE_LIB=yes \
- make_deps=yes
-pbcl: profiling-byte-code-library
-
-# generates native-code libraries
-profiling-native-code-library: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
- $(RES_CLIB) $(NCRESULT).cmxa \
- REAL_RESULT="$(NCRESULT)" PROFILING="y" \
- REAL_OCAMLC="$(OCAMLOPT)" \
- CREATE_LIB=yes \
- make_deps=yes
-pncl: profiling-native-code-library
-
-# packs byte-code objects
-pack-byte-code: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT).cmo \
- REAL_RESULT="$(BCRESULT)" \
- PACK_LIB=yes make_deps=yes
-pabc: pack-byte-code
-
-# packs native-code objects
-pack-native-code: $(PRE_TARGETS)
- $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
- $(NCRESULT).cmx $(NCRESULT).o \
- REAL_RESULT="$(NCRESULT)" \
- REAL_OCAMLC="$(OCAMLOPT)" \
- PACK_LIB=yes make_deps=yes
-panc: pack-native-code
-
-# generates HTML-documentation
-htdoc: doc/$(RESULT)/html
-
-# generates Latex-documentation
-ladoc: doc/$(RESULT)/latex
-
-# generates PostScript-documentation
-psdoc: doc/$(RESULT)/latex/doc.ps
-
-# generates PDF-documentation
-pdfdoc: doc/$(RESULT)/latex/doc.pdf
-
-# generates all supported forms of documentation
-doc: htdoc ladoc psdoc pdfdoc
-
-###########################################################################
-# LOW LEVEL RULES
-
-$(REAL_RESULT): $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS) $(RESULTDEPS)
- $(REAL_OCAMLFIND) $(REAL_OCAMLC) \
- $(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
- $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
- $(REAL_IMPL)
-
-nolink: $(REAL_IMPL_INTF) $(OBJ_LINK)
-
-ifdef WIN32
-$(REAL_RESULT).dll: $(REAL_IMPL_INTF) $(OBJ_LINK)
- $(CAMLIDLDLL) $(CAMLIDLDLLFLAGS) $(OBJ_LINK) $(CLIBS) \
- -o $@ $(REAL_IMPL)
-endif
-
-%$(TOPSUFFIX): $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS)
- $(REAL_OCAMLFIND) $(OCAMLMKTOP) \
- $(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
- $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
- $(REAL_IMPL)
-
-.SUFFIXES: .mli .ml .cmi .cmo .cmx .cma .cmxa .$(EXT_OBJ) \
- .mly .di .d .$(EXT_LIB) .idl %.oxridl .c .$(EXT_CXX) .h .so \
- .rep .zog .glade
-
-ifndef STATIC
-ifdef MINGW
-$(DLLSONAME): $(OBJ_LINK)
- $(CC) $(CFLAGS) $(CFLAGS_WIN32) $(OBJ_LINK) -shared -o $@ \
- -Wl,--whole-archive $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/lib%.a))) \
- $(OCAMLLIBPATH)/ocamlrun.a \
- -Wl,--export-all-symbols \
- -Wl,--no-whole-archive
-else
-ifdef MSVC
-$(DLLSONAME): $(OBJ_LINK)
- link /NOLOGO /DLL /OUT:$@ $(OBJ_LINK) \
- $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/%.lib))) \
- $(OCAMLLIBPATH)/ocamlrun.lib
-
-else
-$(DLLSONAME): $(OBJ_LINK)
- $(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) \
- -o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=-l%) \
- $(OCAMLMKLIB_FLAGS)
-endif
-endif
-endif
-
-ifndef LIB_PACK_NAME
-$(RESULT).cma: $(REAL_IMPL_INTF) $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
- $(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) \
- $(OBJS_LIBS) -o $@ $(OCAMLBLDFLAGS) $(REAL_IMPL)
-
-$(RESULT).cmxa $(RESULT).$(EXT_LIB): $(REAL_IMPL_INTF) $(EXTRADEPS) $(RESULTDEPS)
- $(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) \
- $(OCAMLNLDFLAGS) -o $@ $(REAL_IMPL)
-else
-ifdef BYTE_OCAML
-$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo: $(REAL_IMPL_INTF)
- $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmo $(REAL_IMPL)
-else
-$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx: $(REAL_IMPL_INTF)
- $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmx $(REAL_IMPL)
-endif
-
-$(RESULT).cma: $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
- $(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) \
- $(OBJS_LIBS) -o $@ $(OCAMLBLDFLAGS) $(LIB_PACK_NAME).cmo
-
-$(RESULT).cmxa $(RESULT).$(EXT_LIB): $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx $(EXTRADEPS) $(RESULTDEPS)
- $(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) \
- $(OCAMLNLDFLAGS) -o $@ $(LIB_PACK_NAME).cmx
-endif
-
-$(RES_CLIB): $(OBJ_LINK)
-ifndef MSVC
- ifneq ($(strip $(OBJ_LINK)),)
- $(AR) rcs $@ $(OBJ_LINK)
- endif
-else
- ifneq ($(strip $(OBJ_LINK)),)
- lib -nologo -debugtype:cv -out:$(RES_CLIB) $(OBJ_LINK)
- endif
-endif
-
-.mli.cmi: $(EXTRADEPS)
- $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
- if [ -z "$$pp" ]; then \
- echo $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
- -c $(THREAD_FLAG) $(ANNOT_FLAG) \
- $(OCAMLFLAGS) $(INCFLAGS) $<; \
- $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
- -c $(THREAD_FLAG) $(ANNOT_FLAG) \
- $(OCAMLFLAGS) $(INCFLAGS) $<; \
- else \
- echo $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
- -c -pp \"$$pp $(PPFLAGS)\" $(THREAD_FLAG) $(ANNOT_FLAG) \
- $(OCAMLFLAGS) $(INCFLAGS) $<; \
- $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
- -c -pp "$$pp $(PPFLAGS)" $(THREAD_FLAG) $(ANNOT_FLAG) \
- $(OCAMLFLAGS) $(INCFLAGS) $<; \
- fi
-
-.ml.cmi .ml.$(EXT_OBJ) .ml.cmx .ml.cmo: $(EXTRADEPS)
- $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
- if [ -z "$$pp" ]; then \
- echo $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
- -c $(ALL_OCAMLCFLAGS) $<; \
- $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
- -c $(ALL_OCAMLCFLAGS) $<; \
- else \
- echo $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
- -c -pp \"$$pp $(PPFLAGS)\" $(ALL_OCAMLCFLAGS) $<; \
- $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
- -c -pp "$$pp $(PPFLAGS)" $(ALL_OCAMLCFLAGS) $<; \
- fi
-
-ifdef PACK_LIB
-$(REAL_RESULT).cmo $(REAL_RESULT).cmx $(REAL_RESULT).o: $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS)
- $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack $(ALL_LDFLAGS) \
- $(OBJS_LIBS) -o $@ $(REAL_IMPL)
-endif
-
-.PRECIOUS: %.ml
-%.ml: %.mll
- $(OCAMLLEX) $<
-
-.PRECIOUS: %.ml %.mli
-%.ml %.mli: %.mly
- $(OCAMLYACC) $(YFLAGS) $<
-
-.PRECIOUS: %.ml
-%.ml: %.rep
- $(CAMELEON_REPORT) $(CAMELEON_REPORT_FLAGS) -gen $<
-
-.PRECIOUS: %.ml
-%.ml: %.zog
- $(CAMELEON_ZOGGY) $(CAMELEON_ZOGGY_FLAGS) -impl $< > $@
-
-.PRECIOUS: %.ml
-%.ml: %.glade
- $(OCAML_GLADECC) $(OCAML_GLADECC_FLAGS) $< > $@
-
-.PRECIOUS: %.ml %.mli
-%.ml %.mli: %.oxridl
- $(OXRIDL) $<
-
-.PRECIOUS: %.ml %.mli %_stubs.c %.h
-%.ml %.mli %_stubs.c %.h: %.idl
- $(CAMLIDL) $(MAYBE_IDL_HEADER) $(IDLFLAGS) \
- $(CAMLIDLFLAGS) $<
- $(QUIET)if [ $(NOIDLHEADER) ]; then touch $*.h; fi
-
-.c.$(EXT_OBJ):
- $(OCAMLC) -c -cc "$(CC)" -ccopt "$(CFLAGS) \
- $(CPPFLAGS) $(CPPFLAGS_WIN32) \
- $(CFLAGS_WIN32) $(CINCFLAGS) $(CFLAG_O)$@ " $<
-
-.$(EXT_CXX).$(EXT_OBJ):
- $(CXX) -c $(CXXFLAGS) $(CINCFLAGS) $(CPPFLAGS) \
- -I'$(OCAMLLIBPATH)' \
- $< $(CFLAG_O)$@
-
-$(MLDEPDIR)/%.d: %.ml
- $(QUIET)echo making $@ from $<
- $(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi
- $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
- if [ -z "$$pp" ]; then \
- $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
- $(DINCFLAGS) $< > $@; \
- else \
- $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
- -pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \
- fi
-
-$(BCDIDIR)/%.di $(NCDIDIR)/%.di: %.mli
- $(QUIET)echo making $@ from $<
- $(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi
- $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
- if [ -z "$$pp" ]; then \
- $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) $(DINCFLAGS) $< > $@; \
- else \
- $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) \
- -pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \
- fi
-
-doc/$(RESULT)/html: $(DOC_FILES)
- rm -rf $@
- mkdir -p $@
- $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
- if [ -z "$$pp" ]; then \
- echo $(OCAMLDOC) -html -d $@ $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \
- $(OCAMLDOC) -html -d $@ $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \
- else \
- echo $(OCAMLDOC) -pp \"$$pp $(PPFLAGS)\" -html -d $@ $(OCAMLDOCFLAGS) \
- $(INCFLAGS) $(DOC_FILES); \
- $(OCAMLDOC) -pp "$$pp $(PPFLAGS)" -html -d $@ $(OCAMLDOCFLAGS) \
- $(INCFLAGS) $(DOC_FILES); \
- fi
-
-doc/$(RESULT)/latex: $(DOC_FILES)
- rm -rf $@
- mkdir -p $@
- $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
- if [ -z "$$pp" ]; then \
- echo $(OCAMLDOC) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) \
- $(DOC_FILES) -o $@/doc.tex; \
- $(OCAMLDOC) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES) \
- -o $@/doc.tex; \
- else \
- echo $(OCAMLDOC) -pp \"$$pp $(PPFLAGS)\" -latex $(OCAMLDOCFLAGS) \
- $(INCFLAGS) $(DOC_FILES) -o $@/doc.tex; \
- $(OCAMLDOC) -pp "$$pp $(PPFLAGS)" -latex $(OCAMLDOCFLAGS) \
- $(INCFLAGS) $(DOC_FILES) -o $@/doc.tex; \
- fi
-
-doc/$(RESULT)/latex/doc.ps: doc/$(RESULT)/latex
- cd doc/$(RESULT)/latex && \
- $(LATEX) doc.tex && \
- $(LATEX) doc.tex && \
- $(DVIPS) $(DVIPSFLAGS) doc.dvi -o $(@F)
-
-doc/$(RESULT)/latex/doc.pdf: doc/$(RESULT)/latex/doc.ps
- cd doc/$(RESULT)/latex && $(PS2PDF) $(
+ let tm = Unix.localtime time in
+ if level <= !max_level then begin
+ if !ddate then
+ Printf.printf "%04d-%02d-%02d " (tm.Unix.tm_year + 1900)
+ (tm.Unix.tm_mon + 1) tm.Unix.tm_mday;
+ if !dtime then begin
+ Printf.printf "%02d:%02d:%02d " tm.Unix.tm_hour tm.Unix.tm_min
+ tm.Unix.tm_sec;
+ if !ddecimal then Printf.printf "%f " (time -. floor time)
+ end;
+ Printf.printf "[%20s:%d]\n>>> %s\n" label level str
+ end
+ | None -> Printf.printf "-?-\n"
+ end;
+ h f
+ with End_of_file -> ()
+ in
+ let f = open_in file in
+ h f;
+ close_in f
+
+let parse_args =
+ Arg.parse
+ [
+ ("-l", Arg.String (fun l -> max_level := int_of_string l), "level");
+ ("-nd", Arg.Unit (fun () -> ddate := false), "no date");
+ ("-nt", Arg.Unit (fun () -> dtime := false), "no time");
+ ("-d", Arg.Unit (fun () -> ddecimal := true), "decimals");
+ ]
+ (fun s -> disp s)
+ (Printf.sprintf "usage : %s [options]" (Filename.basename Sys.argv.(0)))