Allow loaded objects to opt out of the "auto-rebuild" feature.
authorPaul Smith <psmith@gnu.org>
Sun, 22 Sep 2013 16:13:28 +0000 (12:13 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 22 Sep 2013 21:10:35 +0000 (17:10 -0400)
ChangeLog
doc/make.texi
read.c

index 8c5b3e5d06c472c974050afebb1bcc07b0300717..5b0fcb59a2608cc4e19797af9a2daada9bfe93fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2013-09-22  Paul Smith  <psmith@gnu.org>
 
+       * read.c (eval): If load_file() returns -1, don't add this to the
+       "to be rebuilt" list.
+       * doc/make.texi (load Directive): Document it.
+
        * guile.c (guile_gmake_setup): Don't initialize Guile so early.
        (func_guile): Lazily initialize Guile the first time the $(guile ..)
        function is invoked.  Guile can steal file descriptors which
index 62c71910ce5f0aac200f0c71eb1d71014e553f96..f89f8b77e669f12395c65abb6094c9e9dad31a18 100644 (file)
@@ -10910,7 +10910,8 @@ The @code{load} directive and extension capability is considered a
 ``technology preview'' in this release of GNU make.  We encourage you
 to experiment with this feature and we appreciate any feedback on it.
 However we cannot guarantee to maintain backward-compatibility in the
-next release.
+next release.  Consider using GNU Guile instead for extending GNU make
+(@pxref{Guile Function, ,The @code{guile} Function}).
 @end quotation
 @end cartouche
 
@@ -10978,7 +10979,9 @@ same directive.
 The initializing function will be provided the file name and line
 number of the invocation of the @code{load} operation.  It should
 return a value of type @code{int}, which must be @code{0} on failure
-and non-@code{0} on success.
+and non-@code{0} on success.  If the return value is @code{-1}, then
+GNU make will @emph{not} attempt to rebuild the object file
+(@pxref{Remaking Loaded Objects, ,How Loaded Objects Are Remade}).
 
 For example:
 
diff --git a/read.c b/read.c
index a4ca72d6522086c9835509196c2be0f2376272f5..7f90b9b946205778e837128928204a22c3366a25 100644 (file)
--- a/read.c
+++ b/read.c
@@ -947,19 +947,27 @@ eval (struct ebuffer *ebuf, int set_default)
                                   PARSEFS_NOAR);
           free (p);
 
-          /* Load each file and add it to the list "to be rebuilt".  */
+          /* Load each file.  */
           while (files != 0)
             {
               struct nameseq *next = files->next;
               const char *name = files->name;
               struct dep *deps;
+              int r;
+
+              /* Load the file.  0 means failure.  */
+              r = load_file (&ebuf->floc, &name, noerror);
+              if (! r && ! noerror)
+                fatal (&ebuf->floc, _("%s: failed to load"), name);
 
               free_ns (files);
               files = next;
 
-              if (! load_file (&ebuf->floc, &name, noerror) && ! noerror)
-                fatal (&ebuf->floc, _("%s: failed to load"), name);
+              /* Return of -1 means a special load: don't rebuild it.  */
+              if (r == -1)
+                continue;
 
+              /* It succeeded, so add it to the list "to be rebuilt".  */
               deps = alloc_dep ();
               deps->next = read_files;
               read_files = deps;