build: improve man2txt and man2html rules

* Output to temp file and only move to final location upon success
* Fix echo of command in verbose mode (requires quotes)
* Don't use $(call ...) to invoke the groff command
* Use printf to generate the \r for the sed "unix2dos" replacement

Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
Kevin Shanahan 2013-03-18 13:49:15 +10:30
parent 033c77328c
commit 679e3de254

View File

@ -359,21 +359,24 @@ quiet_cmd_man2txt = ' MAN2TXT $@'
cmd_man2txt = \
$(GROFF) -man -Tascii $< | cat -v | \
sed -e 's/\^\[\[\([0-9]\)\{1,2\}[a-z]//g' \
-e 's/$$/'`echo \\\r`'/' > $@
-e 's/$$/'`printf \\\r`'/' > $(@D)/.$(@F).tmp && \
mv $(@D)/.$(@F).tmp $@
define do_man2txt
@$(do_mkdir)
@echo $($(quiet)cmd_man2txt);
@$(call cmd_man2txt);
@echo $(if $(quiet),$(quiet_cmd_man2txt),"$(cmd_man2txt)");
@$(cmd_man2txt);
endef
quiet_cmd_man2html = ' MAN2HTML $@'
cmd_man2html = $(GROFF) -man -Thtml $< > $@
cmd_man2html = \
$(GROFF) -man -Thtml $< > $(@D)/.$(@F).tmp && \
mv $(@D)/.$(@F).tmp $@
define do_man2html
@$(do_mkdir)
@echo $($(quiet)cmd_man2html);
@$(call cmd_man2html);
@echo $(if $(quiet),$(quiet_cmd_man2html),"$(cmd_man2html)");
@$(cmd_man2html);
endef