[ntpsec-main commit] Build manpages and install if a2x exists.
Amar Takhar
amar at ntpsec.org
Thu Nov 12 21:27:12 UTC 2015
Module: ntpsec-main
Branch: master
Commit: bffbdc46073d8a937ae26b138befc1016b7251dd
Changeset: http://git.ntpsec.org//commit/?id=bffbdc46073d8a937ae26b138befc1016b7251dd
Author: Amar Takhar <verm at darkbeer.org>
Date: Thu Nov 12 16:25:48 2015 -0500
Build manpages and install if a2x exists.
* This is a bit of a hack to work around several issues.
* xsltproc -o <file> does not work when generating manpages.
* asciidoc doesn't have a way to set the base include path so
relative links break.
---
ntpd/wscript | 2 ++
ntpdig/wscript | 2 ++
ntpfrob/wscript | 2 +-
ntpkeygen/wscript | 1 +
ntpq/wscript | 1 +
ntptime/wscript | 5 ++---
pylib/asciidoc.py | 15 +++++++++++++++
pylib/configure.py | 6 +++++-
pylib/waf.py | 14 ++++++++++++++
util/wscript | 2 +-
wscript | 20 ++++++--------------
11 files changed, 50 insertions(+), 20 deletions(-)
diff --git a/ntpd/wscript b/ntpd/wscript
index 4581217..17efeef 100644
--- a/ntpd/wscript
+++ b/ntpd/wscript
@@ -165,3 +165,5 @@ def build(ctx):
],
install_path= "${PREFIX}/bin/",
)
+
+ ctx.manpage(8, "ntpd-man.txt")
diff --git a/ntpdig/wscript b/ntpdig/wscript
index 8010fc9..fc24cd3 100644
--- a/ntpdig/wscript
+++ b/ntpdig/wscript
@@ -35,3 +35,5 @@ def build(ctx):
] + ctx.env.PLATFORM_INCLUDES, # XXX: Hack needs to use libevent_inc or something else.
install_path= "${PREFIX}/bin/",
)
+
+ ctx.manpage(1, "ntpdig-man.txt")
diff --git a/ntpfrob/wscript b/ntpfrob/wscript
index 924934e..d22106a 100644
--- a/ntpfrob/wscript
+++ b/ntpfrob/wscript
@@ -18,4 +18,4 @@ def build(ctx):
install_path = "${PREFIX}/bin/"
)
-
+ ctx.manpage(8, "ntpfrob-man.txt")
diff --git a/ntpkeygen/wscript b/ntpkeygen/wscript
index e389ee5..1f157a9 100644
--- a/ntpkeygen/wscript
+++ b/ntpkeygen/wscript
@@ -20,3 +20,4 @@ def build(ctx):
install_path= "${PREFIX}/bin/"
)
+ ctx.manpage(8, "ntpkeygen-man.txt")
diff --git a/ntpq/wscript b/ntpq/wscript
index 2983730..999470a 100644
--- a/ntpq/wscript
+++ b/ntpq/wscript
@@ -33,3 +33,4 @@ def build(ctx):
install_path= "${PREFIX}/bin/",
)
+ ctx.manpage(1, "ntpq-man.txt")
diff --git a/ntptime/wscript b/ntptime/wscript
index 5ee1260..7b8d3da 100644
--- a/ntptime/wscript
+++ b/ntptime/wscript
@@ -16,7 +16,6 @@ def build(ctx):
install_path = "${PREFIX}/bin/"
)
-# end
-
-
+ ctx.manpage(8, "ntptime-man.txt")
+# end
diff --git a/pylib/asciidoc.py b/pylib/asciidoc.py
index c0b9d8a..19c85c5 100644
--- a/pylib/asciidoc.py
+++ b/pylib/asciidoc.py
@@ -16,3 +16,18 @@ def run_asciidoc(self, node):
tsk = self.create_task("asciidoc", node, [out])
tsk.cwd = node.parent.get_bld().abspath()
+
+class a2x(Task.Task):
+ color = "YELLOW"
+ shell = True
+ run_str = '${BIN_A2X} ${A2X_FLAGS} ${SRC[0].abspath()}'
+
+
+ at extension('.man-tmp')
+def run_a2x(self, node):
+ n_file = node.path_from(self.bld.bldnode)
+ out = "%s.%s" % (n_file.replace("-man.txt.man-tmp", ""), self.section)
+ out_n = self.bld.path.find_or_declare(out)
+ tsk = self.create_task('a2x', node, out_n)
+ self.bld.install_files("${PREFIX}/man%s/" % self.section, out_n)
+
diff --git a/pylib/configure.py b/pylib/configure.py
index fc675e4..a074161 100644
--- a/pylib/configure.py
+++ b/pylib/configure.py
@@ -79,7 +79,7 @@ def cmd_configure(ctx):
ctx.find_program("perl", var="BIN_PERL")
ctx.find_program("sh", var="BIN_SH")
ctx.find_program("asciidoc", var="BIN_ASCIIDOC", mandatory=False)
- ctx.find_program("a2x", var="BIN_ASCIIDOC", mandatory=False)
+ ctx.find_program("a2x", var="BIN_A2X", mandatory=False)
if ctx.options.enable_doc and not ctx.env.BIN_ASCIIDOC:
ctx.fatal("asciidoc is required in order to build documentation")
@@ -87,6 +87,10 @@ def cmd_configure(ctx):
ctx.env.ASCIIDOC_FLAGS = ["-f", "%s/docs/asciidoc.conf" % ctx.srcnode.abspath(), "-a", "stylesdir=%s/docs/" % ctx.srcnode.abspath()]
ctx.env.ENABLE_DOC = True
+ # XXX: conditionally build this with --disable-man? Should it build without docs enabled?
+ ctx.env.A2X_FLAGS = ["--format", "manpage", "--asciidoc-opts=--conf-file=%s/docs/asciidoc.conf" % ctx.srcnode.abspath()]
+
+
from os.path import exists
from waflib.Utils import subprocess
diff --git a/pylib/waf.py b/pylib/waf.py
index fb4b6d9..88e7e4c 100644
--- a/pylib/waf.py
+++ b/pylib/waf.py
@@ -49,3 +49,17 @@ def ntp_version(self):
tsk.env.TARGET = self.target
self.source.extend([n])
+
+def manpage_subst_fun(task, text):
+ return text.replace("include::../docs/", "include::../../docs/")
+
+ at conf
+def manpage(ctx, section, source):
+ ctx(
+ features = "subst",
+ source = source,
+ target = source + '.man-tmp',
+ subst_fun = manpage_subst_fun
+ )
+
+ ctx(source=source + '.man-tmp', section=section)
diff --git a/util/wscript b/util/wscript
index 1e3e928..901f703 100644
--- a/util/wscript
+++ b/util/wscript
@@ -20,4 +20,4 @@ def build(ctx):
install_path = False
)
-
+ ctx.manpage(1, "ntpsweep/ntpsweep-man.txt")
diff --git a/wscript b/wscript
index 4c337a5..5c485ca 100644
--- a/wscript
+++ b/wscript
@@ -87,12 +87,11 @@ def configure(ctx):
def build(ctx):
ctx.load('waf', tooldir='pylib/')
ctx.load('bison')
+ ctx.load('asciidoc', tooldir='pylib/')
if ctx.env.ENABLE_DOC:
- ctx.load('asciidoc', tooldir='pylib/')
ctx.recurse("docs")
-
ctx.recurse("libisc")
if ctx.env.REFCLOCK_PARSE: # Only required by the parse refclock
ctx.recurse("libparse")
@@ -121,18 +120,10 @@ def build(ctx):
chmod = Utils.O755
)
- man_sources = [
- "ntpd/ntpd-man.txt",
- "ntpdig/ntpdig-man.txt",
- "ntpfrob/ntpfrob-man.txt",
- "ntpkeygen/ntpkeygen-man.txt",
- "ntpleapfetch/ntpleapfetch-man.txt",
- "ntpq/ntpq-man.txt",
- "ntptime/ntptime-man.txt",
- "ntptrace/ntptrace-man.txt",
- "ntpwait/ntpwait-man.txt",
- "scripts/ntpsweep/ntpsweep-man.txt",
- ]
+ ctx.manpage(8, "ntpleapfetch/ntpleapfetch-man.txt")
+ ctx.manpage(8, "ntpwait/ntpwait-man.txt")
+ ctx.manpage(1, "ntptrace/ntptrace-man.txt")
+
#ctx(
# features = "subst",
@@ -141,3 +132,4 @@ def build(ctx):
#)
# end
+
More information about the vc
mailing list