bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ensure that generated files are read-only


From: Jim Meyering
Subject: Re: ensure that generated files are read-only
Date: Thu, 07 Sep 2006 08:49:21 +0200

Paul Eggert <address@hidden> wrote:
> Jim Meyering <address@hidden> writes:
>
>> alloca.h: alloca_.h
>>      rm -f address@hidden $@
>>      cp $(srcdir)/alloca_.h address@hidden
>>      chmod a-x address@hidden
>>      mv address@hidden $@
>
> One other thing -- how about if we just remove the 'chmod' entirely?
> If the source is readonly, that'd make the destination readonly.
> Plus it wouldn't bother people who prefer to have read-write files,

Do you know anyone who prefers that their generated files be writable?

> and it'd save a command and a line of 'make' output.
>
> An even shorter possibility would be:
>
> alloca.h: alloca_.h
>       cp -f $(srcdir)/alloca_.h address@hidden
>       mv -f address@hidden $@
>
> This relies on 'cp -f' and 'mv -f', but that's universal nowadays, no?
> (If not, we could autoconfize it.)

Considering the numerous uses of sed and echo (in place of cp)
I preferred to be consistent.  But I agree that it'd be better
not to pollute the build output with output that is 99% irrelevant.
So, how about prefixing each new line with "@", so make doesn't print them.
E.g.,

  sys/select.h:
          test -d sys || mkdir sys
          @rm -f address@hidden $@
          echo '#include <sys/socket.h>' >address@hidden
          @chmod a-w address@hidden
          mv address@hidden $@

For the 9 rules that use "cp", I'd prefer your two-liner, but for the
fact that the generated files would not necessarily be read-only.  IMHO,
it is the responsibility of the code that creates such a file to mark
it as generated/read-only.

Here's a proposed change to do that:

2006-09-07  Jim Meyering  <address@hidden>

        Tell "make" not to print just added "rm -f" and "chmod a-w" commands.
        * modules/alloca-opt, modules/argz, modules/arpa_inet:
        * modules/byteswap, modules/configmake, modules/fcntl:
        * modules/fnmatch, modules/getopt, modules/glob, modules/inttypes:
        * modules/localcharset, modules/netinet_in, modules/poll:
        * modules/stdbool, modules/stdint, modules/sys_select:
        * modules/sys_socket, modules/sys_stat, modules/sysexits:

Index: modules/alloca-opt
===================================================================
RCS file: /sources/gnulib/gnulib/modules/alloca-opt,v
retrieving revision 1.4
diff -u -r1.4 alloca-opt
--- modules/alloca-opt  7 Sep 2006 05:53:52 -0000       1.4
+++ modules/alloca-opt  7 Sep 2006 06:46:48 -0000
@@ -19,9 +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 address@hidden $@
+       @rm -f address@hidden $@
        cp $(srcdir)/alloca_.h address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += alloca.h alloca.h-t
 
Index: modules/argz
===================================================================
RCS file: /sources/gnulib/gnulib/modules/argz,v
retrieving revision 1.6
diff -u -r1.6 argz
--- modules/argz        7 Sep 2006 05:53:52 -0000       1.6
+++ modules/argz        7 Sep 2006 06:46:48 -0000
@@ -18,9 +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 address@hidden $@
+       @rm -f address@hidden $@
        cp $(srcdir)/argz_.h address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += argz.h argz.h-t
 
Index: modules/arpa_inet
===================================================================
RCS file: /sources/gnulib/gnulib/modules/arpa_inet,v
retrieving revision 1.3
diff -u -r1.3 arpa_inet
--- modules/arpa_inet   7 Sep 2006 05:53:52 -0000       1.3
+++ modules/arpa_inet   7 Sep 2006 06:46:48 -0000
@@ -17,9 +17,9 @@
 # doesn't have one.
 arpa/inet.h:
        test -d arpa || mkdir arpa
-       rm -f address@hidden $@
+       @rm -f address@hidden $@
        echo '#include <sys/socket.h>' >address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t
 MOSTLYCLEANDIRS += arpa
Index: modules/byteswap
===================================================================
RCS file: /sources/gnulib/gnulib/modules/byteswap,v
retrieving revision 1.5
diff -u -r1.5 byteswap
--- modules/byteswap    7 Sep 2006 05:53:52 -0000       1.5
+++ modules/byteswap    7 Sep 2006 06:46:48 -0000
@@ -17,9 +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 address@hidden $@
+       @rm -f address@hidden $@
        cp $(srcdir)/byteswap_.h address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += byteswap.h byteswap.h-t
 
