-1

我想向 ntpd 添加一个新选项,但是在向例如ntpd/ntpd-opts{.c, .h}添加一些行后我找不到如何生成,ntpd/ntpdbase-opts.def

$ git diff ntpd/ntpdbase-opts.def
diff --git a/ntpd/ntpdbase-opts.def b/ntpd/ntpdbase-opts.def
index 66b953528..a790cbd51 100644
--- a/ntpd/ntpdbase-opts.def
+++ b/ntpd/ntpdbase-opts.def
@@ -479,3 +479,13 @@ flag = {
        the server to be discovered via mDNS client lookup.
        _EndOfDoc_;
 };
+
+flag = {
+    name      = foo;
+    value     = F;
+    arg-type  = number;
+    descrip   = "Some new option";
+    doc = <<-  _EndOfDoc_
+       For testing purpose only.
+       _EndOfDoc_;
+};

你有什么想法?

4

2 回答 2

1

如何在向 ntpd/ntpdbase-opts.def 添加一些行后生成 ntpd/ntpd-opts{.c, .h}

它只是在构建脚本中。只需正常编译https://github.com/ntp-project/ntp/blob/master-no-authorname/INSTALL#L30它,make 就会把它捡起来。

https://github.com/ntp-project/ntp/blob/master-no-authorname/ntpd/Makefile.am#L304

https://github.com/ntp-project/ntp/blob/master-no-authorname/ntpd/Makefile.am#L183

于 2022-02-25T08:55:59.073 回答
0

除了@KamilCuk 的回答,我们还需要执行以下操作来添加自定义选项:

  1. 编辑*.def文件
  2. 运行bootstrap脚本
  3. 使用选项运行configure脚本--disable-local-libopts
  4. 运行制作

例如,

$ git diff ntpd/ntpdbase-opts.def
diff --git a/ntpd/ntpdbase-opts.def b/ntpd/ntpdbase-opts.def
index 66b953528..a790cbd51 100644
--- a/ntpd/ntpdbase-opts.def
+++ b/ntpd/ntpdbase-opts.def
@@ -479,3 +479,13 @@ flag = {
        the server to be discovered via mDNS client lookup.
        _EndOfDoc_;
 };
+
+flag = {
+    name      = foo;
+    value     = F;
+    arg-type  = number;
+    descrip   = "Some new option";
+    doc = <<-  _EndOfDoc_
+       For testing purpose only.
+       _EndOfDoc_;
+};

这种变化产生:

$ ./ntpd --help
ntpd - NTP daemon program - Ver. 4.2.8p15
Usage:  ntpd [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \
                [ <server1> ... <serverN> ]
  Flg Arg Option-Name    Description
   -4 no  ipv4           Force IPv4 DNS name resolution
                                - prohibits the option 'ipv6'
   ...
   -F Num foo            Some new option
      opt version        output version information and exit
   -? no  help           display extended usage information and exit
   -! no  more-help      extended usage information passed thru pager

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.
...
于 2022-02-25T16:43:55.793 回答