From f24a94eab53e5cd9e54860f30471ef76ead5fdee Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Mon, 18 Mar 2013 13:59:45 +1030 Subject: [PATCH] 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 --- Makefile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 3e047991..d2c05cd6 100644 --- a/Makefile +++ b/Makefile @@ -198,21 +198,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 DEPFILES = \