Now that so many lib/*.[ch] files in coreutils are generated, it is harder for me to know when a file comes from gnulib and when I can modify it in place. I've always taken the stand that generated files should be read-only, and this is just another reason to follow that policy. [ I learned long enough ago that files like Makefile, Makefile.in, configure, etc. are generated, so that their being writable isn't a big deal. But still, for novices, it'd be nice to make them read-only, too. I'll save that as a project for another day :-) ]
To that end, I've just changed coreutils' bootstrap script to make some of the files it copies into my tree be read-only. However, that exposed a weakness in the gnulib-generated rules that look(ed) like this: alloca.h: alloca_.h cp $(srcdir)/alloca_.h [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ That rule fails (from my perspective) when the target (alloca.h) is read-only, since with an interactive "make", mv would ask me if I want to remove it. The patch below fixes that by removing the targets of cp and mv at the beginning of the rule. In addition, it ensures that the generated file is read-only: alloca.h: alloca_.h rm -f [EMAIL PROTECTED] $@ cp $(srcdir)/alloca_.h [EMAIL PROTECTED] chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ Here's the patch I've just checked in: Note that this does affect modules/* files owned by others. If anyone objects, I'll quickly revert the objectionable change. Bruno, would you mind if I changed the uses of "t-$@" to "[EMAIL PROTECTED]" in modules/localcharset? That minor inconsistency nearly made me miss the two rules in that file. 2006-09-06 Jim Meyering <[EMAIL PROTECTED]> Make generated files be read-only. * modules/alloca-opt (Makefile.am): Work also when $@ is read-only. Ensure that each generated file is now read-only. * modules/argz: Likewise. * modules/arpa_inet: Likewise. * modules/byteswap: Likewise. * modules/configmake: Likewise. * modules/fcntl: Likewise. * modules/fnmatch: Likewise. * modules/getopt: Likewise. * modules/glob: Likewise. * modules/inttypes: Likewise. * modules/netinet_in: Likewise. * modules/poll: Likewise. * modules/stdbool: Likewise. * modules/stdint: Likewise. * modules/sys_select: Likewise. * modules/sys_socket: Likewise. * modules/sys_stat: Likewise. * modules/sysexits: Likewise. * modules/localcharset: Same as above, but continue using temporary file named "t-$@" (why different?) rather than the "[EMAIL PROTECTED]" used everywhere else. * modules/sysexits (Makefile.am): Replace literal occurrences of "sysexit.h" more readable, and more consistent, "$@". Index: modules/alloca-opt =================================================================== RCS file: /sources/gnulib/gnulib/modules/alloca-opt,v retrieving revision 1.2 diff -u -r1.2 alloca-opt --- modules/alloca-opt 22 Jul 2005 22:04:12 -0000 1.2 +++ modules/alloca-opt 6 Sep 2006 21:29:55 -0000 @@ -19,7 +19,9 @@ # We need the following in order to create <alloca.h> when the system # doesn't have one that works with the given compiler. alloca.h: alloca_.h + rm -f [EMAIL PROTECTED] $@ cp $(srcdir)/alloca_.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += alloca.h alloca.h-t Index: modules/argz =================================================================== RCS file: /sources/gnulib/gnulib/modules/argz,v retrieving revision 1.4 diff -u -r1.4 argz --- modules/argz 22 Jul 2005 22:04:12 -0000 1.4 +++ modules/argz 6 Sep 2006 21:29:55 -0000 @@ -18,7 +18,9 @@ # We need the following in order to create <argz.h> when the system # doesn't have one that works with the given compiler. argz.h: argz_.h + rm -f [EMAIL PROTECTED] $@ cp $(srcdir)/argz_.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += argz.h argz.h-t Index: modules/arpa_inet =================================================================== RCS file: /sources/gnulib/gnulib/modules/arpa_inet,v retrieving revision 1.1 diff -u -r1.1 arpa_inet --- modules/arpa_inet 7 Jul 2006 07:41:25 -0000 1.1 +++ modules/arpa_inet 6 Sep 2006 21:29:55 -0000 @@ -17,7 +17,9 @@ # doesn't have one. arpa/inet.h: test -d arpa || mkdir arpa + rm -f [EMAIL PROTECTED] $@ echo '#include <sys/socket.h>' >[EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t MOSTLYCLEANDIRS += arpa Index: modules/byteswap =================================================================== RCS file: /sources/gnulib/gnulib/modules/byteswap,v retrieving revision 1.3 diff -u -r1.3 byteswap --- modules/byteswap 29 Aug 2005 11:13:56 -0000 1.3 +++ modules/byteswap 6 Sep 2006 21:29:55 -0000 @@ -17,7 +17,9 @@ # We need the following in order to create <byteswap.h> when the system # doesn't have one. byteswap.h: byteswap_.h + rm -f [EMAIL PROTECTED] $@ cp $(srcdir)/byteswap_.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += byteswap.h byteswap.h-t Index: modules/configmake =================================================================== RCS file: /sources/gnulib/gnulib/modules/configmake,v retrieving revision 1.3 diff -u -r1.3 configmake --- modules/configmake 29 Aug 2006 15:50:43 -0000 1.3 +++ modules/configmake 6 Sep 2006 21:29:55 -0000 @@ -24,6 +24,7 @@ # # Listed in the same order as the GNU makefile conventions. configmake.h: Makefile + rm -f [EMAIL PROTECTED] $@ ( \ echo '#define PREFIX "$(prefix)"'; \ echo '#define EXEC_PREFIX "$(exec_prefix)"'; \ @@ -49,6 +50,7 @@ echo '#define MANDIR "$(mandir)"'; \ echo '#define MANEXT "$(manext)"'; \ :) | sed '/""/d' >[EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ BUILT_SOURCES += configmake.h CLEANFILES += configmake.h configmake.h-t Index: modules/fcntl =================================================================== RCS file: /sources/gnulib/gnulib/modules/fcntl,v retrieving revision 1.1 diff -u -r1.1 fcntl --- modules/fcntl 28 Aug 2006 22:59:17 -0000 1.1 +++ modules/fcntl 6 Sep 2006 21:29:55 -0000 @@ -19,8 +19,10 @@ # We need the following in order to create <fcntl.h> when the system # doesn't have one that works with the given compiler. fcntl.h: fcntl_.h + rm -f [EMAIL PROTECTED] $@ sed -e 's|@''ABSOLUTE_FCNTL_H''@|$(ABSOLUTE_FCNTL_H)|g' \ < $(srcdir)/fcntl_.h > [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += fcntl.h fcntl.h-t Index: modules/fnmatch =================================================================== RCS file: /sources/gnulib/gnulib/modules/fnmatch,v retrieving revision 1.9 diff -u -r1.9 fnmatch --- modules/fnmatch 22 Jul 2005 22:04:12 -0000 1.9 +++ modules/fnmatch 6 Sep 2006 21:29:55 -0000 @@ -22,7 +22,9 @@ # We need the following in order to create <fnmatch.h> when the system # doesn't have one that supports the required API. fnmatch.h: fnmatch_.h + rm -f [EMAIL PROTECTED] $@ cp $(srcdir)/fnmatch_.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t Index: modules/getopt =================================================================== RCS file: /sources/gnulib/gnulib/modules/getopt,v retrieving revision 1.10 diff -u -r1.10 getopt --- modules/getopt 7 Mar 2006 13:30:51 -0000 1.10 +++ modules/getopt 6 Sep 2006 21:29:55 -0000 @@ -22,7 +22,9 @@ # We need the following in order to create <getopt.h> when the system # doesn't have one that works with the given compiler. getopt.h: getopt_.h + rm -f [EMAIL PROTECTED] $@ cp $(srcdir)/getopt_.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += getopt.h getopt.h-t Index: modules/glob =================================================================== RCS file: /sources/gnulib/gnulib/modules/glob,v retrieving revision 1.7 diff -u -r1.7 glob --- modules/glob 21 Aug 2006 21:46:31 -0000 1.7 +++ modules/glob 6 Sep 2006 21:29:55 -0000 @@ -30,7 +30,9 @@ # We need the following in order to create <glob.h> when the system # doesn't have one that works with the given compiler. glob.h: glob_.h + rm -f [EMAIL PROTECTED] $@ cp $(srcdir)/glob_.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += glob.h glob.h-t Index: modules/inttypes =================================================================== RCS file: /sources/gnulib/gnulib/modules/inttypes,v retrieving revision 1.8 diff -u -r1.8 inttypes --- modules/inttypes 28 Aug 2006 18:41:49 -0000 1.8 +++ modules/inttypes 6 Sep 2006 21:29:55 -0000 @@ -21,6 +21,7 @@ # We need the following in order to create <inttypes.h> when the system # doesn't have one that works with the given compiler. inttypes.h: inttypes_.h + rm -f [EMAIL PROTECTED] $@ sed -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ -e 's|@''ABSOLUTE_INTTYPES_H''@|$(ABSOLUTE_INTTYPES_H)|g' \ -e 's/@''PRI_MACROS_BROKEN''@/$(PRI_MACROS_BROKEN)/g' \ @@ -31,6 +32,7 @@ -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \ -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \ < $(srcdir)/inttypes_.h > [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += inttypes.h inttypes.h-t Index: modules/netinet_in =================================================================== RCS file: /sources/gnulib/gnulib/modules/netinet_in,v retrieving revision 1.1 diff -u -r1.1 netinet_in --- modules/netinet_in 28 Jul 2006 17:27:29 -0000 1.1 +++ modules/netinet_in 6 Sep 2006 21:29:55 -0000 @@ -17,7 +17,9 @@ # doesn't have one. netinet/in.h: test -d netinet || mkdir netinet + rm -f [EMAIL PROTECTED] $@ echo '#include <sys/socket.h>' >[EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t MOSTLYCLEANDIRS += netinet Index: modules/poll =================================================================== RCS file: /sources/gnulib/gnulib/modules/poll,v retrieving revision 1.7 diff -u -r1.7 poll --- modules/poll 27 Sep 2005 21:37:06 -0000 1.7 +++ modules/poll 6 Sep 2006 21:29:55 -0000 @@ -18,7 +18,9 @@ # We need the following in order to create <poll.h> when the system # doesn't have one. poll.h: poll_.h + rm -f [EMAIL PROTECTED] $@ cp $(srcdir)/poll_.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += poll.h poll.h-t Index: modules/stdbool =================================================================== RCS file: /sources/gnulib/gnulib/modules/stdbool,v retrieving revision 1.11 diff -u -r1.11 stdbool --- modules/stdbool 22 Jul 2005 22:04:12 -0000 1.11 +++ modules/stdbool 6 Sep 2006 21:29:55 -0000 @@ -18,7 +18,9 @@ # We need the following in order to create <stdbool.h> when the system # doesn't have one that works. stdbool.h: stdbool_.h + rm -f [EMAIL PROTECTED] $@ sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += stdbool.h stdbool.h-t Index: modules/stdint =================================================================== RCS file: /sources/gnulib/gnulib/modules/stdint,v retrieving revision 1.11 diff -u -r1.11 stdint --- modules/stdint 28 Aug 2006 20:42:18 -0000 1.11 +++ modules/stdint 6 Sep 2006 21:29:55 -0000 @@ -24,6 +24,7 @@ # We need the following in order to create <stdint.h> when the system # doesn't have one that works with the given compiler. stdint.h: stdint_.h + rm -f [EMAIL PROTECTED] $@ sed -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ -e 's|@''ABSOLUTE_STDINT_H''@|$(ABSOLUTE_STDINT_H)|g' \ @@ -46,6 +47,7 @@ -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \ -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \ < $(srcdir)/stdint_.h > [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += stdint.h stdint.h-t Index: modules/sys_select =================================================================== RCS file: /sources/gnulib/gnulib/modules/sys_select,v retrieving revision 1.1 diff -u -r1.1 sys_select --- modules/sys_select 27 Jun 2006 21:21:13 -0000 1.1 +++ modules/sys_select 6 Sep 2006 21:29:55 -0000 @@ -17,7 +17,9 @@ # doesn't have one that works with the given compiler. sys/select.h: test -d sys || mkdir sys + rm -f [EMAIL PROTECTED] $@ echo '#include <sys/socket.h>' >[EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += sys/select.h sys/select.h-t MOSTLYCLEANDIRS += sys Index: modules/sys_socket =================================================================== RCS file: /sources/gnulib/gnulib/modules/sys_socket,v retrieving revision 1.4 diff -u -r1.4 sys_socket --- modules/sys_socket 6 Jul 2006 13:53:54 -0000 1.4 +++ modules/sys_socket 6 Sep 2006 21:29:55 -0000 @@ -19,7 +19,9 @@ # doesn't have one that works with the given compiler. sys/socket.h: socket_.h test -d sys || mkdir sys + rm -f [EMAIL PROTECTED] $@ cp $(srcdir)/socket_.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t MOSTLYCLEANDIRS += sys Index: modules/sys_stat =================================================================== RCS file: /sources/gnulib/gnulib/modules/sys_stat,v retrieving revision 1.2 diff -u -r1.2 sys_stat --- modules/sys_stat 4 Jul 2006 06:37:10 -0000 1.2 +++ modules/sys_stat 6 Sep 2006 21:29:55 -0000 @@ -19,8 +19,10 @@ # has one that is incomplete. sys/stat.h: stat_.h test -d sys || mkdir sys + rm -f [EMAIL PROTECTED] $@ sed -e 's|@''ABSOLUTE_SYS_STAT_H''@|$(ABSOLUTE_SYS_STAT_H)|g' \ < $(srcdir)/stat_.h > [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t MOSTLYCLEANDIRS += sys Index: modules/sysexits =================================================================== RCS file: /sources/gnulib/gnulib/modules/sysexits,v retrieving revision 1.6 diff -u -r1.6 sysexits --- modules/sysexits 11 Oct 2005 06:53:48 -0000 1.6 +++ modules/sysexits 6 Sep 2006 21:29:55 -0000 @@ -17,8 +17,10 @@ # We need the following in order to create <sysexits.h> when the system # doesn't have one that works with the given compiler. sysexits.h: sysexit_.h - cp $(srcdir)/sysexit_.h sysexits.h-t - mv sysexits.h-t sysexits.h + rm -f [EMAIL PROTECTED] $@ + cp $(srcdir)/sysexit_.h [EMAIL PROTECTED] + chmod a-x [EMAIL PROTECTED] + mv [EMAIL PROTECTED] $@ MOSTLYCLEANFILES += sysexits.h sysexits.h-t Include: Index: modules/localcharset =================================================================== RCS file: /sources/gnulib/gnulib/modules/localcharset,v retrieving revision 1.7 diff -u -r1.7 localcharset --- modules/localcharset 29 Aug 2006 15:44:02 -0000 1.7 +++ modules/localcharset 6 Sep 2006 21:29:55 -0000 @@ -59,12 +59,16 @@ fi charset.alias: config.charset + rm -f t-$@ $@ $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ + chmod a-x t-$@ mv t-$@ $@ SUFFIXES += .sed .sin .sin.sed: + rm -f t-$@ $@ sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ + chmod a-x t-$@ mv t-$@ $@ CLEANFILES += charset.alias ref-add.sed ref-del.sed