* Various changes.
authorPaul Smith <psmith@gnu.org>
Sun, 22 Aug 1999 17:50:57 +0000 (17:50 +0000)
committerPaul Smith <psmith@gnu.org>
Sun, 22 Aug 1999 17:50:57 +0000 (17:50 +0000)
ChangeLog
job.c
main.c
maintMakefile
make.texinfo
variable.c

index e5edfca9d094593c21463d87ab0750154cc3459b..c6e22bbcd0f484291f68504a7babe8493b840068 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,21 @@
-1999-08-13  Paul D. Smith  <psmith@gnu.org>
+1999-08-20  Paul D. Smith  <psmith@gnu.org>
+
+       * variable.c (try_variable_definition): Allocate for variable
+       expansion in f_append with a simple variable: if we're looking at
+       target-specific variables we don't want to trash the buffer.
+       Noticed by Reiner Beninga <Reiner.Beninga@mchp.siemens.de>.
+
+1999-08-16  Eli Zaretskii  <eliz@is.elta.co.il>
+
+       * main.c (main) [__MSDOS__]: Mirror any backslashes in argv[0], to
+       avoid problems in shell commands that use backslashes as escape
+       characters.
+
+1999-08-16  Paul D. Smith  <psmith@gnu.org>
+
+       * Version 3.77.93 released.
+
+1999-08-13  Paul D. Smith  <psmith@gnu.org
 
        * function.c (func_if): New function $(if ...) based on the
        original by Han-Wen but reworked quite a bit.
@@ -11,9 +28,9 @@
 
 1999-08-12  Paul D. Smith  <psmith@gnu.org>
 
-       Argh.  Another jobserver algorithm change.  We conveniently forgot
-       that the blocking bit is shared by all users of the pipe, it's not
-       per-process setting.  Since we have many make processes all
+       Another jobserver algorithm change.  We conveniently forgot that
+       the blocking bit is shared by all users of the pipe, it's not a
+       per-process setting.  Since we have many make processes all
        sharing the pipe we can't use the blocking bit as a signal handler
        flag.  Instead, we'll dup the pipe's read FD and have the SIGCHLD
        handler close the dup'd FD.  This will cause the read() to fail
diff --git a/job.c b/job.c
index 36a9443fb12a28752d995c465d215f0a758a945e..2b1159f76315041e3e094d88e21f8d3eb1777a35 100644 (file)
--- a/job.c
+++ b/job.c
@@ -90,7 +90,7 @@ static int amiga_batch_file;
 #endif
 
 #ifdef HAVE_WAITPID
-# define WAIT_NOHANG (status)  waitpid (-1, (status), WNOHANG)
+# define WAIT_NOHANG(status)   waitpid (-1, (status), WNOHANG)
 #else  /* Don't have waitpid.  */
 # ifdef HAVE_WAIT3
 #  ifndef wait3