Index: modules/configmake
===================================================================
RCS file: /sources/gnulib/gnulib/modules/configmake,v
retrieving revision 1.5
diff -u -r1.5 configmake
--- modules/configmake  7 Sep 2006 05:53:52 -0000       1.5
+++ modules/configmake  7 Sep 2006 06:46:48 -0000
@@ -24,7 +24,7 @@
 #
 # Listed in the same order as the GNU makefile conventions.
 configmake.h: Makefile
-       rm -f address@hidden $@
+       @rm -f address@hidden $@
        ( \
          echo '#define PREFIX "$(prefix)"'; \
          echo '#define EXEC_PREFIX "$(exec_prefix)"'; \
@@ -50,7 +50,7 @@
          echo '#define MANDIR "$(mandir)"'; \
          echo '#define MANEXT "$(manext)"'; \
        :) | sed '/""/d' >address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 BUILT_SOURCES += configmake.h
 CLEANFILES += configmake.h configmake.h-t
Index: modules/fcntl
===================================================================
RCS file: /sources/gnulib/gnulib/modules/fcntl,v
retrieving revision 1.3
diff -u -r1.3 fcntl
--- modules/fcntl       7 Sep 2006 05:53:52 -0000       1.3
+++ modules/fcntl       7 Sep 2006 06:46:48 -0000
@@ -19,10 +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 address@hidden $@
+       @rm -f address@hidden $@
        sed -e 's|@''ABSOLUTE_FCNTL_H''@|$(ABSOLUTE_FCNTL_H)|g' \
            < $(srcdir)/fcntl_.h > address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += fcntl.h fcntl.h-t
 
Index: modules/fnmatch
===================================================================
RCS file: /sources/gnulib/gnulib/modules/fnmatch,v
retrieving revision 1.11
diff -u -r1.11 fnmatch
--- modules/fnmatch     7 Sep 2006 05:53:52 -0000       1.11
+++ modules/fnmatch     7 Sep 2006 06:46:48 -0000
@@ -22,9 +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 address@hidden $@
+       @rm -f address@hidden $@
        cp $(srcdir)/fnmatch_.h address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
 
Index: modules/getopt
===================================================================
RCS file: /sources/gnulib/gnulib/modules/getopt,v
retrieving revision 1.12
diff -u -r1.12 getopt
--- modules/getopt      7 Sep 2006 05:53:52 -0000       1.12
+++ modules/getopt      7 Sep 2006 06:46:48 -0000
@@ -22,9 +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 address@hidden $@
+       @rm -f address@hidden $@
        cp $(srcdir)/getopt_.h address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += getopt.h getopt.h-t
 
Index: modules/glob
===================================================================
RCS file: /sources/gnulib/gnulib/modules/glob,v
retrieving revision 1.9
diff -u -r1.9 glob
--- modules/glob        7 Sep 2006 05:53:52 -0000       1.9
+++ modules/glob        7 Sep 2006 06:46:48 -0000
@@ -30,9 +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 address@hidden $@
+       @rm -f address@hidden $@
        cp $(srcdir)/glob_.h address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += glob.h glob.h-t
 
Index: modules/inttypes
===================================================================
RCS file: /sources/gnulib/gnulib/modules/inttypes,v
retrieving revision 1.10
diff -u -r1.10 inttypes
--- modules/inttypes    7 Sep 2006 05:53:53 -0000       1.10
+++ modules/inttypes    7 Sep 2006 06:46:48 -0000
@@ -21,7 +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 address@hidden $@
+       @rm -f address@hidden $@
        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' \
@@ -32,7 +32,7 @@
            -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
            -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
            < $(srcdir)/inttypes_.h > address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += inttypes.h inttypes.h-t
 
Index: modules/localcharset
===================================================================
RCS file: /sources/gnulib/gnulib/modules/localcharset,v
retrieving revision 1.9
diff -u -r1.9 localcharset
--- modules/localcharset        7 Sep 2006 05:53:53 -0000       1.9
+++ modules/localcharset        7 Sep 2006 06:46:48 -0000
@@ -59,16 +59,16 @@
        fi
 
 charset.alias: config.charset
-       rm -f t-$@ $@
+       @rm -f t-$@ $@
        $(SHELL) $(srcdir)/config.charset '$(host)' > t-$@
-       chmod a-w t-$@
+       @chmod a-w t-$@
        mv t-$@ $@
 
 SUFFIXES += .sed .sin
 .sin.sed:
-       rm -f t-$@ $@
+       @rm -f t-$@ $@
        sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@
-       chmod a-w t-$@
+       @chmod a-w t-$@
        mv t-$@ $@
 
 CLEANFILES += charset.alias ref-add.sed ref-del.sed
