GNU autotools 項目中與生成手冊有關的“make distcheck”問題
我正在使用
autoconf
並automake
建構一個小項目。對於該項目的手冊,我使用了 OpenBSD 的原生
mdoc
格式man
,並且使用該mandoc
實用程序生成了可安裝格式的手冊。-formattedman
手冊將作為實際手冊安裝make install
,因為某些系統無法mdoc
正確理解或根本無法正確理解。在項目的
doc
目錄中,我有一個Makefile.am
目前如下所示的文件(手冊適用於名為 的實用程序shell
):dist_man1_MANS= shell.man EXTRA_DIST= shell.mdoc shell.man: shell.mdoc $(mandoc) -T man shell.mdoc >shell.man
$(mandoc)
將正確擴展為mandoc
格式化程序的完整路徑(此變數由configure
腳本設置)。這允許我執行
make dist
它創建shell.man
然後創建一個壓縮tar
存檔,其中包含源mdoc
手冊和生成的man
手冊以及項目的其餘分發文件:$ tar tzf shell-toolbox-20180401.tar.gz ... shell-toolbox-20180401/doc/Makefile.am shell-toolbox-20180401/doc/shell.man shell-toolbox-20180401/doc/Makefile.in shell-toolbox-20180401/doc/shell.mdoc
此
tar
存檔稍後可用於成功建構和安裝項目及其手冊。到現在為止還挺好。但是,如果我跑步
make distcheck
(因為我想確保它絕對有效):$ make distcheck ... checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for mandoc... /usr/bin/mandoc checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating doc/Makefile config.status: creating src/shell Making all in src Making all in doc /usr/bin/mandoc -T man shell.mdoc >shell.man mandoc: shell.mdoc: ERROR: No such file or directory *** Error 3 in shell-toolbox-20180401/_build/sub/doc (Makefile:459 'shell.man') *** Error 1 in shell-toolbox-20180401/_build/sub (Makefile:345 'all-recursive') *** Error 1 in /home/myself/local/build/shell-toolbox (Makefile:576 'distcheck')
當需要建構手冊時,似乎源
mdoc
文件在建構目錄中不可用:$ ls shell-toolbox-20180401/_build/sub/doc total 32 -rw-r--r-- 1 myself myself 14989 Apr 1 21:35 Makefile -rw-r--r-- 1 myself myself 0 Apr 1 21:35 shell.man
零長度
shell.man
文件來自失敗的mandoc
執行。原始碼在解壓後的存檔中可用,但沒有復製到
_build/sub/doc
目錄中:$ ls -l shell-toolbox-20180401/doc total 48 -r--r--r-- 1 myself myself 178 Apr 1 21:23 Makefile.am -r--r--r-- 1 myself myself 13925 Apr 1 21:23 Makefile.in -r--r--r-- 1 myself myself 3443 Apr 1 21:27 shell.man -r--r--r-- 1 myself myself 3319 Apr 1 18:54 shell.mdoc
問題:在嘗試生成-formatted 手冊之前,
automake
我必須應用什麼魔法才能將源make distcheck
正確複製到建構目錄?我正在尋找一種“正確”的方式來做到這一點,而不是黑客。mdoc``man
我嘗試使用
man1_SOURCES= shell.mdoc
但這讓人
automake
抱怨doc/Makefile.am:2: warning: variable 'man1_SOURCES' is defined but no program or doc/Makefile.am:2: library has 'man1' as canonical name (possible typo)
引發此錯誤的另一種方法是手動進行VPATH 建構(這基本上是在做時發生的事情
make distcheck
):$ make distclean $ mkdir t $ cd t $ ../configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking for mandoc... /usr/bin/mandoc checking that generated files are newer than configure... done configure: creating ./config.status config.status: creating Makefile config.status: creating src/Makefile config.status: creating doc/Makefile config.status: creating src/shell $ make Making all in src Making all in doc /usr/bin/mandoc -T man shell.mdoc >shell.man mandoc: shell.mdoc: ERROR: No such file or directory *** Error 3 in doc (Makefile:459 'shell.man') *** Error 1 in /home/myself/local/build/shell-toolbox/t (Makefile:345 'all-recursive') $ ls -l doc total 32 -rw-r--r-- 1 myself myself 14589 Apr 1 22:42 Makefile -rw-r--r-- 1 myself myself 0 Apr 1 22:42 shell.man
解決方案:為了在執行 VPATH 建構時正確獲取手冊的原始碼,
Makefile.am
文件相關部分中的規則應如下所示shell.man: $(srcdir)/shell.mdoc $(mandoc) -T man $(srcdir)/shell.mdoc >shell.man
通過指定
$(srcdir)/shell.mdoc
,make
將在分發樹中找到文件,即使建構樹與分發樹位於不同的位置。
automake
在一些不同的目標之前和之後執行的支持-local
和規則。-hook
顯然沒有distcheck-local
另一個想法是在您Makefile.am
使用dist-hook
之後執行某些東西dist
:dist-hook: cp something $(distdir)/somewhere