use new global, "Version", rather than macro, VERSION
authorJim Meyering <meyering@redhat.com>
Wed, 13 Aug 2008 20:30:14 +0000 (22:30 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 26 Aug 2008 16:45:06 +0000 (18:45 +0200)
With this change, a version-string update no longer
forces recompilation of 100+ src/*.o files.
* src/version.c (Version): New global.  New file.
* src/version.h: Declare it.
* src/Makefile.am: Put it in a library that everyone links to.
(noinst_LIBRARIES, libver_a_SOURCES): Define.
(LDADD): Add libver.a.
(sc_tight_scope): Use perl (was sed), and a more relaxed regexp
to build the global-variable-name-recognizing regexp list.
* src/system.h: Include "version.h".
(case_GETOPT_VERSION_CHAR): Use Version rather than VERSION.
* src/basename.c (main): Use Version rather than VERSION.
* src/chroot.c (main): Likewise.
* src/cksum.c (main): Likewise.
* src/dd.c (main): Likewise.
* src/dirname.c (main): Likewise.
* src/echo.c (main): Likewise.
* src/hostid.c (main): Likewise.
* src/hostname.c (main): Likewise.
* src/link.c (main): Likewise.
* src/logname.c (main): Likewise.
* src/nice.c (main): Likewise.
* src/nohup.c (main): Likewise.
* src/printenv.c (main): Likewise.
* src/printf.c (main): Likewise.
* src/pwd.c (main): Likewise.
* src/setuidgid.c (main): Likewise.
* src/sleep.c (main): Likewise.
* src/sync.c (main): Likewise.
* src/test.c (main): Likewise.
* src/timeout.c (main): Likewise.
* src/true.c (main): Likewise.
* src/tsort.c (main): Likewise.
* src/unlink.c (main): Likewise.
* src/uptime.c (main): Likewise.
* src/users.c (main): Likewise.
* src/whoami.c (main): Likewise.
* src/yes.c (main): Likewise.

31 files changed:
src/Makefile.am
src/basename.c
src/chroot.c
src/cksum.c
src/dd.c
src/dirname.c
src/echo.c
src/hostid.c
src/hostname.c
src/link.c
src/logname.c
src/nice.c
src/nohup.c
src/printenv.c
src/printf.c
src/pwd.c
src/setuidgid.c
src/sleep.c
src/sync.c
src/system.h
src/test.c
src/timeout.c
src/true.c
src/tsort.c
src/unlink.c
src/uptime.c
src/users.c
src/version.c [new file with mode: 0644]
src/version.h [new file with mode: 0644]
src/whoami.c
src/yes.c

index 359d18ec6b7c017adc79f3fd980adf598c995d44..1d5900387b72c91c6cb08593e496c8c5420a3aee 100644 (file)
@@ -69,12 +69,15 @@ CLEANFILES = $(SCRIPTS) su
 
 AM_CPPFLAGS = -I$(top_srcdir)/lib
 
+noinst_LIBRARIES = libver.a
+libver_a_SOURCES = version.c version.h
+
 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
 # include modules defining variables like `optind', so libcoreutils.a
 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
 # replacement functions defined in libcoreutils.a.
-LDADD = ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
+LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
 
 cat_LDADD = $(LDADD)
 df_LDADD = $(LDADD)
@@ -435,8 +438,8 @@ sc_tight_scope: $(all_programs)
          { echo 'the above functions should have static scope' 1>&2;   \
            exit 1; } || : ;                                            \
        ( printf '^program_name$$\n';                                   \
-         sed -n 's/^extern int \([^ ][^ ]*\);$$/^\1$$/p'               \
-           $(noinst_HEADERS) ) > $$t;                                  \
+         perl -ne '/^extern .*?\**(\w+);/ and print "^$$1\$$\n"'       \
+           *.h ) > $$t;                                                \
        nm -e *.$(OBJEXT)                                               \
            | sed -n 's/.* [BD] //p'                                    \
            | grep -Ev -f $$t &&                                        \
index 69b708fe76487485dc04bcb8087a6fcdf65e629b..ac2e01ec2bfc146a4aa0af95ae3f1f5fdc1403af 100644 (file)
@@ -103,7 +103,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index d55db6ef0a2b621e5e78c5944692070d6d60a2db..299acbcbf7e15928e96b59979c451d503170e174 100644 (file)
@@ -71,7 +71,7 @@ main (int argc, char **argv)
   initialize_exit_failure (EXIT_FAILURE);
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index a2d49c5b30ad480d0d80e4a56463717d9d203d34..8bbed37f9fd5a12e59bae2c5d924d03f26ad76e4 100644 (file)
@@ -287,7 +287,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index d32cd946e27a25802ac8333eb29cc91ce8d1386a..f598e44cd37c5ec6e0ee6f2ea6e5332245d00a25 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -1739,7 +1739,7 @@ main (int argc, char **argv)
 
   page_size = getpagesize ();
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version,
                      usage, AUTHORS, (char const *) NULL);
   close_stdout_required = false;
 
index 3a319128f7983a2a07b66fd9c65992f797d3c4fd..10926435ff06874217509c6be7bdb01f167c3f23 100644 (file)
@@ -82,7 +82,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index 8a6466ea8a74fa559c8e418b757cbd7efdcf7429..d549cda2be22e6bfaddc2315f8c2f443b8e2aabb 100644 (file)
@@ -122,7 +122,7 @@ main (int argc, char **argv)
   atexit (close_stdout);
 
   if (allow_options)
-    parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+    parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                        usage, AUTHORS, (char const *) NULL);
 
   --argc;
index dbcb98df8bb7788bafb040b46c9758cdfb1e6da5..f3cabc47b4d44a9daf2e9e3729285fc0600ed892 100644 (file)
@@ -68,7 +68,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index cf8e9535b68e31fbeccc6fe67a516d10289a1b1f..b325c27539c3fa5334ef84339bdad41a11fb26d5 100644 (file)
@@ -85,7 +85,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index 1b09fe32745ca6a303618d14c61435bda8be8d05..d155291f0b857e14e6b3af95520957c3a3e9ad5a 100644 (file)
@@ -67,7 +67,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index a71ac33a14f85e555c1e631b10ba63ab0a14f944..9cf0d9fae022b1b5de5228461a978f1aaf899b4f 100644 (file)
@@ -62,7 +62,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index 13033ec5e0acb7185aacc7c7dc3507ded800e5b0..ee8cc866e8f5239b373cb5c256d0f8293ad20fe3 100644 (file)
@@ -104,7 +104,7 @@ main (int argc, char **argv)
   initialize_exit_failure (EXIT_FAILURE);
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
 
   for (i = 1; i < argc; /* empty */)