Index: modules/netinet_in
===================================================================
RCS file: /sources/gnulib/gnulib/modules/netinet_in,v
retrieving revision 1.3
diff -u -r1.3 netinet_in
--- modules/netinet_in  7 Sep 2006 05:53:53 -0000       1.3
+++ modules/netinet_in  7 Sep 2006 06:46:48 -0000
@@ -17,9 +17,9 @@
 # doesn't have one.
 netinet/in.h:
        test -d netinet || mkdir netinet
-       rm -f address@hidden $@
+       @rm -f address@hidden $@
        echo '#include <sys/socket.h>' >address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t
 MOSTLYCLEANDIRS += netinet
Index: modules/poll
===================================================================
RCS file: /sources/gnulib/gnulib/modules/poll,v
retrieving revision 1.9
diff -u -r1.9 poll
--- modules/poll        7 Sep 2006 05:53:53 -0000       1.9
+++ modules/poll        7 Sep 2006 06:46:48 -0000
@@ -18,9 +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 address@hidden $@
+       @rm -f address@hidden $@
        cp $(srcdir)/poll_.h address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += poll.h poll.h-t
 
Index: modules/stdbool
===================================================================
RCS file: /sources/gnulib/gnulib/modules/stdbool,v
retrieving revision 1.13
diff -u -r1.13 stdbool
--- modules/stdbool     7 Sep 2006 05:53:53 -0000       1.13
+++ modules/stdbool     7 Sep 2006 06:46:48 -0000
@@ -18,9 +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 address@hidden $@
+       @rm -f address@hidden $@
        sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool_.h > 
address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += stdbool.h stdbool.h-t
 
Index: modules/stdint
===================================================================
RCS file: /sources/gnulib/gnulib/modules/stdint,v
retrieving revision 1.13
diff -u -r1.13 stdint
--- modules/stdint      7 Sep 2006 05:53:53 -0000       1.13
+++ modules/stdint      7 Sep 2006 06:46:48 -0000
@@ -24,7 +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 address@hidden $@
+       @rm -f address@hidden $@
        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' \
@@ -47,7 +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 > address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += stdint.h stdint.h-t
 
Index: modules/sys_select
===================================================================
RCS file: /sources/gnulib/gnulib/modules/sys_select,v
retrieving revision 1.3
diff -u -r1.3 sys_select
--- modules/sys_select  7 Sep 2006 05:53:53 -0000       1.3
+++ modules/sys_select  7 Sep 2006 06:46:48 -0000
@@ -17,9 +17,9 @@
 # doesn't have one that works with the given compiler.
 sys/select.h:
        test -d sys || mkdir sys
-       rm -f address@hidden $@
+       @rm -f address@hidden $@
        echo '#include <sys/socket.h>' >address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 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.6
diff -u -r1.6 sys_socket
--- modules/sys_socket  7 Sep 2006 05:53:53 -0000       1.6
+++ modules/sys_socket  7 Sep 2006 06:46:48 -0000
@@ -19,9 +19,9 @@
 # doesn't have one that works with the given compiler.
 sys/socket.h: socket_.h
        test -d sys || mkdir sys
-       rm -f address@hidden $@
+       @rm -f address@hidden $@
        cp $(srcdir)/socket_.h address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 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.4
diff -u -r1.4 sys_stat
--- modules/sys_stat    7 Sep 2006 05:53:53 -0000       1.4
+++ modules/sys_stat    7 Sep 2006 06:46:48 -0000
@@ -19,10 +19,10 @@
 # has one that is incomplete.
 sys/stat.h: stat_.h
        test -d sys || mkdir sys
-       rm -f address@hidden $@
+       @rm -f address@hidden $@
        sed -e 's|@''ABSOLUTE_SYS_STAT_H''@|$(ABSOLUTE_SYS_STAT_H)|g' \
            < $(srcdir)/stat_.h > address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
 MOSTLYCLEANDIRS += sys
Index: modules/sysexits
===================================================================
RCS file: /sources/gnulib/gnulib/modules/sysexits,v
retrieving revision 1.8
diff -u -r1.8 sysexits
--- modules/sysexits    7 Sep 2006 05:53:53 -0000       1.8
+++ modules/sysexits    7 Sep 2006 06:46:48 -0000
@@ -17,9 +17,9 @@
 # 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
-       rm -f address@hidden $@
+       @rm -f address@hidden $@
        cp $(srcdir)/sysexit_.h address@hidden
-       chmod a-w address@hidden
+       @chmod a-w address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += sysexits.h sysexits.h-t
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]