@@ -326,13 +326,11 @@ child_handler (sig)
 {
   ++dead_children;
 
-#ifdef HAVE_JOBSERVER
   if (job_rfd >= 0)
     {
       close (job_rfd);
       job_rfd = -1;
     }
-#endif
 
   if (debug_flag)
     printf (_("Got a SIGCHLD; %u unreaped children.\n"), dead_children);
@@ -348,19 +346,35 @@ extern int shell_function_pid, shell_function_completed;
    complete child, waiting for it to die if necessary.  If ERR is nonzero,
    print an error message first.  */
 
+static int rc_block, rc_reap_all, rc_got_block, rc_start_rfd, rc_end_rfd;
+
 void
 reap_children (block, err)
      int block, err;
 {
   WAIT_T status;
-#ifdef WAIT_NOHANG
   /* Initially, assume we have some.  */
   int reap_more = 1;
+
+#ifdef WAIT_NOHANG
 # define REAP_MORE reap_more
 #else
 # define REAP_MORE dead_children
 #endif
 
+  rc_block = block;
+  rc_reap_all = 0;
+  rc_got_block = 0;
+  rc_start_rfd = job_rfd;
+
+  /* As long as:
+
+       We have at least one child outstanding OR a shell function in progress,
+         AND
+       We're blocking for a complete child OR there are more children to reap
+
+     we'll keep reaping children.  */
+
   while ((children != 0 || shell_function_pid != 0) &&
         (block || REAP_MORE))
     {
@@ -456,10 +470,11 @@ reap_children (block, err)
 
          if (pid < 0)
            {
-              /* The wait*() failed miserably.  Punt.  */
+              /* EINTR?  Try again. */
              if (EINTR_SET)
                goto local_wait;
 
+              /* The wait*() failed miserably.  Punt.  */
              pfatal_with_name ("wait");
            }
          else if (pid > 0)
@@ -472,26 +487,25 @@ reap_children (block, err)
          else
            {
              /* No local children are dead.  */
-#ifdef WAIT_NOHANG
               reap_more = 0;
-#endif
-             if (block && any_remote)
-               {
-                 /* Now try a blocking wait for a remote child.  */
-                 pid = remote_status (&exit_code, &exit_sig, &coredump, 1);
-                 if (pid < 0)
-                   goto remote_status_lose;
-                 else if (pid == 0)
-                   /* No remote children either.  Finally give up.  */
-                   break;
-                 else
-                   /* We got a remote child.  */
-                   remote = 1;
-               }
-             else
-               break;
+              rc_reap_all = 1;
+
+             if (!block || !any_remote)
+                break;
+
+              /* Now try a blocking wait for a remote child.  */
+              pid = remote_status (&exit_code, &exit_sig, &coredump, 1);
+              if (pid < 0)
+                goto remote_status_lose;
+              else if (pid == 0)
+                /* No remote children either.  Finally give up.  */
+                break;
+
+              /* We got a remote child.  */
+              remote = 1;
            }
 #endif /* !__MSDOS__, !Amiga, !WINDOWS32.  */
+
 #ifdef __MSDOS__
          /* Life is very different on MSDOS.  */
          pid = dos_pid - 1;
@@ -703,8 +717,10 @@ reap_children (block, err)
 
       /* Only block for one child.  */
       block = 0;
+      rc_block = block;
     }
 
+  rc_end_rfd = job_rfd;
   return;
 }
 \f
diff --git a/main.c b/main.c
index af77d5f4a183e17bae7e1ec1a663f46c09f26bf0..7dde4f642dd06a196f30585cb1b7002a8eb5ecc9 100644 (file)
--- a/main.c
+++ b/main.c
@@ -945,7 +945,7 @@ int main (int argc, char ** argv)
   if (print_version_flag)
     die (0);
 
-#if !defined(__MSDOS__) && !defined(VMS)
+#ifndef VMS
   /* Set the "MAKE_COMMAND" variable to the name we were invoked with.
      (If it is a relative pathname with a slash, prepend our directory name
      so the result will run the same program regardless of the current dir.
@@ -963,9 +963,21 @@ int main (int argc, char ** argv)
       strneq(argv[0], "//", 2))
     argv[0] = xstrdup(w32ify(argv[0],1));
 #else /* WINDOWS32 */
+#ifdef __MSDOS__
+  if (strchr (argv[0], '\\'))
+    {
+      char *p;
+
+      argv[0] = xstrdup (argv[0]);
+      for (p = argv[0]; *p; p++)
+       if (*p == '\\')
+         *p = '/';
+    }
+#else  /* !__MSDOS__ */
   if (current_directory[0] != '\0'
       && argv[0] != 0 && argv[0][0] != '/' && index (argv[0], '/') != 0)
     argv[0] = concat (current_directory, "/", argv[0]);
+#endif /* !__MSDOS__ */
 #endif /* WINDOWS32 */
 #endif
 
@@ -1339,6 +1351,8 @@ int main (int argc, char ** argv)
          submakes it's the token they were given by their parent.  For the
          top make, we just subtract one from the number the user wants.  */
 
+      job_slots = 1; /* !!!!!DEBUG!!!!! */
+
       while (--job_slots)
        {
          write (job_fds[1], &c, 1);
index c95371785116f59df73bdb15e92b70d091742fa0..108381bcdbd479d8033d44a8f54cf49b79474b30 100644 (file)
@@ -18,7 +18,7 @@ MTEMPLATES = Makefile.DOS SMakefile
 
 # General rule for turning a .template into a regular file.
 #
-$(TEMPLATES) : % : %.template configure.in
+$(TEMPLATES) : % : %.template Makefile
        rm -f $@
        sed -e 's@%VERSION%@$(VERSION)@g' \
            -e 's@%PACKAGE%@$(PACKAGE)@g' \
@@ -27,7 +27,7 @@ $(TEMPLATES) : % : %.template configure.in
 
 # Construct Makefiles by adding on dependencies, etc.
 #
-$(MTEMPLATES) : % : %.template .dep_segment Makefile.am maintMakefile
+$(MTEMPLATES) : % : %.template .dep_segment Makefile
        rm -f $@
        sed -e 's@%VERSION%@$(VERSION)@g' \
            -e 's@%PROGRAMS%@$(bin_PROGRAMS)@g' \
@@ -40,7 +40,7 @@ $(MTEMPLATES) : % : %.template .dep_segment Makefile.am maintMakefile
          cat $(word 2,$^) >>$@
        chmod a-w $@
 
-NMakefile: NMakefile.template .dep_segment Makefile.am maintMakefile
+NMakefile: NMakefile.template .dep_segment Makefile
        rm -f $@
        cp $< $@
        echo >>$@; echo '# --------------- DEPENDENCIES' >>$@; echo '#' >>$@; \
@@ -49,7 +49,7 @@ NMakefile: NMakefile.template .dep_segment Makefile.am maintMakefile
 
 # Construct build.sh.in
 #
-build.sh.in: build.template Makefile.am maintMakefile
+build.sh.in: build.template Makefile
        rm -f $@
        sed -e 's@%objs%@$(filter-out remote-%, $(make_OBJECTS)@g' \
            -e 's@%globobjs%@$(patsubst %.c,%.o,$(globsrc)))@g' \
index 8706c4a8b113a4dda498acb8f8f9759934aa6409..3e5fa6eaf2d72f50557c7d3511053f9768e2f10a 100644 (file)
@@ -2750,9 +2750,9 @@ called @file{@var{name}.d} from a C source file called @file{@var{name}.c}:
 @smallexample
 @group
 %.d: %.c
-        $(SHELL) -ec '$(CC) -M $(CPPFLAGS) $< \
-                      | sed '\''s/\($*\)\.o[ :]*/\1.o $@@ : /g'\'' > $@@; \
-                      [ -s $@@ ] || rm -f $@@'
+        set -e; $(CC) -M $(CPPFLAGS) $< \
+                  | sed 's/\($*\)\.o[ :]*/\1.o $@@ : /g' > $@@; \
+                [ -s $@@ ] || rm -f $@@
 @end group
 @end smallexample
 
index d07b5e1fa5b3fba85e62ca4c62784e725a8ff85a..97207f157357468a6bd60e23dd12763235257619 100644 (file)
@@ -780,9 +780,9 @@ try_variable_definition (flocp, line, origin)
     case f_simple:
       /* A simple variable definition "var := value".  Expand the value.
          We have to allocate memory since otherwise it'll clobber the
-        variable buffer, and we still need that.  */
-      alloc_value = allocated_variable_expand (p);
-      value = alloc_value;
+        variable buffer, and we may still need that if we're looking at a
+         target-specific variable.  */
+      value = alloc_value = allocated_variable_expand (p);
       break;
     case f_conditional:
       /* A conditional variable definition "var ?= value".
@@ -824,8 +824,10 @@ try_variable_definition (flocp, line, origin)
          else
            /* The previous definition of the variable was simple.
               The new value comes from the old value, which was expanded
-              when it was set; and from the expanded new value.  */
-           p = variable_expand (p);
+              when it was set; and from the expanded new value.  Allocate
+               memory for the expansion as we may still need the rest of the
+               buffer if we're looking at a target-specific variable.  */
+           p = alloc_value = allocated_variable_expand (p);
 
          oldlen = strlen (v->value);
          newlen = strlen (p);