index 61f181dbd0f8d35ce1ed62cf1ceeda15b4f2f656..3ff22eac83a34aab0412dfe474982a0e5ce2644f 100644 (file)
@@ -95,7 +95,7 @@ main (int argc, char **argv)
   initialize_exit_failure (NOHUP_FAILURE);
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
     usage (NOHUP_FAILURE);
index ecb6593dd7eaa7bc3226b53565e34fc3523169f3..3033fd4b92766df74bbdffa1f064986239a9e715 100644 (file)
@@ -88,7 +88,7 @@ main (int argc, char **argv)
   initialize_exit_failure (PRINTENV_FAILURE);
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
     usage (PRINTENV_FAILURE);
index a9d5aa144889834ef2dc72f707d154f263471280..c50995183e1a0bbabf980bd117e03e3ce5ab2738 100644 (file)
@@ -645,7 +645,7 @@ main (int argc, char **argv)
 
   posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
 
   /* The above handles --help and --version.
index 5038065d338252bb2b155981cb94c09cc62909aa..3c7b4fcc4481046cee912a9b7be84b590eb8072f 100644 (file)
--- a/src/pwd.c
+++ b/src/pwd.c
@@ -293,7 +293,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index e9103572dd57e4e3c4c0f1909f1728d55d5f8ece..057002cbfec28a39944d60c4a396a183b601e958 100644 (file)
@@ -90,7 +90,7 @@ main (int argc, char **argv)
   initialize_exit_failure (SETUIDGID_FAILURE);
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                       usage, AUTHORS, (char const *) NULL);
   {
     int c;
index 4176977f03b8d4bf5d0315d8a2622c5992504497..0c11b8e73b18cc6fa25148291e30dfd192331ea4 100644 (file)
@@ -111,7 +111,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index 96dcf0953673755775e0c0dfc4b8e7aa56a5f998..fccc6fb922c02ae8bd07c98dff31cda24deeee1b 100644 (file)
@@ -61,7 +61,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index 4b8e58e1f206b1d13e93c4562fb3952ed7875dbc..e88b1bb3bd22bcce58cbf61b5d43badd8cc17cec 100644 (file)
@@ -115,6 +115,7 @@ you must include <sys/types.h> before including this file
 
 #include <stdbool.h>
 #include <stdlib.h>
+#include "version.h"
 
 /* Exit statuses for programs like 'env' that exec other programs.  */
 enum
