From 8ea1c520a237586f2c1909c7b9cd3223414a5d1c Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@fb.com>
Date: Fri, 31 Oct 2014 18:40:50 -0500
Subject: [PATCH] build: generate man pages even when existing targets are
 read-only

* doc/Makefile.am (grep.1): Use mv -f to move temporary to target,
in case the target is read-only.  Also, always make the generated
files read-only.
(egrep.1 fgrep.1): Likewise.
This avoids a build failure reported by Eric Blake in
http://lists.gnu.org/archive/html/bug-grep/2014-10/msg00112.html
---
 doc/Makefile.am | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/doc/Makefile.am b/doc/Makefile.am
index 9a50434..684c1db 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -25,10 +25,14 @@ EXTRA_DIST = grep.in.1
 CLEANFILES = grep.1 egrep.1 fgrep.1

 grep.1: grep.in.1
-	$(AM_V_GEN)sed 's/@''VERSION@/$(VERSION)/' < $(srcdir)/grep.in.1 > $@-t
-	$(AM_V_at)mv $@-t $@
+	$(AM_V_GEN)rm -f $@-t $@
+	$(AM_V_at)sed 's/@''VERSION@/$(VERSION)/' $(srcdir)/grep.in.1 > $@-t
+	$(AM_V_at)chmod a=r $@-t
+	$(AM_V_at)mv -f $@-t $@

 egrep.1 fgrep.1: Makefile.am
-	$(AM_V_GEN)inst=`echo grep | sed '$(transform)'`.1 \
+	$(AM_V_GEN)rm -f $@-t $@
+	$(AM_V_at)inst=`echo grep | sed '$(transform)'`.1 \
 	  && echo ".so man1/$$inst" > $@-t
-	$(AM_V_at)mv $@-t $@
+	$(AM_V_at)chmod a=r $@-t
+	$(AM_V_at)mv -f $@-t $@
-- 
2.1.2