@@ -466,7 +467,7 @@ enum
 
 #define case_GETOPT_VERSION_CHAR(Program_name, Authors)                        \
   case GETOPT_VERSION_CHAR:                                            \
-    version_etc (stdout, Program_name, PACKAGE_NAME, VERSION, Authors, \
+    version_etc (stdout, Program_name, PACKAGE_NAME, Version, Authors, \
                  (char *) NULL);                                       \
     exit (EXIT_SUCCESS);                                               \
     break;
index 833b254b69bdec045e75dbc34582fa9387e29c73..1fe7da00cf26e6d94c46ce9b76192d34912cbbc5 100644 (file)
@@ -826,7 +826,7 @@ main (int margc, char **margv)
         to exit silently with status 0.  */
       if (margc < 2 || !STREQ (margv[margc - 1], "]"))
        {
-         parse_long_options (margc, margv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+         parse_long_options (margc, margv, PROGRAM_NAME, PACKAGE_NAME, Version,
                              usage, AUTHORS, (char const *) NULL);
          test_syntax_error (_("missing `]'"), NULL);
        }
index 8449607af24b5172d5cbff779e4851ce61a786b1..37bed3c0902b92e66a2e51228a8808e3e5278f5d 100644 (file)
@@ -232,7 +232,7 @@ main (int argc, char **argv)
   initialize_exit_failure (EXIT_CANCELED);
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                       usage, AUTHORS, (char const *) NULL);
 
   while ((c = getopt_long (argc, argv, "+s:", long_options, NULL)) != -1)
index 12100bdbfc559826d52ca043c29fd72a86115774..80940f07b6de4d867a504f670b8ba46fbfe52469 100644 (file)
@@ -70,7 +70,7 @@ main (int argc, char **argv)
        usage (EXIT_STATUS);
 
       if (STREQ (argv[1], "--version"))
-       version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, VERSION, AUTHORS,
+       version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
                     (char *) NULL);
     }
 
index 703b8557db5e107b2c81e92ef43c3a1e42170d2b..76865b95ff19bf624fbab4f7063b18b9fbbe340e 100644 (file)
@@ -538,7 +538,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index 36595c8dcffe01454e4f1ddcadcf9ce53054682a..1b999d1d60572005983eca44d276ec56f510d0b4 100644 (file)
@@ -66,7 +66,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index b35e97a48ca553d330c978e191e5effe505b8dfe..a5c4fe55c4052cf270f437039b091d58b4583fd9 100644 (file)
@@ -230,7 +230,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index 19ffce8ca8caca7d8d0cffea09d40e863df1e2fb..c10dac67d7f63d5327782d40c2a1c770bba6eb95 100644 (file)
@@ -128,7 +128,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
diff --git a/src/version.c b/src/version.c
new file mode 100644 (file)
index 0000000..1187ff0
--- /dev/null
@@ -0,0 +1,2 @@
+#include <config.h>
+char const *Version = VERSION;
diff --git a/src/version.h b/src/version.h
new file mode 100644 (file)
index 0000000..f6a1ed3
--- /dev/null
@@ -0,0 +1 @@
+extern char const *Version;
index c3b709bc48e80d8cb078eb2462e55efce0ee0f4f..75bb9a6cdce6c319ab72e4f33573a4c592ec8f67 100644 (file)
@@ -70,7 +70,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)
     usage (EXIT_FAILURE);
index d72c5da87ec17e18611469776daa8fabd0e72a5d..e2a58445f0c701c5505d7db45b9b97fa669cdc7c 100644 (file)
--- a/src/yes.c
+++ b/src/yes.c
@@ -67,7 +67,7 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
+  parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
                      usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "+", NULL, NULL) != -1)
     usage (EXIT_FAILURE);