Index: Makefile
===================================================================
--- Makefile (nonexistent)
+++ Makefile (revision 5)
@@ -0,0 +1,60 @@
+
+COMPONENT_TARGETS = $(HARDWARE_NOARCH)
+
+
+include ../../../build-system/constants.mk
+
+
+url = $(DOWNLOAD_SERVER)/sources/GNU/make-savannah
+
+versions = 4.3.1
+pkgname = make
+suffix = tar.xz
+
+tarballs = $(addsuffix .$(suffix), $(addprefix $(pkgname)-, $(versions)))
+sha1s = $(addsuffix .sha1sum, $(tarballs))
+
+patches = $(CURDIR)/patches/make-4.3.1-alloca.patch
+patches += $(CURDIR)/patches/make-4.3.1-getcwd.patch
+patches += $(CURDIR)/patches/make-4.3.1-gnulib.patch
+
+.NOTPARALLEL: $(patches)
+
+
+BUILD_TARGETS = $(tarballs) $(sha1s) $(patches)
+
+
+include ../../../build-system/core.mk
+
+
+.PHONY: download_clean
+
+
+$(tarballs):
+ @echo -e "\n======= Downloading source tarballs =======" ; \
+ for tarball in $(tarballs) ; do \
+ echo "$(url)/$$tarball" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) - & \
+ done ; wait
+
+$(sha1s): $(tarballs)
+ @for sha in $@ ; do \
+ echo -e "\n======= Downloading '$$sha' signature =======\n" ; \
+ echo "$(url)/$$sha" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) - & wait %1 ; \
+ touch $$sha ; \
+ echo -e "\n======= Check the '$$sha' sha1sum =======\n" ; \
+ sha1sum --check $$sha ; ret="$$?" ; \
+ if [ "$$ret" == "1" ]; then \
+ echo -e "\n======= ERROR: Bad '$$sha' sha1sum =======\n" ; \
+ exit 1 ; \
+ fi ; \
+ done
+
+$(patches): $(sha1s)
+ @echo -e "\n======= Create Patches =======\n" ; \
+ ( cd create-4.3.1-alloca-patch ; ./create.patch.sh ) ; \
+ ( cd create-4.3.1-getcwd-patch ; ./create.patch.sh ) ; \
+ ( cd create-4.3.1-gnulib-patch ; ./create.patch.sh ) ; \
+ echo -e "\n"
+
+download_clean:
+ @rm -f $(tarballs) $(sha1s) $(patches)
Index: create-4.3.1-alloca-patch/create.patch.sh
===================================================================
--- create-4.3.1-alloca-patch/create.patch.sh (nonexistent)
+++ create-4.3.1-alloca-patch/create.patch.sh (revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=4.3.1
+
+tar --files-from=file.list -xJvf ../make-$VERSION.tar.xz
+mv make-$VERSION make-$VERSION-orig
+
+cp -rf ./make-$VERSION-new ./make-$VERSION
+
+diff --unified -Nr make-$VERSION-orig make-$VERSION > make-$VERSION-alloca.patch
+
+mv make-$VERSION-alloca.patch ../patches
+
+rm -rf ./make-$VERSION
+rm -rf ./make-$VERSION-orig
Property changes on: create-4.3.1-alloca-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-4.3.1-alloca-patch/file.list
===================================================================
--- create-4.3.1-alloca-patch/file.list (nonexistent)
+++ create-4.3.1-alloca-patch/file.list (revision 5)
@@ -0,0 +1 @@
+make-4.3.1/src/read.c
Index: create-4.3.1-alloca-patch/make-4.3.1-new/src/read.c
===================================================================
--- create-4.3.1-alloca-patch/make-4.3.1-new/src/read.c (nonexistent)
+++ create-4.3.1-alloca-patch/make-4.3.1-new/src/read.c (revision 5)
@@ -0,0 +1,3476 @@
+/* Reading and parsing of makefiles for GNU Make.
+Copyright (C) 1988-2020 Free Software Foundation, Inc.
+This file is part of GNU Make.
+
+GNU Make is free software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation; either version 3 of the License, or (at your option) any later
+version.
+
+GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "makeint.h"
+
+#include <assert.h>
+
+#include "filedef.h"
+#include "dep.h"
+#include "job.h"
+#include "os.h"
+#include "commands.h"
+#include "variable.h"
+#include "rule.h"
+#include "debug.h"
+#include "hash.h"
+
+
+#ifdef WINDOWS32
+#include <windows.h>
+#include "sub_proc.h"
+#else /* !WINDOWS32 */
+#ifndef _AMIGA
+#ifndef VMS
+#include <pwd.h>
+#else
+struct passwd *getpwnam (char *name);
+#endif
+#endif
+#endif /* !WINDOWS32 */
+
+/* A 'struct ebuffer' controls the origin of the makefile we are currently
+ eval'ing.
+*/
+
+struct ebuffer
+ {
+ char *buffer; /* Start of the current line in the buffer. */
+ char *bufnext; /* Start of the next line in the buffer. */
+ char *bufstart; /* Start of the entire buffer. */
+ size_t size; /* Malloc'd size of buffer. */
+ FILE *fp; /* File, or NULL if this is an internal buffer. */
+ floc floc; /* Info on the file in fp (if any). */
+ };
+
+/* Track the modifiers we can have on variable assignments */
+
+struct vmodifiers
+ {
+ unsigned int assign_v:1;
+ unsigned int define_v:1;
+ unsigned int undefine_v:1;
+ unsigned int override_v:1;
+ unsigned int private_v:1;
+ enum variable_export export_v ENUM_BITFIELD (2);
+ };
+
+/* Types of "words" that can be read in a makefile. */
+enum make_word_type
+ {
+ w_bogus, w_eol, w_static, w_variable, w_colon, w_dcolon, w_semicolon,
+ w_varassign, w_ampcolon, w_ampdcolon
+ };
+
+
+/* A 'struct conditionals' contains the information describing
+ all the active conditionals in a makefile.
+
+ The global variable 'conditionals' contains the conditionals
+ information for the current makefile. It is initialized from
+ the static structure 'toplevel_conditionals' and is later changed
+ to new structures for included makefiles. */
+
+struct conditionals
+ {
+ unsigned int if_cmds; /* Depth of conditional nesting. */
+ unsigned int allocated; /* Elts allocated in following arrays. */
+ char *ignoring; /* Are we ignoring or interpreting?
+ 0=interpreting, 1=not yet interpreted,
+ 2=already interpreted */
+ char *seen_else; /* Have we already seen an 'else'? */
+ };
+
+static struct conditionals toplevel_conditionals;
+static struct conditionals *conditionals = &toplevel_conditionals;
+
+
+/* Default directories to search for include files in */
+
+static const char *default_include_directories[] =
+ {
+#if defined(WINDOWS32) && !defined(INCLUDEDIR)
+/* This completely up to the user when they install MSVC or other packages.
+ This is defined as a placeholder. */
+# define INCLUDEDIR "."
+#endif
+ INCLUDEDIR,
+#ifndef _AMIGA
+ "/usr/gnu/include",
+ "/usr/local/include",
+ "/usr/include",
+#endif
+ 0
+ };
+
+/* List of directories to search for include files in */
+
+static const char **include_directories;
+
+/* Maximum length of an element of the above. */
+
+static size_t max_incl_len;
+
+/* The filename and pointer to line number of the
+ makefile currently being read in. */
+
+const floc *reading_file = 0;
+
+/* The chain of files read by read_all_makefiles. */
+
+static struct goaldep *read_files = 0;
+
+static struct goaldep *eval_makefile (const char *filename, unsigned short flags);
+static void eval (struct ebuffer *buffer, int flags);
+
+static long readline (struct ebuffer *ebuf);
+static void do_undefine (char *name, enum variable_origin origin,
+ struct ebuffer *ebuf);
+static struct variable *do_define (char *name, enum variable_origin origin,
+ struct ebuffer *ebuf);
+static int conditional_line (char *line, size_t len, const floc *flocp);
+static void check_specials (const struct nameseq *file, int set_default);
+static void record_files (struct nameseq *filenames, int are_also_makes,
+ const char *pattern,
+ const char *pattern_percent, char *depstr,
+ unsigned int cmds_started, char *commands,
+ size_t commands_idx, int two_colon,
+ char prefix, const floc *flocp);
+static void record_target_var (struct nameseq *filenames, char *defn,
+ enum variable_origin origin,
+ struct vmodifiers *vmod,
+ const floc *flocp);
+static enum make_word_type get_next_mword (char *buffer,
+ char **startp, size_t *length);
+static void remove_comments (char *line);
+static char *find_map_unquote (char *string, int map);
+static char *find_char_unquote (char *string, int stop);
+static char *unescape_char (char *string, int c);
+
+
+/* Compare a word, both length and contents.
+ P must point to the word to be tested, and WLEN must be the length.
+*/
+#define word1eq(s) (wlen == CSTRLEN (s) && strneq (s, p, CSTRLEN (s)))
+
+
+/* Read in all the makefiles and return a chain of targets to rebuild. */
+
+struct goaldep *
+read_all_makefiles (const char **makefiles)
+{
+ unsigned int num_makefiles = 0;
+
+ /* Create *_LIST variables, to hold the makefiles, targets, and variables
+ we will be reading. */
+
+ define_variable_cname ("MAKEFILE_LIST", "", o_file, 0);
+
+ DB (DB_BASIC, (_("Reading makefiles...\n")));
+
+ /* If there's a non-null variable MAKEFILES, its value is a list of
+ files to read first thing. But don't let it prevent reading the
+ default makefiles and don't let the default goal come from there. */
+
+ {
+ char *value;
+ char *name, *p;
+ size_t length;
+
+ {
+ /* Turn off --warn-undefined-variables while we expand MAKEFILES. */
+ int save = warn_undefined_variables_flag;
+ warn_undefined_variables_flag = 0;
+
+ value = allocated_variable_expand ("$(MAKEFILES)");
+
+ warn_undefined_variables_flag = save;
+ }
+
+ /* Set NAME to the start of next token and LENGTH to its length.
+ MAKEFILES is updated for finding remaining tokens. */
+ p = value;
+
+ while ((name = find_next_token ((const char **)&p, &length)) != 0)
+ {
+ if (*p != '\0')
+ *p++ = '\0';
+ eval_makefile (strcache_add (name), RM_NO_DEFAULT_GOAL|RM_INCLUDED|RM_DONTCARE);
+ }
+
+ free (value);
+ }
+
+ /* Read makefiles specified with -f switches. */
+
+ if (makefiles != 0)
+ while (*makefiles != 0)
+ {
+ struct goaldep *d = eval_makefile (*makefiles, 0);
+
+ if (errno)
+ perror_with_name ("", *makefiles);
+
+ /* Reuse the storage allocated for the read_file. */
+ *makefiles = dep_name (d);
+ ++num_makefiles;
+ ++makefiles;
+ }
+
+ /* If there were no -f switches, try the default names. */
+
+ if (num_makefiles == 0)
+ {
+ static const char *default_makefiles[] =
+#ifdef VMS
+ /* all lower case since readdir() (the vms version) 'lowercasifies' */
+ /* TODO: Above is not always true, this needs more work */
+ { "makefile.vms", "gnumakefile", "makefile", 0 };
+#else
+#ifdef _AMIGA
+ { "GNUmakefile", "Makefile", "SMakefile", 0 };
+#else /* !Amiga && !VMS */
+#ifdef WINDOWS32
+ { "GNUmakefile", "makefile", "Makefile", "makefile.mak", 0 };
+#else /* !Amiga && !VMS && !WINDOWS32 */
+ { "GNUmakefile", "makefile", "Makefile", 0 };
+#endif /* !Amiga && !VMS && !WINDOWS32 */
+#endif /* AMIGA */
+#endif /* VMS */
+ const char **p = default_makefiles;
+ while (*p != 0 && !file_exists_p (*p))
+ ++p;
+
+ if (*p != 0)
+ {
+ eval_makefile (*p, 0);
+ if (errno)
+ perror_with_name ("", *p);
+ }
+ else
+ {
+ /* No default makefile was found. Add the default makefiles to the
+ 'read_files' chain so they will be updated if possible. */
+ for (p = default_makefiles; *p != 0; ++p)
+ {
+ struct goaldep *d = alloc_goaldep ();
+ d->file = enter_file (strcache_add (*p));
+ /* Tell update_goal_chain to bail out as soon as this file is
+ made, and main not to die if we can't make this file. */
+ d->flags = RM_DONTCARE;
+ d->next = read_files;
+ read_files = d;
+ }
+ }
+ }
+
+ return read_files;
+}
+
+/* Install a new conditional and return the previous one. */
+
+static struct conditionals *
+install_conditionals (struct conditionals *new)
+{
+ struct conditionals *save = conditionals;
+
+ memset (new, '\0', sizeof (*new));
+ conditionals = new;
+
+ return save;
+}
+
+/* Free the current conditionals and reinstate a saved one. */
+
+static void
+restore_conditionals (struct conditionals *saved)
+{
+ /* Free any space allocated by conditional_line. */
+ free (conditionals->ignoring);
+ free (conditionals->seen_else);
+
+ /* Restore state. */
+ conditionals = saved;
+}
+
+static struct goaldep *
+eval_makefile (const char *filename, unsigned short flags)
+{
+ struct goaldep *deps;
+ struct ebuffer ebuf;
+ const floc *curfile;
+ char *expanded = 0;
+
+ /* Create a new goaldep entry. */
+ deps = alloc_goaldep ();
+ deps->next = read_files;
+ read_files = deps;
+
+ ebuf.floc.filenm = filename; /* Use the original file name. */
+ ebuf.floc.lineno = 1;
+ ebuf.floc.offset = 0;
+
+ if (ISDB (DB_VERBOSE))
+ {
+ printf (_("Reading makefile '%s'"), filename);
+ if (flags & RM_NO_DEFAULT_GOAL)
+ printf (_(" (no default goal)"));
+ if (flags & RM_INCLUDED)
+ printf (_(" (search path)"));
+ if (flags & RM_DONTCARE)
+ printf (_(" (don't care)"));
+ if (flags & RM_NO_TILDE)
+ printf (_(" (no ~ expansion)"));
+ puts ("...");
+ }
+
+ /* First, get a stream to read. */
+
+ /* Expand ~ in FILENAME unless it came from 'include',
+ in which case it was already done. */
+ if (!(flags & RM_NO_TILDE) && filename[0] == '~')
+ {
+ expanded = tilde_expand (filename);
+ if (expanded != 0)
+ filename = expanded;
+ }
+
+ errno = 0;
+ ENULLLOOP (ebuf.fp, fopen (filename, "r"));
+ deps->error = errno;
+
+ /* Check for unrecoverable errors: out of mem or FILE slots. */
+ switch (deps->error)
+ {
+#ifdef EMFILE
+ case EMFILE:
+#endif
+#ifdef ENFILE
+ case ENFILE:
+#endif
+ case ENOMEM:
+ {
+ const char *err = strerror (deps->error);
+ OS (fatal, reading_file, "%s", err);
+ }
+ }
+
+ /* If the makefile wasn't found and it's either a makefile from
+ the 'MAKEFILES' variable or an included makefile,
+ search the included makefile search path for this makefile. */
+ if (ebuf.fp == 0 && (flags & RM_INCLUDED) && *filename != '/')
+ {
+ unsigned int i;
+ for (i = 0; include_directories[i] != 0; ++i)
+ {
+ const char *included = concat (3, include_directories[i],
+ "/", filename);
+ ebuf.fp = fopen (included, "r");
+ if (ebuf.fp)
+ {
+ filename = included;
+ break;
+ }
+ }
+ }
+
+ /* Enter the final name for this makefile as a goaldep. */
+ filename = strcache_add (filename);
+ deps->file = lookup_file (filename);
+ if (deps->file == 0)
+ deps->file = enter_file (filename);
+ filename = deps->file->name;
+ deps->flags = flags;
+
+ free (expanded);
+
+ if (ebuf.fp == 0)
+ {
+ /* The makefile can't be read at all, give up entirely.
+ If we did some searching errno has the error from the last attempt,
+ rather from FILENAME itself: recover the more accurate one. */
+ errno = deps->error;
+ deps->file->last_mtime = NONEXISTENT_MTIME;
+ return deps;
+ }
+
+ /* Success; clear errno. */
+ deps->error = 0;
+
+ /* If we tried and failed to read the included file before but this
+ time we succeeded, reset the last mtime. */
+ if (deps->file->last_mtime == NONEXISTENT_MTIME)
+ deps->file->last_mtime = 0;
+
+ /* Avoid leaking the makefile to children. */
+ fd_noinherit (fileno (ebuf.fp));
+
+ /* Add this makefile to the list. */
+ do_variable_definition (&ebuf.floc, "MAKEFILE_LIST", filename, o_file,
+ f_append_value, 0);
+
+ /* Evaluate the makefile */
+
+ ebuf.size = 200;
+ ebuf.buffer = ebuf.bufnext = ebuf.bufstart = xmalloc (ebuf.size);
+
+ curfile = reading_file;
+ reading_file = &ebuf.floc;
+
+ eval (&ebuf, !(flags & RM_NO_DEFAULT_GOAL));
+
+ reading_file = curfile;
+
+ fclose (ebuf.fp);
+
+ free (ebuf.bufstart);
+ free_alloca ();
+
+ errno = 0;
+ return deps;
+}
+
+void
+eval_buffer (char *buffer, const floc *flocp)
+{
+ struct ebuffer ebuf;
+ struct conditionals *saved;
+ struct conditionals new;
+ const floc *curfile;
+
+ /* Evaluate the buffer */
+
+ ebuf.size = strlen (buffer);
+ ebuf.buffer = ebuf.bufnext = ebuf.bufstart = buffer;
+ ebuf.fp = NULL;
+
+ if (flocp)
+ ebuf.floc = *flocp;
+ else if (reading_file)
+ ebuf.floc = *reading_file;
+ else
+ {
+ ebuf.floc.filenm = NULL;
+ ebuf.floc.lineno = 1;
+ ebuf.floc.offset = 0;
+ }
+
+ curfile = reading_file;
+ reading_file = &ebuf.floc;
+
+ saved = install_conditionals (&new);
+
+ eval (&ebuf, 1);
+
+ restore_conditionals (saved);
+
+ reading_file = curfile;
+
+ free_alloca ();
+}
+
+/* Check LINE to see if it's a variable assignment or undefine.
+
+ It might use one of the modifiers "export", "override", "private", or it
+ might be one of the conditional tokens like "ifdef", "include", etc.
+
+ If it's not a variable assignment or undefine, VMOD.V_ASSIGN is 0.
+ Returns LINE.
+
+ Returns a pointer to the first non-modifier character, and sets VMOD
+ based on the modifiers found if any, plus V_ASSIGN is 1.
+ */
+static char *
+parse_var_assignment (const char *line, int targvar, struct vmodifiers *vmod)
+{
+ const char *p;
+ memset (vmod, '\0', sizeof (*vmod));
+
+ /* Find the start of the next token. If there isn't one we're done. */
+ NEXT_TOKEN (line);
+ if (*line == '\0')
+ return (char *) line;
+
+ p = line;
+ while (1)
+ {
+ size_t wlen;
+ const char *p2;
+ struct variable v;
+
+ p2 = parse_variable_definition (p, &v);
+
+ /* If this is a variable assignment, we're done. */
+ if (p2)
+ break;
+
+ /* It's not a variable; see if it's a modifier. */
+ p2 = end_of_token (p);
+ wlen = p2 - p;
+
+ if (word1eq ("export"))
+ vmod->export_v = v_export;
+ else if (word1eq ("unexport"))
+ vmod->export_v = v_noexport;
+ else if (word1eq ("override"))
+ vmod->override_v = 1;
+ else if (word1eq ("private"))
+ vmod->private_v = 1;
+ else if (!targvar && word1eq ("define"))
+ {
+ /* We can't have modifiers after 'define' */
+ vmod->define_v = 1;
+ p = next_token (p2);
+ break;
+ }
+ else if (!targvar && word1eq ("undefine"))
+ {
+ /* We can't have modifiers after 'undefine' */
+ vmod->undefine_v = 1;
+ p = next_token (p2);
+ break;
+ }
+ else
+ /* Not a variable or modifier: this is not a variable assignment. */
+ return (char *) line;
+
+ /* It was a modifier. Try the next word. */
+ p = next_token (p2);
+ if (*p == '\0')
+ return (char *) line;
+ }
+
+ /* Found a variable assignment or undefine. */
+ vmod->assign_v = 1;
+ return (char *)p;
+}
+
+
+/* Read file FILENAME as a makefile and add its contents to the data base.
+
+ SET_DEFAULT is true if we are allowed to set the default goal. */
+
+static void
+eval (struct ebuffer *ebuf, int set_default)
+{
+ char *collapsed = 0;
+ size_t collapsed_length = 0;
+ size_t commands_len = 200;
+ char *commands;
+ size_t commands_idx = 0;
+ unsigned int cmds_started, tgts_started;
+ int ignoring = 0, in_ignored_define = 0;
+ int no_targets = 0; /* Set when reading a rule without targets. */
+ int also_make_targets = 0; /* Set when reading grouped targets. */
+ struct nameseq *filenames = 0;
+ char *depstr = 0;
+ long nlines = 0;
+ int two_colon = 0;
+ char prefix = cmd_prefix;
+ const char *pattern = 0;
+ const char *pattern_percent;
+ floc *fstart;
+ floc fi;
+
+#define record_waiting_files() \
+ do \
+ { \
+ if (filenames != 0) \
+ { \
+ fi.lineno = tgts_started; \
+ fi.offset = 0; \
+ record_files (filenames, also_make_targets, pattern, \
+ pattern_percent, depstr, \
+ cmds_started, commands, commands_idx, two_colon, \
+ prefix, &fi); \
+ filenames = 0; \
+ } \
+ commands_idx = 0; \
+ no_targets = 0; \
+ pattern = 0; \
+ also_make_targets = 0; \
+ } while (0)
+
+ pattern_percent = 0;
+ cmds_started = tgts_started = 1;
+
+ fstart = &ebuf->floc;
+ fi.filenm = ebuf->floc.filenm;
+
+ /* Loop over lines in the file.
+ The strategy is to accumulate target names in FILENAMES, dependencies
+ in DEPS and commands in COMMANDS. These are used to define a rule
+ when the start of the next rule (or eof) is encountered.
+
+ When you see a "continue" in the loop below, that means we are moving on
+ to the next line. If you see record_waiting_files(), then the statement
+ we are parsing also finishes the previous rule. */
+
+ commands = xmalloc (200);
+
+ while (1)
+ {
+ size_t linelen;
+ char *line;
+ size_t wlen;
+ char *p;
+ char *p2;
+ struct vmodifiers vmod;
+
+ /* At the top of this loop, we are starting a brand new line. */
+ /* Grab the next line to be evaluated */
+ ebuf->floc.lineno += nlines;
+ nlines = readline (ebuf);
+
+ /* If there is nothing left to eval, we're done. */
+ if (nlines < 0)
+ break;
+
+ line = ebuf->buffer;
+
+ /* If this is the first line, check for a UTF-8 BOM and skip it. */
+ if (ebuf->floc.lineno == 1)
+ {
+ unsigned char *ul = (unsigned char *) line;
+ if (ul[0] == 0xEF && ul[1] == 0xBB && ul[2] == 0xBF)
+ {
+ line += 3;
+ if (ISDB(DB_BASIC))
+ {
+ if (ebuf->floc.filenm)
+ printf (_("Skipping UTF-8 BOM in makefile '%s'\n"),
+ ebuf->floc.filenm);
+ else
+ printf (_("Skipping UTF-8 BOM in makefile buffer\n"));
+ }
+ }
+ }
+ /* If this line is empty, skip it. */
+ if (line[0] == '\0')
+ continue;
+
+ linelen = strlen (line);
+
+ /* Check for a shell command line first.
+ If it is not one, we can stop treating cmd_prefix specially. */
+ if (line[0] == cmd_prefix)
+ {
+ if (no_targets)
+ /* Ignore the commands in a rule with no targets. */
+ continue;
+
+ /* If there is no preceding rule line, don't treat this line
+ as a command, even though it begins with a recipe prefix.
+ SunOS 4 make appears to behave this way. */
+
+ if (filenames != 0)
+ {
+ if (ignoring)
+ /* Yep, this is a shell command, and we don't care. */
+ continue;
+
+ if (commands_idx == 0)
+ cmds_started = ebuf->floc.lineno;
+
+ /* Append this command line to the line being accumulated.
+ Skip the initial command prefix character. */
+ if (linelen + commands_idx > commands_len)
+ {
+ commands_len = (linelen + commands_idx) * 2;
+ commands = xrealloc (commands, commands_len);
+ }
+ memcpy (&commands[commands_idx], line + 1, linelen - 1);
+ commands_idx += linelen - 1;
+ commands[commands_idx++] = '\n';
+ continue;
+ }
+ }
+
+ /* This line is not a shell command line. Don't worry about whitespace.
+ Get more space if we need it; we don't need to preserve the current
+ contents of the buffer. */
+
+ if (collapsed_length < linelen+1)
+ {
+ collapsed_length = linelen+1;
+ free (collapsed);
+ /* Don't need xrealloc: we don't need to preserve the content. */
+ collapsed = xmalloc (collapsed_length);
+ }
+ strcpy (collapsed, line);
+ /* Collapse continuation lines. */
+ collapse_continuations (collapsed);
+ remove_comments (collapsed);
+
+ /* Get rid if starting space (including formfeed, vtab, etc.) */
+ p = collapsed;
+ NEXT_TOKEN (p);
+
+ /* See if this is a variable assignment. We need to do this early, to
+ allow variables with names like 'ifdef', 'export', 'private', etc. */
+ p = parse_var_assignment (p, 0, &vmod);
+ if (vmod.assign_v)
+ {
+ struct variable *v;
+ enum variable_origin origin = vmod.override_v ? o_override : o_file;
+
+ /* If we're ignoring then we're done now. */
+ if (ignoring)
+ {
+ if (vmod.define_v)
+ in_ignored_define = 1;
+ continue;
+ }
+
+ /* Variable assignment ends the previous rule. */
+ record_waiting_files ();
+
+ if (vmod.undefine_v)
+ {
+ do_undefine (p, origin, ebuf);
+ continue;
+ }
+ else if (vmod.define_v)
+ v = do_define (p, origin, ebuf);
+ else
+ v = try_variable_definition (fstart, p, origin, 0);
+
+ assert (v != NULL);
+
+ if (vmod.export_v != v_default)
+ v->export = vmod.export_v;
+ if (vmod.private_v)
+ v->private_var = 1;
+
+ /* This line has been dealt with. */
+ continue;
+ }
+
+ /* If this line is completely empty, ignore it. */
+ if (*p == '\0')
+ continue;
+
+ p2 = end_of_token (p);
+ wlen = p2 - p;
+ NEXT_TOKEN (p2);
+
+ /* If we're in an ignored define, skip this line (but maybe get out). */
+ if (in_ignored_define)
+ {
+ /* See if this is an endef line (plus optional comment). */
+ if (word1eq ("endef") && STOP_SET (*p2, MAP_COMMENT|MAP_NUL))
+ in_ignored_define = 0;
+
+ continue;
+ }
+
+ /* Check for conditional state changes. */
+ {
+ int i = conditional_line (p, wlen, fstart);
+ if (i != -2)
+ {
+ if (i == -1)
+ O (fatal, fstart, _("invalid syntax in conditional"));
+
+ ignoring = i;
+ continue;
+ }
+ }
+
+ /* Nothing to see here... move along. */
+ if (ignoring)
+ continue;
+
+ /* Manage the "export" keyword used outside of variable assignment
+ as well as "unexport". */
+ if (word1eq ("export") || word1eq ("unexport"))
+ {
+ int exporting = *p == 'u' ? 0 : 1;
+
+ /* Export/unexport ends the previous rule. */
+ record_waiting_files ();
+
+ /* (un)export by itself causes everything to be (un)exported. */
+ if (*p2 == '\0')
+ export_all_variables = exporting;
+ else
+ {
+ size_t l;
+ const char *cp;
+ char *ap;
+
+ /* Expand the line so we can use indirect and constructed
+ variable names in an (un)export command. */
+ cp = ap = allocated_variable_expand (p2);
+
+ for (p = find_next_token (&cp, &l); p != 0;
+ p = find_next_token (&cp, &l))
+ {
+ struct variable *v = lookup_variable (p, l);
+ if (v == 0)
+ v = define_variable_global (p, l, "", o_file, 0, fstart);
+ v->export = exporting ? v_export : v_noexport;
+ }
+
+ free (ap);
+ }
+ continue;
+ }
+
+ /* Handle the special syntax for vpath. */
+ if (word1eq ("vpath"))
+ {
+ const char *cp;
+ char *vpat;
+ size_t l;
+
+ /* vpath ends the previous rule. */
+ record_waiting_files ();
+
+ cp = variable_expand (p2);
+ p = find_next_token (&cp, &l);
+ if (p != 0)
+ {
+ vpat = xstrndup (p, l);
+ p = find_next_token (&cp, &l);
+ /* No searchpath means remove all previous
+ selective VPATH's with the same pattern. */
+ }
+ else
+ /* No pattern means remove all previous selective VPATH's. */
+ vpat = 0;
+ construct_vpath_list (vpat, p);
+ free (vpat);
+
+ continue;
+ }
+
+ /* Handle include and variants. */
+ if (word1eq ("include") || word1eq ("-include") || word1eq ("sinclude"))
+ {
+ /* We have found an 'include' line specifying a nested
+ makefile to be read at this point. */
+ struct conditionals *save;
+ struct conditionals new_conditionals;
+ struct nameseq *files;
+ /* "-include" (vs "include") says no error if the file does not
+ exist. "sinclude" is an alias for this from SGI. */
+ int noerror = (p[0] != 'i');
+
+ /* Include ends the previous rule. */
+ record_waiting_files ();
+
+ p = allocated_variable_expand (p2);
+
+ /* If no filenames, it's a no-op. */
+ if (*p == '\0')
+ {
+ free (p);
+ continue;
+ }
+
+ /* Parse the list of file names. Don't expand archive references! */
+ p2 = p;
+ files = PARSE_FILE_SEQ (&p2, struct nameseq, MAP_NUL, NULL,
+ PARSEFS_NOAR);
+ free (p);
+
+ /* Save the state of conditionals and start
+ the included makefile with a clean slate. */
+ save = install_conditionals (&new_conditionals);
+
+ /* Record the rules that are waiting so they will determine
+ the default goal before those in the included makefile. */
+ record_waiting_files ();
+
+ /* Read each included makefile. */
+ while (files != 0)
+ {
+ struct nameseq *next = files->next;
+ unsigned short flags = (RM_INCLUDED | RM_NO_TILDE
+ | (noerror ? RM_DONTCARE : 0)
+ | (set_default ? 0 : RM_NO_DEFAULT_GOAL));
+
+ struct goaldep *d = eval_makefile (files->name, flags);
+
+ if (errno)
+ d->floc = *fstart;
+
+ free_ns (files);
+ files = next;
+ }
+
+ /* Restore conditional state. */
+ restore_conditionals (save);
+
+ continue;
+ }
+
+ /* Handle the load operations. */
+ if (word1eq ("load") || word1eq ("-load"))
+ {
+ /* A 'load' line specifies a dynamic object to load. */
+ struct nameseq *files;
+ int noerror = (p[0] == '-');
+
+ /* Load ends the previous rule. */
+ record_waiting_files ();
+
+ p = allocated_variable_expand (p2);
+
+ /* If no filenames, it's a no-op. */
+ if (*p == '\0')
+ {
+ free (p);
+ continue;
+ }
+
+ /* Parse the list of file names.
+ Don't expand archive references or strip "./" */
+ p2 = p;
+ files = PARSE_FILE_SEQ (&p2, struct nameseq, MAP_NUL, NULL,
+ PARSEFS_NOAR);
+ free (p);
+
+ /* Load each file. */
+ while (files != 0)
+ {
+ struct nameseq *next = files->next;
+ const char *name = files->name;
+ struct goaldep *deps;
+ int r;
+
+ /* Load the file. 0 means failure. */
+ r = load_file (&ebuf->floc, &name, noerror);
+ if (! r && ! noerror)
+ OS (fatal, &ebuf->floc, _("%s: failed to load"), name);
+
+ free_ns (files);
+ files = next;
+
+ /* 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_goaldep ();
+ deps->next = read_files;
+ read_files = deps;
+ deps->file = lookup_file (name);
+ if (deps->file == 0)
+ deps->file = enter_file (name);
+ deps->file->loaded = 1;
+ }
+
+ continue;
+ }
+
+ /* This line starts with a tab but was not caught above because there
+ was no preceding target, and the line might have been usable as a
+ variable definition. But now we know it is definitely lossage. */
+ if (line[0] == cmd_prefix)
+ O (fatal, fstart, _("recipe commences before first target"));
+
+ /* This line describes some target files. This is complicated by
+ the existence of target-specific variables, because we can't
+ expand the entire line until we know if we have one or not. So
+ we expand the line word by word until we find the first ':',
+ then check to see if it's a target-specific variable.
+
+ In this algorithm, 'lb_next' will point to the beginning of the
+ unexpanded parts of the input buffer, while 'p2' points to the
+ parts of the expanded buffer we haven't searched yet. */
+
+ {
+ enum make_word_type wtype;
+ char *cmdleft, *semip, *lb_next;
+ size_t plen = 0;
+ char *colonp;
+ const char *end, *beg; /* Helpers for whitespace stripping. */
+
+ /* Record the previous rule. */
+
+ record_waiting_files ();
+ tgts_started = fstart->lineno;
+
+ /* Search the line for an unquoted ; that is not after an
+ unquoted #. */
+ cmdleft = find_map_unquote (line, MAP_SEMI|MAP_COMMENT|MAP_VARIABLE);
+ if (cmdleft != 0 && *cmdleft == '#')
+ {
+ /* We found a comment before a semicolon. */
+ *cmdleft = '\0';
+ cmdleft = 0;
+ }
+ else if (cmdleft != 0)
+ /* Found one. Cut the line short there before expanding it. */
+ *(cmdleft++) = '\0';
+ semip = cmdleft;
+
+ collapse_continuations (line);
+
+ /* We can't expand the entire line, since if it's a per-target
+ variable we don't want to expand it. So, walk from the
+ beginning, expanding as we go, and looking for "interesting"
+ chars. The first word is always expandable. */
+ wtype = get_next_mword (line, &lb_next, &wlen);
+ switch (wtype)
+ {
+ case w_eol:
+ if (cmdleft != 0)
+ O (fatal, fstart, _("missing rule before recipe"));
+ /* This line contained something but turned out to be nothing
+ but whitespace (a comment?). */
+ continue;
+
+ case w_colon:
+ case w_dcolon:
+ case w_ampcolon:
+ case w_ampdcolon:
+ /* We accept and ignore rules without targets for
+ compatibility with SunOS 4 make. */
+ no_targets = 1;
+ continue;
+
+ default:
+ break;
+ }
+
+ p2 = variable_expand_string (NULL, lb_next, wlen);
+
+ while (1)
+ {
+ lb_next += wlen;
+ if (cmdleft == 0)
+ {
+ /* Look for a semicolon in the expanded line. */
+ cmdleft = find_char_unquote (p2, ';');
+
+ if (cmdleft != 0)
+ {
+ size_t p2_off = p2 - variable_buffer;
+ size_t cmd_off = cmdleft - variable_buffer;
+ char *pend = p2 + strlen (p2);
+
+ /* Append any remnants of lb, then cut the line short
+ at the semicolon. */
+ *cmdleft = '\0';
+
+ /* One school of thought says that you shouldn't expand
+ here, but merely copy, since now you're beyond a ";"
+ and into a command script. However, the old parser
+ expanded the whole line, so we continue that for
+ backwards-compatibility. Also, it wouldn't be
+ entirely consistent, since we do an unconditional
+ expand below once we know we don't have a
+ target-specific variable. */
+ variable_expand_string (pend, lb_next, SIZE_MAX);
+ lb_next += strlen (lb_next);
+ p2 = variable_buffer + p2_off;
+ cmdleft = variable_buffer + cmd_off + 1;
+ }
+ }
+
+ colonp = find_char_unquote (p2, ':');
+
+#ifdef HAVE_DOS_PATHS
+ if (colonp > p2)
+ /* The drive spec brain-damage strikes again...
+ Note that the only separators of targets in this context are
+ whitespace and a left paren. If others are possible, add them
+ to the string in the call to strchr. */
+ while (colonp && (colonp[1] == '/' || colonp[1] == '\\') &&
+ isalpha ((unsigned char) colonp[-1]) &&
+ (colonp == p2 + 1 || strchr (" \t(", colonp[-2]) != 0))
+ colonp = find_char_unquote (colonp + 1, ':');
+#endif
+
+ if (colonp)
+ {
+ /* If the previous character is '&', back up before '&:' */
+ if (colonp > p2 && colonp[-1] == '&')
+ --colonp;
+
+ break;
+ }
+
+ wtype = get_next_mword (lb_next, &lb_next, &wlen);
+ if (wtype == w_eol)
+ break;
+
+ p2 += strlen (p2);
+ *(p2++) = ' ';
+ p2 = variable_expand_string (p2, lb_next, wlen);
+ /* We don't need to worry about cmdleft here, because if it was
+ found in the variable_buffer the entire buffer has already
+ been expanded... we'll never get here. */
+ }
+
+ p2 = next_token (variable_buffer);
+
+ /* If the word we're looking at is EOL, see if there's _anything_
+ on the line. If not, a variable expanded to nothing, so ignore
+ it. If so, we can't parse this line so punt. */
+ if (wtype == w_eol)
+ {
+ if (*p2 == '\0')
+ continue;
+
+ /* There's no need to be ivory-tower about this: check for
+ one of the most common bugs found in makefiles... */
+ if (cmd_prefix == '\t' && strneq (line, " ", 8))
+ O (fatal, fstart, _("missing separator (did you mean TAB instead of 8 spaces?)"));
+ else
+ O (fatal, fstart, _("missing separator"));
+ }
+
+ {
+ char save = *colonp;
+
+ /* If we have &:, it specifies that the targets are understood to be
+ updated/created together by a single invocation of the recipe. */
+ if (save == '&')
+ also_make_targets = 1;
+
+ /* Make the colon the end-of-string so we know where to stop
+ looking for targets. Start there again once we're done. */
+ *colonp = '\0';
+ filenames = PARSE_SIMPLE_SEQ (&p2, struct nameseq);
+ *colonp = save;
+ p2 = colonp + (save == '&');
+ }
+
+ if (!filenames)
+ {
+ /* We accept and ignore rules without targets for
+ compatibility with SunOS 4 make. */
+ no_targets = 1;
+ continue;
+ }
+ /* This should never be possible; we handled it above. */
+ assert (*p2 != '\0');
+ ++p2;
+
+ /* Is this a one-colon or two-colon entry? */
+ two_colon = *p2 == ':';
+ if (two_colon)
+ p2++;
+
+ /* Test to see if it's a target-specific variable. Copy the rest
+ of the buffer over, possibly temporarily (we'll expand it later
+ if it's not a target-specific variable). PLEN saves the length
+ of the unparsed section of p2, for later. */
+ if (*lb_next != '\0')
+ {
+ size_t l = p2 - variable_buffer;
+ plen = strlen (p2);
+ variable_buffer_output (p2+plen, lb_next, strlen (lb_next)+1);
+ p2 = variable_buffer + l;
+ }
+
+ p2 = parse_var_assignment (p2, 1, &vmod);
+ if (vmod.assign_v)
+ {
+ /* If there was a semicolon found, add it back, plus anything
+ after it. */
+ if (semip)
+ {
+ size_t l = p2 - variable_buffer;
+ *(--semip) = ';';
+ collapse_continuations (semip);
+ variable_buffer_output (p2 + strlen (p2),
+ semip, strlen (semip)+1);
+ p2 = variable_buffer + l;
+ }
+ record_target_var (filenames, p2,
+ vmod.override_v ? o_override : o_file,
+ &vmod, fstart);
+ filenames = 0;
+ continue;
+ }
+
+ /* This is a normal target, _not_ a target-specific variable.
+ Unquote any = in the dependency list. */
+ find_char_unquote (lb_next, '=');
+
+ /* Remember the command prefix for this target. */
+ prefix = cmd_prefix;
+
+ /* We have some targets, so don't ignore the following commands. */
+ no_targets = 0;
+
+ /* Expand the dependencies, etc. */
+ if (*lb_next != '\0')
+ {
+ size_t l = p2 - variable_buffer;
+ variable_expand_string (p2 + plen, lb_next, SIZE_MAX);
+ p2 = variable_buffer + l;
+
+ /* Look for a semicolon in the expanded line. */
+ if (cmdleft == 0)
+ {
+ cmdleft = find_char_unquote (p2, ';');
+ if (cmdleft != 0)
+ *(cmdleft++) = '\0';
+ }
+ }
+
+ /* Is this a static pattern rule: 'target: %targ: %dep; ...'? */
+ p = strchr (p2, ':');
+ while (p != 0 && p[-1] == '\\')
+ {
+ char *q = &p[-1];
+ int backslash = 0;
+ while (*q-- == '\\')
+ backslash = !backslash;
+ if (backslash)
+ p = strchr (p + 1, ':');
+ else
+ break;
+ }
+#ifdef _AMIGA
+ /* Here, the situation is quite complicated. Let's have a look
+ at a couple of targets:
+
+ install: dev:make
+
+ dev:make: make
+
+ dev:make:: xyz
+
+ The rule is that it's only a target, if there are TWO :'s
+ OR a space around the :.
+ */
+ if (p && !(ISSPACE (p[1]) || !p[1] || ISSPACE (p[-1])))
+ p = 0;
+#endif
+#ifdef HAVE_DOS_PATHS
+ {
+ int check_again;
+ do {
+ check_again = 0;
+ /* For DOS-style paths, skip a "C:\..." or a "C:/..." */
+ if (p != 0 && (p[1] == '\\' || p[1] == '/') &&
+ isalpha ((unsigned char)p[-1]) &&
+ (p == p2 + 1 || strchr (" \t:(", p[-2]) != 0)) {
+ p = strchr (p + 1, ':');
+ check_again = 1;
+ }
+ } while (check_again);
+ }
+#endif
+ if (p != 0)
+ {
+ struct nameseq *target;
+ target = PARSE_FILE_SEQ (&p2, struct nameseq, MAP_COLON, NULL,
+ PARSEFS_NOGLOB);
+ ++p2;
+ if (target == 0)
+ O (fatal, fstart, _("missing target pattern"));
+ else if (target->next != 0)
+ O (fatal, fstart, _("multiple target patterns"));
+ pattern_percent = find_percent_cached (&target->name);
+ pattern = target->name;
+ if (pattern_percent == 0)
+ O (fatal, fstart, _("target pattern contains no '%%'"));
+ free_ns (target);
+ }
+ else
+ pattern = 0;
+
+ /* Strip leading and trailing whitespaces. */
+ beg = p2;
+ end = beg + strlen (beg) - 1;
+ strip_whitespace (&beg, &end);
+
+ /* Put all the prerequisites here; they'll be parsed later. */
+ if (beg <= end && *beg != '\0')
+ depstr = xstrndup (beg, end - beg + 1);
+ else
+ depstr = 0;
+
+ commands_idx = 0;
+ if (cmdleft != 0)
+ {
+ /* Semicolon means rest of line is a command. */
+ size_t l = strlen (cmdleft);
+
+ cmds_started = fstart->lineno;
+
+ /* Add this command line to the buffer. */
+ if (l + 2 > commands_len)
+ {
+ commands_len = (l + 2) * 2;
+ commands = xrealloc (commands, commands_len);
+ }
+ memcpy (commands, cmdleft, l);
+ commands_idx += l;
+ commands[commands_idx++] = '\n';
+ }
+
+ check_specials (filenames, set_default);
+ }
+ }
+
+#undef word1eq
+
+ if (conditionals->if_cmds)
+ O (fatal, fstart, _("missing 'endif'"));
+
+ /* At eof, record the last rule. */
+ record_waiting_files ();
+
+ free (collapsed);
+ free (commands);
+}
+
+
+/* Remove comments from LINE.
+ This will also remove backslashes that escape things.
+ It ignores comment characters that appear inside variable references. */
+
+static void
+remove_comments (char *line)
+{
+ char *comment;
+
+ comment = find_map_unquote (line, MAP_COMMENT|MAP_VARIABLE);
+
+ if (comment != 0)
+ /* Cut off the line at the #. */
+ *comment = '\0';
+}
+
+/* Execute a 'undefine' directive.
+ The undefine line has already been read, and NAME is the name of
+ the variable to be undefined. */
+
+static void
+do_undefine (char *name, enum variable_origin origin, struct ebuffer *ebuf)
+{
+ char *p, *var;
+
+ /* Expand the variable name and find the beginning (NAME) and end. */
+ var = allocated_variable_expand (name);
+ name = next_token (var);
+ if (*name == '\0')
+ O (fatal, &ebuf->floc, _("empty variable name"));
+ p = name + strlen (name) - 1;
+ while (p > name && ISBLANK (*p))
+ --p;
+ p[1] = '\0';
+
+ undefine_variable_global (name, p - name + 1, origin);
+ free (var);
+}
+
+/* Execute a 'define' directive.
+ The first line has already been read, and NAME is the name of
+ the variable to be defined. The following lines remain to be read. */
+
+static struct variable *
+do_define (char *name, enum variable_origin origin, struct ebuffer *ebuf)
+{
+ struct variable *v;
+ struct variable var;
+ floc defstart;
+ int nlevels = 1;
+ size_t length = 100;
+ char *definition = xmalloc (length);
+ size_t idx = 0;
+ char *p, *n;
+
+ defstart = ebuf->floc;
+
+ p = parse_variable_definition (name, &var);
+ if (p == NULL)
+ /* No assignment token, so assume recursive. */
+ var.flavor = f_recursive;
+ else
+ {
+ if (var.value[0] != '\0')
+ O (error, &defstart, _("extraneous text after 'define' directive"));
+
+ /* Chop the string before the assignment token to get the name. */
+ var.name[var.length] = '\0';
+ }
+
+ /* Expand the variable name and find the beginning (NAME) and end. */
+ n = allocated_variable_expand (name);
+ name = next_token (n);
+ if (name[0] == '\0')
+ O (fatal, &defstart, _("empty variable name"));
+ p = name + strlen (name) - 1;
+ while (p > name && ISBLANK (*p))
+ --p;
+ p[1] = '\0';
+
+ /* Now read the value of the variable. */
+ while (1)
+ {
+ size_t len;
+ char *line;
+ long nlines = readline (ebuf);
+
+ /* If there is nothing left to be eval'd, there's no 'endef'!! */
+ if (nlines < 0)
+ O (fatal, &defstart, _("missing 'endef', unterminated 'define'"));
+
+ ebuf->floc.lineno += nlines;
+ line = ebuf->buffer;
+
+ collapse_continuations (line);
+
+ /* If the line doesn't begin with a tab, test to see if it introduces
+ another define, or ends one. Stop if we find an 'endef' */
+ if (line[0] != cmd_prefix)
+ {
+ p = next_token (line);
+ len = strlen (p);
+
+ /* If this is another 'define', increment the level count. */
+ if ((len == 6 || (len > 6 && ISBLANK (p[6])))
+ && strneq (p, "define", 6))
+ ++nlevels;
+
+ /* If this is an 'endef', decrement the count. If it's now 0,
+ we've found the last one. */
+ else if ((len == 5 || (len > 5 && ISBLANK (p[5])))
+ && strneq (p, "endef", 5))
+ {
+ p += 5;
+ remove_comments (p);
+ if (*(next_token (p)) != '\0')
+ O (error, &ebuf->floc,
+ _("extraneous text after 'endef' directive"));
+
+ if (--nlevels == 0)
+ break;
+ }
+ }
+
+ /* Add this line to the variable definition. */
+ len = strlen (line);
+ if (idx + len + 1 > length)
+ {
+ length = (idx + len) * 2;
+ definition = xrealloc (definition, length + 1);
+ }
+
+ memcpy (&definition[idx], line, len);
+ idx += len;
+ /* Separate lines with a newline. */
+ definition[idx++] = '\n';
+ }
+
+ /* We've got what we need; define the variable. */
+ if (idx == 0)
+ definition[0] = '\0';
+ else
+ definition[idx - 1] = '\0';
+
+ v = do_variable_definition (&defstart, name,
+ definition, origin, var.flavor, 0);
+ free (definition);
+ free (n);
+ return (v);
+}
+
+/* Interpret conditional commands "ifdef", "ifndef", "ifeq",
+ "ifneq", "else" and "endif".
+ LINE is the input line, with the command as its first word.
+
+ FILENAME and LINENO are the filename and line number in the
+ current makefile. They are used for error messages.
+
+ Value is -2 if the line is not a conditional at all,
+ -1 if the line is an invalid conditional,
+ 0 if following text should be interpreted,
+ 1 if following text should be ignored. */
+
+static int
+conditional_line (char *line, size_t len, const floc *flocp)
+{
+ const char *cmdname;
+ enum { c_ifdef, c_ifndef, c_ifeq, c_ifneq, c_else, c_endif } cmdtype;
+ unsigned int i;
+ unsigned int o;
+
+ /* Compare a word, both length and contents. */
+#define word1eq(s) (len == CSTRLEN (s) && strneq (s, line, CSTRLEN (s)))
+#define chkword(s, t) if (word1eq (s)) { cmdtype = (t); cmdname = (s); }
+
+ /* Make sure this line is a conditional. */
+ chkword ("ifdef", c_ifdef)
+ else chkword ("ifndef", c_ifndef)
+ else chkword ("ifeq", c_ifeq)
+ else chkword ("ifneq", c_ifneq)
+ else chkword ("else", c_else)
+ else chkword ("endif", c_endif)
+ else
+ return -2;
+
+ /* Found one: skip past it and any whitespace after it. */
+ line += len;
+ NEXT_TOKEN (line);
+
+#define EXTRATEXT() OS (error, flocp, _("extraneous text after '%s' directive"), cmdname)
+#define EXTRACMD() OS (fatal, flocp, _("extraneous '%s'"), cmdname)
+
+ /* An 'endif' cannot contain extra text, and reduces the if-depth by 1 */
+ if (cmdtype == c_endif)
+ {
+ if (*line != '\0')
+ EXTRATEXT ();
+
+ if (!conditionals->if_cmds)
+ EXTRACMD ();
+
+ --conditionals->if_cmds;
+
+ goto DONE;
+ }
+
+ /* An 'else' statement can either be simple, or it can have another
+ conditional after it. */
+ if (cmdtype == c_else)
+ {
+ const char *p;
+
+ if (!conditionals->if_cmds)
+ EXTRACMD ();
+
+ o = conditionals->if_cmds - 1;
+
+ if (conditionals->seen_else[o])
+ O (fatal, flocp, _("only one 'else' per conditional"));
+
+ /* Change the state of ignorance. */
+ switch (conditionals->ignoring[o])
+ {
+ case 0:
+ /* We've just been interpreting. Never do it again. */
+ conditionals->ignoring[o] = 2;
+ break;
+ case 1:
+ /* We've never interpreted yet. Maybe this time! */
+ conditionals->ignoring[o] = 0;
+ break;
+ }
+
+ /* It's a simple 'else'. */
+ if (*line == '\0')
+ {
+ conditionals->seen_else[o] = 1;
+ goto DONE;
+ }
+
+ /* The 'else' has extra text. That text must be another conditional
+ and cannot be an 'else' or 'endif'. */
+
+ /* Find the length of the next word. */
+ for (p = line+1; ! STOP_SET (*p, MAP_SPACE|MAP_NUL); ++p)
+ ;
+ len = p - line;
+
+ /* If it's 'else' or 'endif' or an illegal conditional, fail. */
+ if (word1eq ("else") || word1eq ("endif")
+ || conditional_line (line, len, flocp) < 0)
+ EXTRATEXT ();
+ else
+ {
+ /* conditional_line() created a new level of conditional.
+ Raise it back to this level. */
+ if (conditionals->ignoring[o] < 2)
+ conditionals->ignoring[o] = conditionals->ignoring[o+1];
+ --conditionals->if_cmds;
+ }
+
+ goto DONE;
+ }
+
+ if (conditionals->allocated == 0)
+ {
+ conditionals->allocated = 5;
+ conditionals->ignoring = xmalloc (conditionals->allocated);
+ conditionals->seen_else = xmalloc (conditionals->allocated);
+ }
+
+ o = conditionals->if_cmds++;
+ if (conditionals->if_cmds > conditionals->allocated)
+ {
+ conditionals->allocated += 5;
+ conditionals->ignoring = xrealloc (conditionals->ignoring,
+ conditionals->allocated);
+ conditionals->seen_else = xrealloc (conditionals->seen_else,
+ conditionals->allocated);
+ }
+
+ /* Record that we have seen an 'if...' but no 'else' so far. */
+ conditionals->seen_else[o] = 0;
+
+ /* Search through the stack to see if we're already ignoring. */
+ for (i = 0; i < o; ++i)
+ if (conditionals->ignoring[i])
+ {
+ /* We are already ignoring, so just push a level to match the next
+ "else" or "endif", and keep ignoring. We don't want to expand
+ variables in the condition. */
+ conditionals->ignoring[o] = 1;
+ return 1;
+ }
+
+ if (cmdtype == c_ifdef || cmdtype == c_ifndef)
+ {
+ size_t l;
+ char *var;
+ struct variable *v;
+ char *p;
+
+ /* Expand the thing we're looking up, so we can use indirect and
+ constructed variable names. */
+ var = allocated_variable_expand (line);
+
+ /* Make sure there's only one variable name to test. */
+ p = end_of_token (var);
+ l = p - var;
+ NEXT_TOKEN (p);
+ if (*p != '\0')
+ return -1;
+
+ var[l] = '\0';
+ v = lookup_variable (var, l);
+
+ conditionals->ignoring[o] =
+ ((v != 0 && *v->value != '\0') == (cmdtype == c_ifndef));
+
+ free (var);
+ }
+ else
+ {
+ /* "ifeq" or "ifneq". */
+ char *s1, *s2;
+ size_t l;
+ char termin = *line == '(' ? ',' : *line;
+
+ if (termin != ',' && termin != '"' && termin != '\'')
+ return -1;
+
+ s1 = ++line;
+ /* Find the end of the first string. */
+ if (termin == ',')
+ {
+ int count = 0;
+ for (; *line != '\0'; ++line)
+ if (*line == '(')
+ ++count;
+ else if (*line == ')')
+ --count;
+ else if (*line == ',' && count <= 0)
+ break;
+ }
+ else
+ while (*line != '\0' && *line != termin)
+ ++line;
+
+ if (*line == '\0')
+ return -1;
+
+ if (termin == ',')
+ {
+ /* Strip blanks after the first string. */
+ char *p = line++;
+ while (ISBLANK (p[-1]))
+ --p;
+ *p = '\0';
+ }
+ else
+ *line++ = '\0';
+
+ s2 = variable_expand (s1);
+ /* We must allocate a new copy of the expanded string because
+ variable_expand re-uses the same buffer. */
+ l = strlen (s2);
+ s1 = alloca (l + 1);
+ memcpy (s1, s2, l + 1);
+
+ if (termin != ',')
+ /* Find the start of the second string. */
+ NEXT_TOKEN (line);
+
+ termin = termin == ',' ? ')' : *line;
+ if (termin != ')' && termin != '"' && termin != '\'')
+ return -1;
+
+ /* Find the end of the second string. */
+ if (termin == ')')
+ {
+ int count = 0;
+ s2 = next_token (line);
+ for (line = s2; *line != '\0'; ++line)
+ {
+ if (*line == '(')
+ ++count;
+ else if (*line == ')')
+ {
+ if (count <= 0)
+ break;
+ else
+ --count;
+ }
+ }
+ }
+ else
+ {
+ ++line;
+ s2 = line;
+ while (*line != '\0' && *line != termin)
+ ++line;
+ }
+
+ if (*line == '\0')
+ return -1;
+
+ *(line++) = '\0';
+ NEXT_TOKEN (line);
+ if (*line != '\0')
+ EXTRATEXT ();
+
+ s2 = variable_expand (s2);
+ conditionals->ignoring[o] = (streq (s1, s2) == (cmdtype == c_ifneq));
+ }
+
+ DONE:
+ /* Search through the stack to see if we're ignoring. */
+ for (i = 0; i < conditionals->if_cmds; ++i)
+ if (conditionals->ignoring[i])
+ return 1;
+ return 0;
+}
+
+
+/* Record target-specific variable values for files FILENAMES.
+ TWO_COLON is nonzero if a double colon was used.
+
+ The links of FILENAMES are freed, and so are any names in it
+ that are not incorporated into other data structures.
+
+ If the target is a pattern, add the variable to the pattern-specific
+ variable value list. */
+
+static void
+record_target_var (struct nameseq *filenames, char *defn,
+ enum variable_origin origin, struct vmodifiers *vmod,
+ const floc *flocp)
+{
+ struct nameseq *nextf;
+ struct variable_set_list *global;
+
+ global = current_variable_set_list;
+
+ /* If the variable is an append version, store that but treat it as a
+ normal recursive variable. */
+
+ for (; filenames != 0; filenames = nextf)
+ {
+ struct variable *v;
+ const char *name = filenames->name;
+ const char *percent;
+ struct pattern_var *p;
+
+ nextf = filenames->next;
+ free_ns (filenames);
+
+ /* If it's a pattern target, then add it to the pattern-specific
+ variable list. */
+ percent = find_percent_cached (&name);
+ if (percent)
+ {
+ /* Get a reference for this pattern-specific variable struct. */
+ p = create_pattern_var (name, percent);
+ p->variable.fileinfo = *flocp;
+ /* I don't think this can fail since we already determined it was a
+ variable definition. */
+ v = assign_variable_definition (&p->variable, defn);
+ assert (v != 0);
+
+ v->origin = origin;
+ if (v->flavor == f_simple)
+ v->value = allocated_variable_expand (v->value);
+ else
+ v->value = xstrdup (v->value);
+ }
+ else
+ {
+ struct file *f;
+
+ /* Get a file reference for this file, and initialize it.
+ We don't want to just call enter_file() because that allocates a
+ new entry if the file is a double-colon, which we don't want in
+ this situation. */
+ f = lookup_file (name);
+ if (!f)
+ f = enter_file (strcache_add (name));
+ else if (f->double_colon)
+ f = f->double_colon;
+
+ initialize_file_variables (f, 1);
+
+ current_variable_set_list = f->variables;
+ v = try_variable_definition (flocp, defn, origin, 1);
+ if (!v)
+ O (fatal, flocp, _("Malformed target-specific variable definition"));
+ current_variable_set_list = global;
+ }
+
+ /* Set up the variable to be *-specific. */
+ v->per_target = 1;
+ v->private_var = vmod->private_v;
+ if (vmod->export_v != v_default)
+ v->export = vmod->export_v;
+
+ /* If it's not an override, check to see if there was a command-line
+ setting. If so, reset the value. */
+ if (v->origin != o_override)
+ {
+ struct variable *gv;
+ size_t len = strlen (v->name);
+
+ gv = lookup_variable (v->name, len);
+ if (gv && v != gv
+ && (gv->origin == o_env_override || gv->origin == o_command))
+ {
+ free (v->value);
+ v->value = xstrdup (gv->value);
+ v->origin = gv->origin;
+ v->recursive = gv->recursive;
+ v->append = 0;
+ }
+ }
+ }
+}
+
+
+/* Check for special targets. We used to do this in record_files() but that's
+ too late: by the time we get there we'll have already parsed the next line
+ and it have been mis-parsed because these special targets haven't been
+ considered yet. */
+
+static void check_specials (const struct nameseq* files, int set_default)
+{
+ const struct nameseq *t = files;
+
+ /* Unlikely but ... */
+ if (posix_pedantic && second_expansion && one_shell
+ && (!set_default || default_goal_var->value[0] == '\0'))
+ return;
+
+ for (; t != 0; t = t->next)
+ {
+ const char* nm = t->name;
+
+ if (!posix_pedantic && streq (nm, ".POSIX"))
+ {
+ posix_pedantic = 1;
+ define_variable_cname (".SHELLFLAGS", "-ec", o_default, 0);
+ /* These default values are based on IEEE Std 1003.1-2008.
+ It requires '-O 1' for [CF]FLAGS, but GCC doesn't allow
+ space between -O and the number so omit it here. */
+ define_variable_cname ("CC", "c99", o_default, 0);
+ define_variable_cname ("CFLAGS", "-O1", o_default, 0);
+ define_variable_cname ("FC", "fort77", o_default, 0);
+ define_variable_cname ("FFLAGS", "-O1", o_default, 0);
+ define_variable_cname ("SCCSGETFLAGS", "-s", o_default, 0);
+ continue;
+ }
+
+ if (!second_expansion && streq (nm, ".SECONDEXPANSION"))
+ {
+ second_expansion = 1;
+ continue;
+ }
+
+#if !defined (__MSDOS__) && !defined (__EMX__)
+ if (!one_shell && streq (nm, ".ONESHELL"))
+ {
+ one_shell = 1;
+ continue;
+ }
+#endif
+
+ /* Determine if this target should be made default. */
+
+ if (set_default && default_goal_var->value[0] == '\0')
+ {
+ struct dep *d;
+ int reject = 0;
+
+ /* We have nothing to do if this is an implicit rule. */
+ if (strchr (nm, '%') != 0)
+ break;
+
+ /* See if this target's name does not start with a '.',
+ unless it contains a slash. */
+ if (*nm == '.' && strchr (nm, '/') == 0
+#ifdef HAVE_DOS_PATHS
+ && strchr (nm, '\\') == 0
+#endif
+ )
+ continue;
+
+ /* If this file is a suffix, it can't be the default goal file. */
+ for (d = suffix_file->deps; d != 0; d = d->next)
+ {
+ struct dep *d2;
+ if (*dep_name (d) != '.' && streq (nm, dep_name (d)))
+ {
+ reject = 1;
+ break;
+ }
+ for (d2 = suffix_file->deps; d2 != 0; d2 = d2->next)
+ {
+ size_t l = strlen (dep_name (d2));
+ if (!strneq (nm, dep_name (d2), l))
+ continue;
+ if (streq (nm + l, dep_name (d)))
+ {
+ reject = 1;
+ break;
+ }
+ }
+
+ if (reject)
+ break;
+ }
+
+ if (!reject)
+ define_variable_global (".DEFAULT_GOAL", 13, t->name,
+ o_file, 0, NILF);
+ }
+ }
+}
+
+/* Record a description line for files FILENAMES,
+ with dependencies DEPS, commands to execute described
+ by COMMANDS and COMMANDS_IDX, coming from FILENAME:COMMANDS_STARTED.
+ TWO_COLON is nonzero if a double colon was used.
+ If not nil, PATTERN is the '%' pattern to make this
+ a static pattern rule, and PATTERN_PERCENT is a pointer
+ to the '%' within it.
+
+ The links of FILENAMES are freed, and so are any names in it
+ that are not incorporated into other data structures. */
+
+static void
+record_files (struct nameseq *filenames, int are_also_makes,
+ const char *pattern,
+ const char *pattern_percent, char *depstr,
+ unsigned int cmds_started, char *commands,
+ size_t commands_idx, int two_colon,
+ char prefix, const floc *flocp)
+{
+ struct commands *cmds;
+ struct dep *deps;
+ struct dep *also_make = NULL;
+ const char *implicit_percent;
+ const char *name;
+
+ /* If we've already snapped deps, that means we're in an eval being
+ resolved after the makefiles have been read in. We can't add more rules
+ at this time, since they won't get snapped and we'll get core dumps.
+ See Savannah bug # 12124. */
+ if (snapped_deps)
+ O (fatal, flocp, _("prerequisites cannot be defined in recipes"));
+
+ /* Determine if this is a pattern rule or not. */
+ name = filenames->name;
+ implicit_percent = find_percent_cached (&name);
+
+ /* If there's a recipe, set up a struct for it. */
+ if (commands_idx > 0)
+ {
+ cmds = xmalloc (sizeof (struct commands));
+ cmds->fileinfo.filenm = flocp->filenm;
+ cmds->fileinfo.lineno = cmds_started;
+ cmds->fileinfo.offset = 0;
+ cmds->commands = xstrndup (commands, commands_idx);
+ cmds->command_lines = 0;
+ cmds->recipe_prefix = prefix;
+ }
+ else if (are_also_makes)
+ O (fatal, flocp, _("grouped targets must provide a recipe"));
+ else
+ cmds = NULL;
+
+ /* If there's a prereq string then parse it--unless it's eligible for 2nd
+ expansion: if so, snap_deps() will do it. */
+ if (depstr == 0)
+ deps = 0;
+ else
+ {
+ depstr = unescape_char (depstr, ':');
+ if (second_expansion && strchr (depstr, '$'))
+ {
+ deps = alloc_dep ();
+ deps->name = depstr;
+ deps->need_2nd_expansion = 1;
+ deps->staticpattern = pattern != 0;
+ }
+ else
+ {
+ deps = split_prereqs (depstr);
+ free (depstr);
+
+ /* We'll enter static pattern prereqs later when we have the stem.
+ We don't want to enter pattern rules at all so that we don't
+ think that they ought to exist (make manual "Implicit Rule Search
+ Algorithm", item 5c). */
+ if (! pattern && ! implicit_percent)
+ deps = enter_prereqs (deps, NULL);
+ }
+ }
+
+ /* For implicit rules, _all_ the targets must have a pattern. That means we
+ can test the first one to see if we're working with an implicit rule; if
+ so we handle it specially. */
+
+ if (implicit_percent)
+ {
+ struct nameseq *nextf;
+ const char **targets, **target_pats;
+ unsigned short c;
+
+ if (pattern != 0)
+ O (fatal, flocp, _("mixed implicit and static pattern rules"));
+
+ /* Count the targets to create an array of target names.
+ We already have the first one. */
+ nextf = filenames->next;
+ free_ns (filenames);
+ filenames = nextf;
+
+ for (c = 1; nextf; ++c, nextf = nextf->next)
+ ;
+ targets = xmalloc (c * sizeof (const char *));
+ target_pats = xmalloc (c * sizeof (const char *));
+
+ targets[0] = name;
+ target_pats[0] = implicit_percent;
+
+ c = 1;
+ while (filenames)
+ {
+ name = filenames->name;
+ implicit_percent = find_percent_cached (&name);
+
+ if (implicit_percent == 0)
+ O (fatal, flocp, _("mixed implicit and normal rules"));
+
+ targets[c] = name;
+ target_pats[c] = implicit_percent;
+ ++c;
+
+ nextf = filenames->next;
+ free_ns (filenames);
+ filenames = nextf;
+ }
+
+ create_pattern_rule (targets, target_pats, c, two_colon, deps, cmds, 1);
+
+ return;
+ }
+
+
+ /* Walk through each target and create it in the database.
+ We already set up the first target, above. */
+ while (1)
+ {
+ struct nameseq *nextf = filenames->next;
+ struct file *f;
+ struct dep *this = 0;
+
+ free_ns (filenames);
+
+ /* If this is a static pattern rule:
+ 'targets: target%pattern: prereq%pattern; recipe',
+ make sure the pattern matches this target name. */
+ if (pattern && !pattern_matches (pattern, pattern_percent, name))
+ OS (error, flocp,
+ _("target '%s' doesn't match the target pattern"), name);
+ else if (deps)
+ /* If there are multiple targets, copy the chain DEPS for all but the
+ last one. It is not safe for the same deps to go in more than one
+ place in the database. */
+ this = nextf != 0 ? copy_dep_chain (deps) : deps;
+
+ /* Find or create an entry in the file database for this target. */
+ if (!two_colon)
+ {
+ /* Single-colon. Combine this rule with the file's existing record,
+ if any. */
+ f = enter_file (strcache_add (name));
+ if (f->double_colon)
+ OS (fatal, flocp,
+ _("target file '%s' has both : and :: entries"), f->name);
+
+ /* If CMDS == F->CMDS, this target was listed in this rule
+ more than once. Just give a warning since this is harmless. */
+ if (cmds != 0 && cmds == f->cmds)
+ OS (error, flocp,
+ _("target '%s' given more than once in the same rule"),
+ f->name);
+
+ /* Check for two single-colon entries both with commands.
+ Check is_target so that we don't lose on files such as .c.o
+ whose commands were preinitialized. */
+ else if (cmds != 0 && f->cmds != 0 && f->is_target)
+ {
+ size_t l = strlen (f->name);
+ error (&cmds->fileinfo, l,
+ _("warning: overriding recipe for target '%s'"),
+ f->name);
+ error (&f->cmds->fileinfo, l,
+ _("warning: ignoring old recipe for target '%s'"),
+ f->name);
+ }
+
+ /* Defining .DEFAULT with no deps or cmds clears it. */
+ if (f == default_file && this == 0 && cmds == 0)
+ f->cmds = 0;
+ if (cmds != 0)
+ f->cmds = cmds;
+
+ /* Defining .SUFFIXES with no dependencies clears out the list of
+ suffixes. */
+ if (f == suffix_file && this == 0)
+ {
+ free_dep_chain (f->deps);
+ f->deps = 0;
+ }
+ }
+ else
+ {
+ /* Double-colon. Make a new record even if there already is one. */
+ f = lookup_file (name);
+
+ /* Check for both : and :: rules. Check is_target so we don't lose
+ on default suffix rules or makefiles. */
+ if (f != 0 && f->is_target && !f->double_colon)
+ OS (fatal, flocp,
+ _("target file '%s' has both : and :: entries"), f->name);
+
+ f = enter_file (strcache_add (name));
+ /* If there was an existing entry and it was a double-colon entry,
+ enter_file will have returned a new one, making it the prev
+ pointer of the old one, and setting its double_colon pointer to
+ the first one. */
+ if (f->double_colon == 0)
+ /* This is the first entry for this name, so we must set its
+ double_colon pointer to itself. */
+ f->double_colon = f;
+
+ f->cmds = cmds;
+ }
+
+ if (are_also_makes)
+ {
+ struct dep *also = alloc_dep();
+ also->name = f->name;
+ also->file = f;
+ also->next = also_make;
+ also_make = also;
+ }
+
+ f->is_target = 1;
+
+ /* If this is a static pattern rule, set the stem to the part of its
+ name that matched the '%' in the pattern, so you can use $* in the
+ commands. If we didn't do it before, enter the prereqs now. */
+ if (pattern)
+ {
+ static const char *percent = "%";
+ char *o = patsubst_expand_pat (variable_buffer, name, pattern,
+ percent, pattern_percent+1, percent+1);
+ f->stem = strcache_add_len (variable_buffer, o - variable_buffer);
+ if (this)
+ {
+ if (! this->need_2nd_expansion)
+ this = enter_prereqs (this, f->stem);
+ else
+ this->stem = f->stem;
+ }
+ }
+
+ /* Add the dependencies to this file entry. */
+ if (this != 0)
+ {
+ /* Add the file's old deps and the new ones in THIS together. */
+ if (f->deps == 0)
+ f->deps = this;
+ else if (cmds != 0)
+ {
+ struct dep *d = this;
+
+ /* If this rule has commands, put these deps first. */
+ while (d->next != 0)
+ d = d->next;
+
+ d->next = f->deps;
+ f->deps = this;
+ }
+ else
+ {
+ struct dep *d = f->deps;
+
+ /* A rule without commands: put its prereqs at the end. */
+ while (d->next != 0)
+ d = d->next;
+
+ d->next = this;
+ }
+ }
+
+ name = f->name;
+
+ /* All done! Set up for the next one. */
+ if (nextf == 0)
+ break;
+
+ filenames = nextf;
+
+ /* Reduce escaped percents. If there are any unescaped it's an error */
+ name = filenames->name;
+ if (find_percent_cached (&name))
+ O (error, flocp,
+ _("*** mixed implicit and normal rules: deprecated syntax"));
+ }
+
+ /* If there are also-makes, then populate a copy of the also-make list into
+ each one. For the last file, we take our original also_make list instead
+ wastefully copying it one more time and freeing it. */
+ {
+ struct dep *i;
+
+ for (i = also_make; i != NULL; i = i->next)
+ {
+ struct file *f = i->file;
+ struct dep *cpy = i->next ? copy_dep_chain (also_make) : also_make;
+
+ if (f->also_make)
+ {
+ OS (error, &cmds->fileinfo,
+ _("warning: overriding group membership for target '%s'"),
+ f->name);
+ free_dep_chain (f->also_make);
+ }
+
+ f->also_make = cpy;
+ }
+ }
+}
+
+/* Search STRING for an unquoted STOPMAP.
+ Backslashes quote elements from STOPMAP and backslash.
+ Quoting backslashes are removed from STRING by compacting it into itself.
+ Returns a pointer to the first unquoted STOPCHAR if there is one, or nil if
+ there are none.
+
+ If MAP_VARIABLE is set, then the complete contents of variable references
+ are skipped, even if the contain STOPMAP characters. */
+
+static char *
+find_map_unquote (char *string, int stopmap)
+{
+ size_t string_len = 0;
+ char *p = string;
+
+ /* Always stop on NUL. */
+ stopmap |= MAP_NUL;
+
+ while (1)
+ {
+ while (! STOP_SET (*p, stopmap))
+ ++p;
+
+ if (*p == '\0')
+ break;
+
+ /* If we stopped due to a variable reference, skip over its contents. */
+ if (*p == '$')
+ {
+ char openparen = p[1];
+
+ /* Check if '$' is the last character in the string. */
+ if (openparen == '\0')
+ break;
+
+ p += 2;
+
+ /* Skip the contents of a non-quoted, multi-char variable ref. */
+ if (openparen == '(' || openparen == '{')
+ {
+ unsigned int pcount = 1;
+ char closeparen = (openparen == '(' ? ')' : '}');
+
+ while (*p)
+ {
+ if (*p == openparen)
+ ++pcount;
+ else if (*p == closeparen)
+ if (--pcount == 0)
+ {
+ ++p;
+ break;
+ }
+ ++p;
+ }
+ }
+
+ /* Skipped the variable reference: look for STOPCHARS again. */
+ continue;
+ }
+
+ if (p > string && p[-1] == '\\')
+ {
+ /* Search for more backslashes. */
+ int i = -2;
+ while (&p[i] >= string && p[i] == '\\')
+ --i;
+ ++i;
+ /* Only compute the length if really needed. */
+ if (string_len == 0)
+ string_len = strlen (string);
+ /* The number of backslashes is now -I.
+ Copy P over itself to swallow half of them. */
+ memmove (&p[i], &p[i/2], (string_len - (p - string)) - (i/2) + 1);
+ p += i/2;
+ if (i % 2 == 0)
+ /* All the backslashes quoted each other; the STOPCHAR was
+ unquoted. */
+ return p;
+
+ /* The STOPCHAR was quoted by a backslash. Look for another. */
+ }
+ else
+ /* No backslash in sight. */
+ return p;
+ }
+
+ /* Never hit a STOPCHAR or blank (with BLANK nonzero). */
+ return 0;
+}
+
+static char *
+find_char_unquote (char *string, int stop)
+{
+ size_t string_len = 0;
+ char *p = string;
+
+ while (1)
+ {
+ p = strchr(p, stop);
+
+ if (!p)
+ return NULL;
+
+ if (p > string && p[-1] == '\\')
+ {
+ /* Search for more backslashes. */
+ int i = -2;
+ while (&p[i] >= string && p[i] == '\\')
+ --i;
+ ++i;
+ /* Only compute the length if really needed. */
+ if (string_len == 0)
+ string_len = strlen (string);
+ /* The number of backslashes is now -I.
+ Copy P over itself to swallow half of them. */
+ memmove (&p[i], &p[i/2], (string_len - (p - string)) - (i/2) + 1);
+ p += i/2;
+ if (i % 2 == 0)
+ /* All the backslashes quoted each other; the STOPCHAR was
+ unquoted. */
+ return p;
+
+ /* The STOPCHAR was quoted by a backslash. Look for another. */
+ }
+ else
+ /* No backslash in sight. */
+ return p;
+ }
+}
+
+/* Unescape a character in a string. The string is compressed onto itself. */
+
+static char *
+unescape_char (char *string, int c)
+{
+ char *p = string;
+ char *s = string;
+
+ while (*s != '\0')
+ {
+ if (*s == '\\')
+ {
+ char *e = s;
+ size_t l;
+
+ /* We found a backslash. See if it's escaping our character. */
+ while (*e == '\\')
+ ++e;
+ l = e - s;
+
+ if (*e != c || l%2 == 0)
+ {
+ /* It's not; just take it all without unescaping. */
+ memmove (p, s, l);
+ p += l;
+
+ /* If we hit the end of the string, we're done. */
+ if (*e == '\0')
+ break;
+ }
+ else if (l > 1)
+ {
+ /* It is, and there's >1 backslash. Take half of them. */
+ l /= 2;
+ memmove (p, s, l);
+ p += l;
+ }
+
+ s = e;
+ }
+
+ *(p++) = *(s++);
+ }
+
+ *p = '\0';
+ return string;
+}
+
+/* Search PATTERN for an unquoted % and handle quoting. */
+
+char *
+find_percent (char *pattern)
+{
+ return find_char_unquote (pattern, '%');
+}
+
+/* Search STRING for an unquoted % and handle quoting. Returns a pointer to
+ the % or NULL if no % was found.
+ This version is used with strings in the string cache: if there's a need to
+ modify the string a new version will be added to the string cache and
+ *STRING will be set to that. */
+
+const char *
+find_percent_cached (const char **string)
+{
+ const char *p = *string;
+ char *new = 0;
+ size_t slen = 0;
+
+ /* If the first char is a % return now. This lets us avoid extra tests
+ inside the loop. */
+ if (*p == '%')
+ return p;
+
+ while (1)
+ {
+ p = strchr(p, '%');
+
+ if (!p)
+ break;
+
+ /* See if this % is escaped with a backslash; if not we're done. */
+ if (p[-1] != '\\')
+ break;
+
+ {
+ /* Search for more backslashes. */
+ char *pv;
+ int i = -2;
+
+ while (&p[i] >= *string && p[i] == '\\')
+ --i;
+ ++i;
+
+ /* At this point we know we'll need to allocate a new string.
+ Make a copy if we haven't yet done so. */
+ if (! new)
+ {
+ slen = strlen (*string);
+ new = xmalloc (slen + 1);
+ memcpy (new, *string, slen + 1);
+ p = new + (p - *string);
+ *string = new;
+ }
+
+ /* At this point *string, p, and new all point into the same string.
+ Get a non-const version of p so we can modify new. */
+ pv = new + (p - *string);
+
+ /* The number of backslashes is now -I.
+ Copy P over itself to swallow half of them. */
+ memmove (&pv[i], &pv[i/2], (slen - (pv - new)) - (i/2) + 1);
+ p += i/2;
+
+ /* If the backslashes quoted each other; the % was unquoted. */
+ if (i % 2 == 0)
+ break;
+ }
+ }
+
+ /* If we had to change STRING, add it to the strcache. */
+ if (new)
+ {
+ *string = strcache_add (*string);
+ if (p)
+ p = *string + (p - new);
+ free (new);
+ }
+
+ /* If we didn't find a %, return NULL. Otherwise return a ptr to it. */
+ return p;
+}
+
+/* Find the next line of text in an eval buffer, combining continuation lines
+ into one line.
+ Return the number of actual lines read (> 1 if continuation lines).
+ Returns -1 if there's nothing left in the buffer.
+
+ After this function, ebuf->buffer points to the first character of the
+ line we just found.
+ */
+
+/* Read a line of text from a STRING.
+ Since we aren't really reading from a file, don't bother with linenumbers.
+ */
+
+static long
+readstring (struct ebuffer *ebuf)
+{
+ char *eol;
+
+ /* If there is nothing left in this buffer, return 0. */
+ if (ebuf->bufnext >= ebuf->bufstart + ebuf->size)
+ return -1;
+
+ /* Set up a new starting point for the buffer, and find the end of the
+ next logical line (taking into account backslash/newline pairs). */
+
+ eol = ebuf->buffer = ebuf->bufnext;
+
+ while (1)
+ {
+ int backslash = 0;
+ const char *bol = eol;
+ const char *p;
+
+ /* Find the next newline. At EOS, stop. */
+ p = eol = strchr (eol , '\n');
+ if (!eol)
+ {
+ ebuf->bufnext = ebuf->bufstart + ebuf->size + 1;
+ return 0;
+ }
+
+ /* Found a newline; if it's escaped continue; else we're done. */
+ while (p > bol && *(--p) == '\\')
+ backslash = !backslash;
+ if (!backslash)
+ break;
+ ++eol;
+ }
+
+ /* Overwrite the newline char. */
+ *eol = '\0';
+ ebuf->bufnext = eol+1;
+
+ return 0;
+}
+
+static long
+readline (struct ebuffer *ebuf)
+{
+ char *p;
+ char *end;
+ char *start;
+ long nlines = 0;
+
+ /* The behaviors between string and stream buffers are different enough to
+ warrant different functions. Do the Right Thing. */
+
+ if (!ebuf->fp)
+ return readstring (ebuf);
+
+ /* When reading from a file, we always start over at the beginning of the
+ buffer for each new line. */
+
+ p = start = ebuf->bufstart;
+ end = p + ebuf->size;
+ *p = '\0';
+
+ while (fgets (p, (int) (end - p), ebuf->fp) != 0)
+ {
+ char *p2;
+ size_t len;
+ int backslash;
+
+ len = strlen (p);
+ if (len == 0)
+ {
+ /* This only happens when the first thing on the line is a '\0'.
+ It is a pretty hopeless case, but (wonder of wonders) Athena
+ lossage strikes again! (xmkmf puts NULs in its makefiles.)
+ There is nothing really to be done; we synthesize a newline so
+ the following line doesn't appear to be part of this line. */
+ O (error, &ebuf->floc,
+ _("warning: NUL character seen; rest of line ignored"));
+ p[0] = '\n';
+ len = 1;
+ }
+
+ /* Jump past the text we just read. */
+ p += len;
+
+ /* If the last char isn't a newline, the whole line didn't fit into the
+ buffer. Get some more buffer and try again. */
+ if (p[-1] != '\n')
+ goto more_buffer;
+
+ /* We got a newline, so add one to the count of lines. */
+ ++nlines;
+
+#if !defined(WINDOWS32) && !defined(__MSDOS__) && !defined(__EMX__)
+ /* Check to see if the line was really ended with CRLF; if so ignore
+ the CR. */
+ if ((p - start) > 1 && p[-2] == '\r')
+ {
+ --p;
+ memmove (p-1, p, strlen (p) + 1);
+ }
+#endif
+
+ backslash = 0;
+ for (p2 = p - 2; p2 >= start; --p2)
+ {
+ if (*p2 != '\\')
+ break;
+ backslash = !backslash;
+ }
+
+ if (!backslash)
+ {
+ p[-1] = '\0';
+ break;
+ }
+
+ /* It was a backslash/newline combo. If we have more space, read
+ another line. */
+ if (end - p >= 80)
+ continue;
+
+ /* We need more space at the end of our buffer, so realloc it.
+ Make sure to preserve the current offset of p. */
+ more_buffer:
+ {
+ size_t off = p - start;
+ ebuf->size *= 2;
+ start = ebuf->buffer = ebuf->bufstart = xrealloc (start, ebuf->size);
+ p = start + off;
+ end = start + ebuf->size;
+ *p = '\0';
+ }
+ }
+
+ if (ferror (ebuf->fp))
+ pfatal_with_name (ebuf->floc.filenm);
+
+ /* If we found some lines, return how many.
+ If we didn't, but we did find _something_, that indicates we read the last
+ line of a file with no final newline; return 1.
+ If we read nothing, we're at EOF; return -1. */
+
+ return nlines ? nlines : p == ebuf->bufstart ? -1 : 1;
+}
+
+/* Parse the next "makefile word" from the input buffer, and return info
+ about it.
+
+ A "makefile word" is one of:
+
+ w_bogus Should never happen
+ w_eol End of input
+ w_static A static word; cannot be expanded
+ w_variable A word containing one or more variables/functions
+ w_colon A colon
+ w_dcolon A double-colon
+ w_ampcolon An ampersand-colon (&:) token
+ w_ampdcolon An ampersand-double-colon (&::) token
+ w_semicolon A semicolon
+ w_varassign A variable assignment operator (=, :=, ::=, +=, ?=, or !=)
+
+ Note that this function is only used when reading certain parts of the
+ makefile. Don't use it where special rules hold sway (RHS of a variable,
+ in a command list, etc.) */
+
+static enum make_word_type
+get_next_mword (char *buffer, char **startp, size_t *length)
+{
+ enum make_word_type wtype;
+ char *p = buffer, *beg;
+ char c;
+
+ /* Skip any leading whitespace. */
+ while (ISSPACE (*p))
+ ++p;
+
+ beg = p;
+ c = *(p++);
+
+ /* Look at the start of the word to see if it's simple. */
+ switch (c)
+ {
+ case '\0':
+ wtype = w_eol;
+ goto done;
+
+ case ';':
+ wtype = w_semicolon;
+ goto done;
+
+ case '=':
+ wtype = w_varassign;
+ goto done;
+
+ case ':':
+ if (*p == '=')
+ {
+ ++p;
+ wtype = w_varassign; /* := */
+ }
+ else if (*p == ':')
+ {
+ ++p;
+ if (p[1] == '=')
+ {
+ ++p;
+ wtype = w_varassign; /* ::= */
+ }
+ else
+ wtype = w_dcolon;
+ }
+ else
+ wtype = w_colon;
+ goto done;
+
+ case '&':
+ if (*p == ':')
+ {
+ ++p;
+ if (*p != ':')
+ wtype = w_ampcolon; /* &: */
+ else
+ {
+ ++p;
+ wtype = w_ampdcolon; /* &:: */
+ }
+ goto done;
+ }
+ break;
+
+ case '+':
+ case '?':
+ case '!':
+ if (*p == '=')
+ {
+ ++p;
+ wtype = w_varassign; /* += or ?= or != */
+ goto done;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ /* This is some non-operator word. A word consists of the longest
+ string of characters that doesn't contain whitespace, one of [:=#],
+ or [?+!]=, or &:. */
+
+ /* We start out assuming a static word; if we see a variable we'll
+ adjust our assumptions then. */
+ wtype = w_static;
+
+ /* We already found the first value of "c", above. */
+ while (1)
+ {
+ char closeparen;
+ int count;
+
+ if (END_OF_TOKEN (c))
+ goto done_word;
+
+ switch (c)
+ {
+ case '=':
+ goto done_word;
+
+ case ':':
+#ifdef HAVE_DOS_PATHS
+ /* A word CAN include a colon in its drive spec. The drive
+ spec is allowed either at the beginning of a word, or as part
+ of the archive member name, like in "libfoo.a(d:/foo/bar.o)". */
+ if ((p - beg == 2 || (p - beg > 2 && p[-3] == '('))
+ && isalpha ((unsigned char)p[-2]))
+ break;
+#endif
+ goto done_word;
+
+ case '$':
+ c = *(p++);
+ if (c == '$')
+ break;
+ if (c == '\0')
+ goto done_word;
+
+ /* This is a variable reference, so note that it's expandable.
+ Then read it to the matching close paren. */
+ wtype = w_variable;
+
+ if (c == '(')
+ closeparen = ')';
+ else if (c == '{')
+ closeparen = '}';
+ else
+ /* This is a single-letter variable reference. */
+ break;
+
+ for (count=0; *p != '\0'; ++p)
+ {
+ if (*p == c)
+ ++count;
+ else if (*p == closeparen && --count < 0)
+ {
+ ++p;
+ break;
+ }
+ }
+ break;
+
+ case '?':
+ case '+':
+ if (*p == '=')
+ goto done_word;
+ break;
+
+ case '\\':
+ switch (*p)
+ {
+ case ':':
+ case ';':
+ case '=':
+ case '\\':
+ ++p;
+ break;
+ }
+ break;
+
+ case '&':
+ if (*p == ':')
+ goto done_word;
+ break;
+
+ default:
+ break;
+ }
+
+ c = *(p++);
+ }
+ done_word:
+ --p;
+
+ done:
+ if (startp)
+ *startp = beg;
+ if (length)
+ *length = p - beg;
+ return wtype;
+}
+
+/* Construct the list of include directories
+ from the arguments and the default list. */
+
+void
+construct_include_path (const char **arg_dirs)
+{
+#ifdef VAXC /* just don't ask ... */
+ stat_t stbuf;
+#else
+ struct stat stbuf;
+#endif
+ const char **dirs;
+ const char **cpp;
+ size_t idx;
+
+ /* Compute the number of pointers we need in the table. */
+ idx = sizeof (default_include_directories) / sizeof (const char *);
+ if (arg_dirs)
+ for (cpp = arg_dirs; *cpp != 0; ++cpp)
+ ++idx;
+
+#ifdef __MSDOS__
+ /* Add one for $DJDIR. */
+ ++idx;
+#endif
+
+ dirs = xmalloc (idx * sizeof (const char *));
+
+ idx = 0;
+ max_incl_len = 0;
+
+ /* First consider any dirs specified with -I switches.
+ Ignore any that don't exist. Remember the maximum string length. */
+
+ if (arg_dirs)
+ while (*arg_dirs != 0)
+ {
+ const char *dir = *(arg_dirs++);
+ char *expanded = 0;
+ int e;
+
+ if (dir[0] == '~')
+ {
+ expanded = tilde_expand (dir);
+ if (expanded != 0)
+ dir = expanded;
+ }
+
+ EINTRLOOP (e, stat (dir, &stbuf));
+ if (e == 0 && S_ISDIR (stbuf.st_mode))
+ {
+ size_t len = strlen (dir);
+ /* If dir name is written with trailing slashes, discard them. */
+ while (len > 1 && dir[len - 1] == '/')
+ --len;
+ if (len > max_incl_len)
+ max_incl_len = len;
+ dirs[idx++] = strcache_add_len (dir, len);
+ }
+
+ free (expanded);
+ }
+
+ /* Now add the standard default dirs at the end. */
+
+#ifdef __MSDOS__
+ {
+ /* The environment variable $DJDIR holds the root of the DJGPP directory
+ tree; add ${DJDIR}/include. */
+ struct variable *djdir = lookup_variable ("DJDIR", 5);
+
+ if (djdir)
+ {
+ size_t len = strlen (djdir->value) + 8;
+ char *defdir = alloca (len + 1);
+
+ strcat (strcpy (defdir, djdir->value), "/include");
+ dirs[idx++] = strcache_add (defdir);
+
+ if (len > max_incl_len)
+ max_incl_len = len;
+ }
+ }
+#endif
+
+ for (cpp = default_include_directories; *cpp != 0; ++cpp)
+ {
+ int e;
+
+ EINTRLOOP (e, stat (*cpp, &stbuf));
+ if (e == 0 && S_ISDIR (stbuf.st_mode))
+ {
+ size_t len = strlen (*cpp);
+ /* If dir name is written with trailing slashes, discard them. */
+ while (len > 1 && (*cpp)[len - 1] == '/')
+ --len;
+ if (len > max_incl_len)
+ max_incl_len = len;
+ dirs[idx++] = strcache_add_len (*cpp, len);
+ }
+ }
+
+ dirs[idx] = 0;
+
+ /* Now add each dir to the .INCLUDE_DIRS variable. */
+
+ for (cpp = dirs; *cpp != 0; ++cpp)
+ do_variable_definition (NILF, ".INCLUDE_DIRS", *cpp,
+ o_default, f_append, 0);
+
+ include_directories = dirs;
+}
+
+/* Expand ~ or ~USER at the beginning of NAME.
+ Return a newly malloc'd string or 0. */
+
+char *
+tilde_expand (const char *name)
+{
+#ifndef VMS
+ if (name[1] == '/' || name[1] == '\0')
+ {
+ char *home_dir;
+ int is_variable;
+
+ {
+ /* Turn off --warn-undefined-variables while we expand HOME. */
+ int save = warn_undefined_variables_flag;
+ warn_undefined_variables_flag = 0;
+
+ home_dir = allocated_variable_expand ("$(HOME)");
+
+ warn_undefined_variables_flag = save;
+ }
+
+ is_variable = home_dir[0] != '\0';
+ if (!is_variable)
+ {
+ free (home_dir);
+ home_dir = getenv ("HOME");
+ }
+# if !defined(_AMIGA) && !defined(WINDOWS32)
+ if (home_dir == 0 || home_dir[0] == '\0')
+ {
+ char *logname = getlogin ();
+ home_dir = 0;
+ if (logname != 0)
+ {
+ struct passwd *p = getpwnam (logname);
+ if (p != 0)
+ home_dir = p->pw_dir;
+ }
+ }
+# endif /* !AMIGA && !WINDOWS32 */
+ if (home_dir != 0)
+ {
+ char *new = xstrdup (concat (2, home_dir, name + 1));
+ if (is_variable)
+ free (home_dir);
+ return new;
+ }
+ }
+# if !defined(_AMIGA) && !defined(WINDOWS32)
+ else
+ {
+ struct passwd *pwent;
+ char *userend = strchr (name + 1, '/');
+ if (userend != 0)
+ *userend = '\0';
+ pwent = getpwnam (name + 1);
+ if (pwent != 0)
+ {
+ if (userend == 0)
+ return xstrdup (pwent->pw_dir);
+ else
+ return xstrdup (concat (3, pwent->pw_dir, "/", userend + 1));
+ }
+ else if (userend != 0)
+ *userend = '/';
+ }
+# endif /* !AMIGA && !WINDOWS32 */
+#endif /* !VMS */
+ return 0;
+}
+
+/* Parse a string into a sequence of filenames represented as a chain of
+ struct nameseq's and return that chain. Optionally expand the strings via
+ glob().
+
+ The string is passed as STRINGP, the address of a string pointer.
+ The string pointer is updated to point at the first character
+ not parsed, which either is a null char or equals STOPMAP.
+
+ SIZE is how large (in bytes) each element in the new chain should be.
+ This is useful if we want them actually to be other structures
+ that have room for additional info.
+
+ STOPMAP is a map of characters that tell us to stop parsing.
+
+ PREFIX, if non-null, is added to the beginning of each filename.
+
+ FLAGS allows one or more of the following bitflags to be set:
+ PARSEFS_NOSTRIP - Do no strip './'s off the beginning
+ PARSEFS_NOAR - Do not check filenames for archive references
+ PARSEFS_NOGLOB - Do not expand globbing characters
+ PARSEFS_EXISTS - Only return globbed files that actually exist
+ (cannot also set NOGLOB)
+ PARSEFS_NOCACHE - Do not add filenames to the strcache (caller frees)
+ */
+
+void *
+parse_file_seq (char **stringp, size_t size, int stopmap,
+ const char *prefix, int flags)
+{
+ /* tmp points to tmpbuf after the prefix, if any.
+ tp is the end of the buffer. */
+ static char *tmpbuf = NULL;
+
+ int cachep = NONE_SET (flags, PARSEFS_NOCACHE);
+
+ struct nameseq *new = 0;
+ struct nameseq **newp = &new;
+#define NEWELT(_n) do { \
+ const char *__n = (_n); \
+ *newp = xcalloc (size); \
+ (*newp)->name = (cachep ? strcache_add (__n) : xstrdup (__n)); \
+ newp = &(*newp)->next; \
+ } while(0)
+
+ char *p;
+ glob_t gl;
+ char *tp;
+ int findmap = stopmap|MAP_VMSCOMMA|MAP_NUL;
+
+ if (NONE_SET (flags, PARSEFS_ONEWORD))
+ findmap |= MAP_BLANK;
+
+ /* Always stop on NUL. */
+ stopmap |= MAP_NUL;
+
+ if (size < sizeof (struct nameseq))
+ size = sizeof (struct nameseq);
+
+ if (NONE_SET (flags, PARSEFS_NOGLOB))
+ dir_setup_glob (&gl);
+
+ /* Get enough temporary space to construct the largest possible target. */
+ {
+ static size_t tmpbuf_len = 0;
+ size_t l = strlen (*stringp) + 1;
+ if (l > tmpbuf_len)
+ {
+ tmpbuf = xrealloc (tmpbuf, l);
+ tmpbuf_len = l;
+ }
+ }
+ tp = tmpbuf;
+
+ /* Parse STRING. P will always point to the end of the parsed content. */
+ p = *stringp;
+ while (1)
+ {
+ const char *name;
+ const char **nlist = 0;
+ char *tildep = 0;
+ int globme = 1;
+#ifndef NO_ARCHIVES
+ char *arname = 0;
+ char *memname = 0;
+#endif
+ char *s;
+ size_t nlen;
+ int tot, i;
+
+ /* Skip whitespace; at the end of the string or STOPCHAR we're done. */
+ NEXT_TOKEN (p);
+ if (STOP_SET (*p, stopmap))
+ break;
+
+ /* There are names left, so find the end of the next name.
+ Throughout this iteration S points to the start. */
+ s = p;
+ p = find_map_unquote (p, findmap);
+
+#ifdef VMS
+ /* convert comma separated list to space separated */
+ if (p && *p == ',')
+ *p =' ';
+#endif
+#ifdef _AMIGA
+ /* If we stopped due to a device name, skip it. */
+ if (p && p != s+1 && p[0] == ':')
+ p = find_map_unquote (p+1, findmap);
+#endif
+#ifdef HAVE_DOS_PATHS
+ /* If we stopped due to a drive specifier, skip it.
+ Tokens separated by spaces are treated as separate paths since make
+ doesn't allow path names with spaces. */
+ if (p && p == s+1 && p[0] == ':'
+ && isalpha ((unsigned char)s[0]) && STOP_SET (p[1], MAP_DIRSEP))
+ p = find_map_unquote (p+1, findmap);
+#endif
+
+ if (!p)
+ p = s + strlen (s);
+
+ /* Strip leading "this directory" references. */
+ if (NONE_SET (flags, PARSEFS_NOSTRIP))
+#ifdef VMS
+ /* Skip leading '[]'s. should only be one set or bug somewhere else */
+ if (p - s > 2 && s[0] == '[' && s[1] == ']')
+ s += 2;
+ /* Skip leading '<>'s. should only be one set or bug somewhere else */
+ if (p - s > 2 && s[0] == '<' && s[1] == '>')
+ s += 2;
+#endif
+ /* Skip leading './'s. */
+ while (p - s > 2 && s[0] == '.' && s[1] == '/')
+ {
+ /* Skip "./" and all following slashes. */
+ s += 2;
+ while (*s == '/')
+ ++s;
+ }
+
+ /* Extract the filename just found, and skip it.
+ Set NAME to the string, and NLEN to its length. */
+
+ if (s == p)
+ {
+ /* The name was stripped to empty ("./"). */
+#if defined(_AMIGA)
+ /* PDS-- This cannot be right!! */
+ tp[0] = '\0';
+ nlen = 0;
+#else
+ tp[0] = '.';
+ tp[1] = '/';
+ tp[2] = '\0';
+ nlen = 2;
+#endif
+ }
+ else
+ {
+#ifdef VMS
+/* VMS filenames can have a ':' in them but they have to be '\'ed but we need
+ * to remove this '\' before we can use the filename.
+ * xstrdup called because S may be read-only string constant.
+ */
+ char *n = tp;
+ while (s < p)
+ {
+ if (s[0] == '\\' && s[1] == ':')
+ ++s;
+ *(n++) = *(s++);
+ }
+ n[0] = '\0';
+ nlen = strlen (tp);
+#else
+ nlen = p - s;
+ memcpy (tp, s, nlen);
+ tp[nlen] = '\0';
+#endif
+ }
+
+ /* At this point, TP points to the element and NLEN is its length. */
+
+#ifndef NO_ARCHIVES
+ /* If this is the start of an archive group that isn't complete, set up
+ to add the archive prefix for future files. A file list like:
+ "libf.a(x.o y.o z.o)" needs to be expanded as:
+ "libf.a(x.o) libf.a(y.o) libf.a(z.o)"
+
+ TP == TMP means we're not already in an archive group. Ignore
+ something starting with '(', as that cannot actually be an
+ archive-member reference (and treating it as such results in an empty
+ file name, which causes much lossage). Also if it ends in ")" then
+ it's a complete reference so we don't need to treat it specially.
+
+ Finally, note that archive groups must end with ')' as the last
+ character, so ensure there's some word ending like that before
+ considering this an archive group. */
+ if (NONE_SET (flags, PARSEFS_NOAR)
+ && tp == tmpbuf && tp[0] != '(' && tp[nlen-1] != ')')
+ {
+ char *n = strchr (tp, '(');
+ if (n)
+ {
+ /* This looks like the first element in an open archive group.
+ A valid group MUST have ')' as the last character. */
+ const char *e = p;
+ do
+ {
+ const char *o = e;
+ NEXT_TOKEN (e);
+ /* Find the end of this word. We don't want to unquote and
+ we don't care about quoting since we're looking for the
+ last char in the word. */
+ while (! STOP_SET (*e, findmap))
+ ++e;
+ /* If we didn't move, we're done now. */
+ if (e == o)
+ break;
+ if (e[-1] == ')')
+ {
+ /* Found the end, so this is the first element in an
+ open archive group. It looks like "lib(mem".
+ Reset TP past the open paren. */
+ nlen -= (n + 1) - tp;
+ tp = n + 1;
+
+ /* We can stop looking now. */
+ break;
+ }
+ }
+ while (*e != '\0');
+
+ /* If we have just "lib(", part of something like "lib( a b)",
+ go to the next item. */
+ if (! nlen)
+ continue;
+ }
+ }
+
+ /* If we are inside an archive group, make sure it has an end. */
+ if (tp > tmpbuf)
+ {
+ if (tp[nlen-1] == ')')
+ {
+ /* This is the natural end; reset TP. */
+ tp = tmpbuf;
+
+ /* This is just ")", something like "lib(a b )": skip it. */
+ if (nlen == 1)
+ continue;
+ }
+ else
+ {
+ /* Not the end, so add a "fake" end. */
+ tp[nlen++] = ')';
+ tp[nlen] = '\0';
+ }
+ }
+#endif
+
+ /* If we're not globbing we're done: add it to the end of the chain.
+ Go to the next item in the string. */
+ if (ANY_SET (flags, PARSEFS_NOGLOB))
+ {
+ NEWELT (concat (2, prefix, tmpbuf));
+ continue;
+ }
+
+ /* If we get here we know we're doing glob expansion.
+ TP is a string in tmpbuf. NLEN is no longer used.
+ We may need to do more work: after this NAME will be set. */
+ name = tmpbuf;
+
+ /* Expand tilde if applicable. */
+ if (tmpbuf[0] == '~')
+ {
+ tildep = tilde_expand (tmpbuf);
+ if (tildep != 0)
+ name = tildep;
+ }
+
+#ifndef NO_ARCHIVES
+ /* If NAME is an archive member reference replace it with the archive
+ file name, and save the member name in MEMNAME. We will glob on the
+ archive name and then reattach MEMNAME later. */
+ if (NONE_SET (flags, PARSEFS_NOAR) && ar_name (name))
+ {
+ ar_parse_name (name, &arname, &memname);
+ name = arname;
+ }
+#endif /* !NO_ARCHIVES */
+
+ /* glob() is expensive: don't call it unless we need to. */
+ if (NONE_SET (flags, PARSEFS_EXISTS) && strpbrk (name, "?*[") == NULL)
+ {
+ globme = 0;
+ tot = 1;
+ nlist = &name;
+ }
+ else
+ switch (glob (name, GLOB_ALTDIRFUNC, NULL, &gl))
+ {
+ case GLOB_NOSPACE:
+ out_of_memory ();
+
+ case 0:
+ /* Success. */
+ tot = gl.gl_pathc;
+ nlist = (const char **)gl.gl_pathv;
+ break;
+
+ case GLOB_NOMATCH:
+ /* If we want only existing items, skip this one. */
+ if (ANY_SET (flags, PARSEFS_EXISTS))
+ {
+ tot = 0;
+ break;
+ }
+ /* FALLTHROUGH */
+
+ default:
+ /* By default keep this name. */
+ tot = 1;
+ nlist = &name;
+ break;
+ }
+
+ /* For each matched element, add it to the list. */
+ for (i = 0; i < tot; ++i)
+#ifndef NO_ARCHIVES
+ if (memname != 0)
+ {
+ /* Try to glob on MEMNAME within the archive. */
+ struct nameseq *found = ar_glob (nlist[i], memname, size);
+ if (! found)
+ /* No matches. Use MEMNAME as-is. */
+ NEWELT (concat (5, prefix, nlist[i], "(", memname, ")"));
+ else
+ {
+ /* We got a chain of items. Attach them. */
+ if (*newp)
+ (*newp)->next = found;
+ else
+ *newp = found;
+
+ /* Find and set the new end. Massage names if necessary. */
+ while (1)
+ {
+ if (! cachep)
+ found->name = xstrdup (concat (2, prefix, name));
+ else if (prefix)
+ found->name = strcache_add (concat (2, prefix, name));
+
+ if (found->next == 0)
+ break;
+
+ found = found->next;
+ }
+ newp = &found->next;
+ }
+ }
+ else
+#endif /* !NO_ARCHIVES */
+ NEWELT (concat (2, prefix, nlist[i]));
+
+ if (globme)
+ globfree (&gl);
+
+#ifndef NO_ARCHIVES
+ free (arname);
+#endif
+
+ free (tildep);
+ }
+
+ *stringp = p;
+ return new;
+}
Index: create-4.3.1-alloca-patch/make-4.3.1-new/src
===================================================================
--- create-4.3.1-alloca-patch/make-4.3.1-new/src (nonexistent)
+++ create-4.3.1-alloca-patch/make-4.3.1-new/src (revision 5)
Property changes on: create-4.3.1-alloca-patch/make-4.3.1-new/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-4.3.1-alloca-patch/make-4.3.1-new
===================================================================
--- create-4.3.1-alloca-patch/make-4.3.1-new (nonexistent)
+++ create-4.3.1-alloca-patch/make-4.3.1-new (revision 5)
Property changes on: create-4.3.1-alloca-patch/make-4.3.1-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-4.3.1-alloca-patch
===================================================================
--- create-4.3.1-alloca-patch (nonexistent)
+++ create-4.3.1-alloca-patch (revision 5)
Property changes on: create-4.3.1-alloca-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-4.3.1-getcwd-patch/create.patch.sh
===================================================================
--- create-4.3.1-getcwd-patch/create.patch.sh (nonexistent)
+++ create-4.3.1-getcwd-patch/create.patch.sh (revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=4.3.1
+
+tar --files-from=file.list -xJvf ../make-$VERSION.tar.xz
+mv make-$VERSION make-$VERSION-orig
+
+cp -rf ./make-$VERSION-new ./make-$VERSION
+
+diff --unified -Nr make-$VERSION-orig make-$VERSION > make-$VERSION-getcwd.patch
+
+mv make-$VERSION-getcwd.patch ../patches
+
+rm -rf ./make-$VERSION
+rm -rf ./make-$VERSION-orig
Property changes on: create-4.3.1-getcwd-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-4.3.1-getcwd-patch/file.list
===================================================================
--- create-4.3.1-getcwd-patch/file.list (nonexistent)
+++ create-4.3.1-getcwd-patch/file.list (revision 5)
@@ -0,0 +1 @@
+make-4.3.1/src/makeint.h
Index: create-4.3.1-getcwd-patch/make-4.3.1-new/src/makeint.h
===================================================================
--- create-4.3.1-getcwd-patch/make-4.3.1-new/src/makeint.h (nonexistent)
+++ create-4.3.1-getcwd-patch/make-4.3.1-new/src/makeint.h (revision 5)
@@ -0,0 +1,824 @@
+/* Miscellaneous global declarations and portability cruft for GNU Make.
+Copyright (C) 1988-2020 Free Software Foundation, Inc.
+This file is part of GNU Make.
+
+GNU Make is free software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation; either version 3 of the License, or (at your option) any later
+version.
+
+GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* We use <config.h> instead of "config.h" so that a compilation
+ using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
+ (which it would do because makeint.h was found in $srcdir). */
+#include <config.h>
+#undef HAVE_CONFIG_H
+#define HAVE_CONFIG_H 1
+
+/* Specify we want GNU source code. This must be defined before any
+ system headers are included. */
+
+#define _GNU_SOURCE 1
+
+/* AIX requires this to be the first thing in the file. */
+#if HAVE_ALLOCA_H
+# include <alloca.h>
+#else
+# ifdef _AIX
+ #pragma alloca
+# else
+# if !defined(__GNUC__) && !defined(WINDOWS32)
+# ifndef alloca /* predefined by HP cc +Olibcalls */
+char *alloca ();
+# endif
+# endif
+# endif
+#endif
+
+/* Some versions of GCC (e.g., 10.x) set the warn_unused_result attribute on
+ __builtin_alloca. This causes alloca(0) to fail and is not easily worked
+ around so avoid it via the preprocessor.
+ See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98055 */
+
+#if defined (__has_builtin)
+# if __has_builtin (__builtin_alloca)
+# define free_alloca()
+# else
+# define free_alloca() alloca (0)
+# endif
+#else
+# define free_alloca() alloca (0)
+#endif
+
+/* Disable assert() unless we're a maintainer.
+ Some asserts are compute-intensive. */
+#ifndef MAKE_MAINTAINER_MODE
+# define NDEBUG 1
+#endif
+
+/* Include the externally-visible content.
+ Be sure to use the local one, and not one installed on the system.
+ Define GMK_BUILDING_MAKE for proper selection of dllexport/dllimport
+ declarations for MS-Windows. */
+#ifdef WINDOWS32
+# define GMK_BUILDING_MAKE
+#endif
+#include "gnumake.h"
+
+#ifdef CRAY
+/* This must happen before #include <signal.h> so
+ that the declaration therein is changed. */
+# define signal bsdsignal
+#endif
+
+/* If we're compiling for the dmalloc debugger, turn off string inlining. */
+#if defined(HAVE_DMALLOC_H) && defined(__GNUC__)
+# define __NO_STRING_INLINES
+#endif
+
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef HAVE_SYS_TIMEB_H
+/* SCO 3.2 "devsys 4.2" has a prototype for 'ftime' in <time.h> that bombs
+ unless <sys/timeb.h> has been included first. */
+# include <sys/timeb.h>
+#endif
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+#include <errno.h>
+
+#ifndef errno
+extern int errno;
+#endif
+
+#ifdef __VMS
+/* In strict ANSI mode, VMS compilers should not be defining the
+ VMS macro. Define it here instead of a bulk edit for the correct code.
+ */
+# ifndef VMS
+# define VMS
+# endif
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+/* Ultrix's unistd.h always defines _POSIX_VERSION, but you only get
+ POSIX.1 behavior with 'cc -YPOSIX', which predefines POSIX itself! */
+# if defined (_POSIX_VERSION) && !defined (ultrix) && !defined (VMS)
+# define POSIX 1
+# endif
+#endif
+
+/* Some systems define _POSIX_VERSION but are not really POSIX.1. */
+#if (defined (butterfly) || (defined (__mips) && defined (_SYSTYPE_SVR3)) || (defined (sequent) && defined (i386)))
+# undef POSIX
+#endif
+
+#if !defined (POSIX) && defined (_AIX) && defined (_POSIX_SOURCE)
+# define POSIX 1
+#endif
+
+#ifndef RETSIGTYPE
+# define RETSIGTYPE void
+#endif
+
+#ifndef sigmask
+# define sigmask(sig) (1 << ((sig) - 1))
+#endif
+
+#ifndef HAVE_SA_RESTART
+# define SA_RESTART 0
+#endif
+
+#ifdef HAVE_VFORK_H
+# include <vfork.h>
+#endif
+
+#ifdef HAVE_LIMITS_H
+# include <limits.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#ifndef PATH_MAX
+# ifndef POSIX
+# define PATH_MAX MAXPATHLEN
+# endif
+#endif
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 1024
+#endif
+
+#ifdef PATH_MAX
+# define GET_PATH_MAX PATH_MAX
+# define PATH_VAR(var) char var[PATH_MAX+1]
+#else
+# define NEED_GET_PATH_MAX 1
+# define GET_PATH_MAX (get_path_max ())
+# define PATH_VAR(var) char *var = alloca (GET_PATH_MAX+1)
+unsigned int get_path_max (void);
+#endif
+
+#ifndef CHAR_BIT
+# define CHAR_BIT 8
+#endif
+
+#ifndef USHRT_MAX
+# define USHRT_MAX 65535
+#endif
+
+/* Nonzero if the integer type T is signed.
+ Use <= to avoid GCC warnings about always-false expressions. */
+#define INTEGER_TYPE_SIGNED(t) ((t) -1 <= 0)
+
+/* The minimum and maximum values for the integer type T.
+ Use ~ (t) 0, not -1, for portability to 1's complement hosts. */
+#define INTEGER_TYPE_MINIMUM(t) \
+ (! INTEGER_TYPE_SIGNED (t) ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))
+#define INTEGER_TYPE_MAXIMUM(t) (~ (t) 0 - INTEGER_TYPE_MINIMUM (t))
+
+#ifndef CHAR_MAX
+# define CHAR_MAX INTEGER_TYPE_MAXIMUM (char)
+#endif
+
+#ifdef STAT_MACROS_BROKEN
+# ifdef S_ISREG
+# undef S_ISREG
+# endif
+# ifdef S_ISDIR
+# undef S_ISDIR
+# endif
+#endif /* STAT_MACROS_BROKEN. */
+
+#ifndef S_ISREG
+# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#endif
+#ifndef S_ISDIR
+# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#endif
+
+#ifdef VMS
+# include <fcntl.h>
+# include <types.h>
+# include <unixlib.h>
+# include <unixio.h>
+# include <perror.h>
+/* Needed to use alloca on VMS. */
+# include <builtins.h>
+
+extern int vms_use_mcr_command;
+extern int vms_always_use_cmd_file;
+extern int vms_gnv_shell;
+extern int vms_comma_separator;
+extern int vms_legacy_behavior;
+extern int vms_unix_simulation;
+#endif
+
+#if !defined(__attribute__) && (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__)
+/* Don't use __attribute__ if it's not supported. */
+# define ATTRIBUTE(x)
+#else
+# define ATTRIBUTE(x) __attribute__ (x)
+#endif
+
+/* The __-protected variants of 'format' and 'printf' attributes
+ are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+# define __format__ format
+# define __printf__ printf
+#endif
+
+#define UNUSED ATTRIBUTE ((unused))
+#define NORETURN ATTRIBUTE ((noreturn))
+
+#if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
+# include <stdlib.h>
+# include <string.h>
+# define ANSI_STRING 1
+#else /* No standard headers. */
+# ifdef HAVE_STRING_H
+# include <string.h>
+# define ANSI_STRING 1
+# else
+# include <strings.h>
+# endif
+# ifdef HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# else
+void *malloc (int);
+void *realloc (void *, int);
+void free (void *);
+
+void abort (void) NORETURN;
+void exit (int) NORETURN;
+# endif /* HAVE_STDLIB_H. */
+
+#endif /* Standard headers. */
+
+/* These should be in stdlib.h. Make sure we have them. */
+#ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+# define EXIT_FAILURE 1
+#endif
+
+#ifndef ANSI_STRING
+
+/* SCO Xenix has a buggy macro definition in <string.h>. */
+#undef strerror
+#if !defined(__DECC)
+char *strerror (int errnum);
+#endif
+
+#endif /* !ANSI_STRING. */
+#undef ANSI_STRING
+
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#define FILE_TIMESTAMP uintmax_t
+
+#if !defined(HAVE_STRSIGNAL)
+char *strsignal (int signum);
+#endif
+
+#if !defined(HAVE_UMASK)
+typedef int mode_t;
+extern mode_t umask (mode_t);
+#endif
+
+/* ISDIGIT offers the following features:
+ - Its arg may be any int or unsigned int; it need not be an unsigned char.
+ - It's guaranteed to evaluate its argument exactly once.
+ NOTE! Make relies on this behavior, don't change it!
+ - It's typically faster.
+ POSIX 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
+ only '0' through '9' are digits. Prefer ISDIGIT to isdigit() unless
+ it's important to use the locale's definition of 'digit' even when the
+ host does not conform to POSIX. */
+#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
+
+/* Test if two strings are equal. Is this worthwhile? Should be profiled. */
+#define streq(a, b) \
+ ((a) == (b) || \
+ (*(a) == *(b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))
+
+/* Test if two strings are equal, but match case-insensitively on systems
+ which have case-insensitive filesystems. Should only be used for
+ filenames! */
+#ifdef HAVE_CASE_INSENSITIVE_FS
+# define patheq(a, b) \
+ ((a) == (b) \
+ || (tolower((unsigned char)*(a)) == tolower((unsigned char)*(b)) \
+ && (*(a) == '\0' || !strcasecmp ((a) + 1, (b) + 1))))
+#else
+# define patheq(a, b) streq(a, b)
+#endif
+
+#define strneq(a, b, l) (strncmp ((a), (b), (l)) == 0)
+
+#if defined(ENUM_BITFIELDS) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
+# define ENUM_BITFIELD(bits) :bits
+#else
+# define ENUM_BITFIELD(bits)
+#endif
+
+/* Handle gettext and locales. */
+
+#if HAVE_LOCALE_H
+# include <locale.h>
+#else
+# define setlocale(category, locale)
+#endif
+
+#include <gettext.h>
+
+#define _(msgid) gettext (msgid)
+#define N_(msgid) gettext_noop (msgid)
+#define S_(msg1,msg2,num) ngettext (msg1,msg2,num)
+
+/* This is needed for getcwd() and chdir(), on some W32 systems. */
+#if defined(HAVE_DIRECT_H)
+# include <direct.h>
+#endif
+
+#ifdef WINDOWS32
+# include <fcntl.h>
+# include <malloc.h>
+# define pipe(_p) _pipe((_p), 512, O_BINARY)
+# define kill(_pid,_sig) w32_kill((_pid),(_sig))
+/* MSVC and Watcom C don't have ftruncate. */
+# if defined(_MSC_VER) || defined(__WATCOMC__)
+# define ftruncate(_fd,_len) _chsize(_fd,_len)
+# endif
+/* MinGW64 doesn't have _S_ISDIR. */
+# ifndef _S_ISDIR
+# define _S_ISDIR(m) S_ISDIR(m)
+# endif
+
+void sync_Path_environment (void);
+int w32_kill (pid_t pid, int sig);
+int find_and_set_default_shell (const char *token);
+
+/* indicates whether or not we have Bourne shell */
+extern int no_default_sh_exe;
+
+/* is default_shell unixy? */
+extern int unixy_shell;
+
+/* We don't have a preferred fixed value for LOCALEDIR. */
+# ifndef LOCALEDIR
+# define LOCALEDIR NULL
+# endif
+
+/* Include only the minimal stuff from windows.h. */
+# define WIN32_LEAN_AND_MEAN
+#endif /* WINDOWS32 */
+
+#define ANY_SET(_v,_m) (((_v)&(_m)) != 0)
+#define NONE_SET(_v,_m) (! ANY_SET ((_v),(_m)))
+
+#define MAP_NUL 0x0001
+#define MAP_BLANK 0x0002
+#define MAP_NEWLINE 0x0004
+#define MAP_COMMENT 0x0008
+#define MAP_SEMI 0x0010
+#define MAP_EQUALS 0x0020
+#define MAP_COLON 0x0040
+#define MAP_VARSEP 0x0080
+#define MAP_PIPE 0x0100
+#define MAP_DOT 0x0200
+#define MAP_COMMA 0x0400
+
+/* These are the valid characters for a user-defined function. */
+#define MAP_USERFUNC 0x2000
+/* This means not only a '$', but skip the variable reference. */
+#define MAP_VARIABLE 0x4000
+/* The set of characters which are directory separators is OS-specific. */
+#define MAP_DIRSEP 0x8000
+
+#ifdef VMS
+# define MAP_VMSCOMMA MAP_COMMA
+#else
+# define MAP_VMSCOMMA 0x0000
+#endif
+
+#define MAP_SPACE (MAP_BLANK|MAP_NEWLINE)
+
+/* Handle other OSs.
+ To overcome an issue parsing paths in a DOS/Windows environment when
+ built in a unix based environment, override the PATH_SEPARATOR_CHAR
+ definition unless being built for Cygwin. */
+#if defined(HAVE_DOS_PATHS) && !defined(__CYGWIN__)
+# undef PATH_SEPARATOR_CHAR
+# define PATH_SEPARATOR_CHAR ';'
+# define MAP_PATHSEP MAP_SEMI
+#elif !defined(PATH_SEPARATOR_CHAR)
+# if defined (VMS)
+# define PATH_SEPARATOR_CHAR (vms_comma_separator ? ',' : ':')
+# define MAP_PATHSEP (vms_comma_separator ? MAP_COMMA : MAP_SEMI)
+# else
+# define PATH_SEPARATOR_CHAR ':'
+# define MAP_PATHSEP MAP_COLON
+# endif
+#elif PATH_SEPARATOR_CHAR == ':'
+# define MAP_PATHSEP MAP_COLON
+#elif PATH_SEPARATOR_CHAR == ';'
+# define MAP_PATHSEP MAP_SEMI
+#elif PATH_SEPARATOR_CHAR == ','
+# define MAP_PATHSEP MAP_COMMA
+#else
+# error "Unknown PATH_SEPARATOR_CHAR"
+#endif
+
+#define STOP_SET(_v,_m) ANY_SET(stopchar_map[(unsigned char)(_v)],(_m))
+
+#define ISBLANK(c) STOP_SET((c),MAP_BLANK)
+#define ISSPACE(c) STOP_SET((c),MAP_SPACE)
+#define END_OF_TOKEN(c) STOP_SET((c),MAP_SPACE|MAP_NUL)
+#define NEXT_TOKEN(s) while (ISSPACE (*(s))) ++(s)
+
+/* We can't run setrlimit when using posix_spawn. */
+#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) && !defined(USE_POSIX_SPAWN)
+# define SET_STACK_SIZE
+#endif
+#ifdef SET_STACK_SIZE
+# include <sys/resource.h>
+extern struct rlimit stack_limit;
+#endif
+
+#include <glob.h>
+
+#define NILF ((floc *)0)
+
+#define CSTRLEN(_s) (sizeof (_s)-1)
+#define STRING_SIZE_TUPLE(_s) (_s), CSTRLEN(_s)
+
+/* The number of bytes needed to represent the largest integer as a string. */
+#define INTSTR_LENGTH CSTRLEN ("18446744073709551616")
+
+#define DEFAULT_TTYNAME "true"
+#ifdef HAVE_TTYNAME
+# define TTYNAME(_f) ttyname (_f)
+#else
+# define TTYNAME(_f) DEFAULT_TTYNAME
+#endif
+
+
+
+/* Specify the location of elements read from makefiles. */
+typedef struct
+ {
+ const char *filenm;
+ unsigned long lineno;
+ unsigned long offset;
+ } floc;
+
+const char *concat (unsigned int, ...);
+void message (int prefix, size_t length, const char *fmt, ...)
+ ATTRIBUTE ((__format__ (__printf__, 3, 4)));
+void error (const floc *flocp, size_t length, const char *fmt, ...)
+ ATTRIBUTE ((__format__ (__printf__, 3, 4)));
+void fatal (const floc *flocp, size_t length, const char *fmt, ...)
+ ATTRIBUTE ((noreturn, __format__ (__printf__, 3, 4)));
+void out_of_memory () NORETURN;
+
+/* When adding macros to this list be sure to update the value of
+ XGETTEXT_OPTIONS in the po/Makevars file. */
+#define O(_t,_a,_f) _t((_a), 0, (_f))
+#define OS(_t,_a,_f,_s) _t((_a), strlen (_s), (_f), (_s))
+#define OSS(_t,_a,_f,_s1,_s2) _t((_a), strlen (_s1) + strlen (_s2), \
+ (_f), (_s1), (_s2))
+#define OSSS(_t,_a,_f,_s1,_s2,_s3) _t((_a), strlen (_s1) + strlen (_s2) + strlen (_s3), \
+ (_f), (_s1), (_s2), (_s3))
+#define ON(_t,_a,_f,_n) _t((_a), INTSTR_LENGTH, (_f), (_n))
+#define ONN(_t,_a,_f,_n1,_n2) _t((_a), INTSTR_LENGTH*2, (_f), (_n1), (_n2))
+
+#define OSN(_t,_a,_f,_s,_n) _t((_a), strlen (_s) + INTSTR_LENGTH, \
+ (_f), (_s), (_n))
+#define ONS(_t,_a,_f,_n,_s) _t((_a), INTSTR_LENGTH + strlen (_s), \
+ (_f), (_n), (_s))
+
+void die (int) NORETURN;
+void pfatal_with_name (const char *) NORETURN;
+void perror_with_name (const char *, const char *);
+#define xstrlen(_s) ((_s)==NULL ? 0 : strlen (_s))
+void *xmalloc (size_t);
+void *xcalloc (size_t);
+void *xrealloc (void *, size_t);
+char *xstrdup (const char *);
+char *xstrndup (const char *, size_t);
+char *find_next_token (const char **, size_t *);
+char *next_token (const char *);
+char *end_of_token (const char *);
+void collapse_continuations (char *);
+char *lindex (const char *, const char *, int);
+int alpha_compare (const void *, const void *);
+void print_spaces (unsigned int);
+char *find_percent (char *);
+const char *find_percent_cached (const char **);
+FILE *get_tmpfile (char **, const char *);
+ssize_t writebuf (int, const void *, size_t);
+ssize_t readbuf (int, void *, size_t);
+
+#ifndef HAVE_MEMRCHR
+void *memrchr(const void *, int, size_t);
+#endif
+
+#ifndef NO_ARCHIVES
+int ar_name (const char *);
+void ar_parse_name (const char *, char **, char **);
+int ar_touch (const char *);
+time_t ar_member_date (const char *);
+
+typedef long int (*ar_member_func_t) (int desc, const char *mem, int truncated,
+ long int hdrpos, long int datapos,
+ long int size, long int date, int uid,
+ int gid, unsigned int mode,
+ const void *arg);
+
+long int ar_scan (const char *archive, ar_member_func_t function, const void *arg);
+int ar_name_equal (const char *name, const char *mem, int truncated);
+#ifndef VMS
+int ar_member_touch (const char *arname, const char *memname);
+#endif
+#endif
+
+int dir_file_exists_p (const char *, const char *);
+int file_exists_p (const char *);
+int file_impossible_p (const char *);
+void file_impossible (const char *);
+const char *dir_name (const char *);
+void print_dir_data_base (void);
+void dir_setup_glob (glob_t *);
+void hash_init_directories (void);
+
+void define_default_variables (void);
+void undefine_default_variables (void);
+void set_default_suffixes (void);
+void install_default_suffix_rules (void);
+void install_default_implicit_rules (void);
+
+void build_vpath_lists (void);
+void construct_vpath_list (char *pattern, char *dirpath);
+const char *vpath_search (const char *file, FILE_TIMESTAMP *mtime_ptr,
+ unsigned int* vpath_index, unsigned int* path_index);
+int gpath_search (const char *file, size_t len);
+
+void construct_include_path (const char **arg_dirs);
+
+void user_access (void);
+void make_access (void);
+void child_access (void);
+
+char *strip_whitespace (const char **begpp, const char **endpp);
+
+void show_goal_error (void);
+
+/* String caching */
+void strcache_init (void);
+void strcache_print_stats (const char *prefix);
+int strcache_iscached (const char *str);
+const char *strcache_add (const char *str);
+const char *strcache_add_len (const char *str, size_t len);
+
+/* Guile support */
+int guile_gmake_setup (const floc *flocp);
+
+/* Loadable object support. Sets to the strcached name of the loaded file. */
+typedef int (*load_func_t)(const floc *flocp);
+int load_file (const floc *flocp, const char **filename, int noerror);
+void unload_file (const char *name);
+
+/* Maintainer mode support */
+#ifdef MAKE_MAINTAINER_MODE
+# define SPIN(_s) spin (_s)
+void spin (const char* suffix);
+#else
+# define SPIN(_s)
+#endif
+
+/* We omit these declarations on non-POSIX systems which define _POSIX_VERSION,
+ because such systems often declare them in header files anyway. */
+
+#if !defined (__GNU_LIBRARY__) && !defined (POSIX) && !defined (_POSIX_VERSION) && !defined(WINDOWS32)
+
+long int atol ();
+# ifndef VMS
+long int lseek ();
+# endif
+
+# ifdef HAVE_GETCWD
+# if !defined(VMS) && !defined(__DECC) && !defined(getcwd)
+char *getcwd ();
+# endif
+# else
+char *getwd ();
+# define getcwd(buf, len) getwd (buf)
+# endif
+
+#endif /* Not GNU C library or POSIX. */
+
+#if !HAVE_STRCASECMP
+# if HAVE_STRICMP
+# define strcasecmp stricmp
+# elif HAVE_STRCMPI
+# define strcasecmp strcmpi
+# else
+/* Create our own, in misc.c */
+int strcasecmp (const char *s1, const char *s2);
+# endif
+#endif
+
+#if !HAVE_STRNCASECMP
+# if HAVE_STRNICMP
+# define strncasecmp strnicmp
+# elif HAVE_STRNCMPI
+# define strncasecmp strncmpi
+# else
+/* Create our own, in misc.c */
+int strncasecmp (const char *s1, const char *s2, int n);
+# endif
+#endif
+
+#define OUTPUT_SYNC_NONE 0
+#define OUTPUT_SYNC_LINE 1
+#define OUTPUT_SYNC_TARGET 2
+#define OUTPUT_SYNC_RECURSE 3
+
+/* Non-GNU systems may not declare this in unistd.h. */
+extern char **environ;
+
+extern const floc *reading_file;
+extern const floc **expanding_var;
+
+extern unsigned short stopchar_map[];
+
+extern int just_print_flag, run_silent, ignore_errors_flag, keep_going_flag;
+extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
+extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
+extern int print_version_flag, print_directory, check_symlink_flag;
+extern int warn_undefined_variables_flag, posix_pedantic;
+extern int not_parallel, second_expansion, clock_skew_detected;
+extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
+extern unsigned long command_count;
+
+extern const char *default_shell;
+
+/* can we run commands via 'sh -c xxx' or must we use batch files? */
+extern int batch_mode_shell;
+
+/* Resetting the command script introduction prefix character. */
+#define RECIPEPREFIX_NAME ".RECIPEPREFIX"
+#define RECIPEPREFIX_DEFAULT '\t'
+extern char cmd_prefix;
+
+extern unsigned int job_slots;
+extern double max_load_average;
+
+extern const char *program;
+
+#ifdef VMS
+const char *vms_command (const char *argv0);
+const char *vms_progname (const char *argv0);
+
+void vms_exit (int);
+# define _exit(foo) vms_exit(foo)
+# define exit(foo) vms_exit(foo)
+
+extern char *program_name;
+
+void
+set_program_name (const char *arv0);
+
+int
+need_vms_symbol (void);
+
+int
+create_foreign_command (const char *command, const char *image);
+
+int
+vms_export_dcl_symbol (const char *name, const char *value);
+
+int
+vms_putenv_symbol (const char *string);
+
+void
+vms_restore_symbol (const char *string);
+
+#endif
+
+void remote_setup (void);
+void remote_cleanup (void);
+int start_remote_job_p (int);
+int start_remote_job (char **, char **, int, int *, pid_t *, int *);
+int remote_status (int *, int *, int *, int);
+void block_remote_children (void);
+void unblock_remote_children (void);
+int remote_kill (pid_t id, int sig);
+void print_variable_data_base (void);
+void print_vpath_data_base (void);
+
+extern char *starting_directory;
+extern unsigned int makelevel;
+extern char *version_string, *remote_description, *make_host;
+
+extern unsigned int commands_started;
+
+extern int handling_fatal_signal;
+
+#ifndef MIN
+#define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
+#endif
+#ifndef MAX
+#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
+#endif
+
+#define MAKE_SUCCESS 0
+#define MAKE_TROUBLE 1
+#define MAKE_FAILURE 2
+
+/* Set up heap debugging library dmalloc. */
+
+#ifdef HAVE_DMALLOC_H
+#include <dmalloc.h>
+#endif
+
+#ifndef initialize_main
+# ifdef __EMX__
+# define initialize_main(pargc, pargv) \
+ { _wildcard(pargc, pargv); _response(pargc, pargv); }
+# else
+# define initialize_main(pargc, pargv)
+# endif
+#endif
+
+#ifdef __EMX__
+# if !defined chdir
+# define chdir _chdir2
+# endif
+# if !defined getcwd
+# define getcwd _getcwd2
+# endif
+
+/* NO_CHDIR2 causes make not to use _chdir2() and _getcwd2() instead of
+ chdir() and getcwd(). This avoids some error messages for the
+ make testsuite but restricts the drive letter support. */
+# ifdef NO_CHDIR2
+# warning NO_CHDIR2: usage of drive letters restricted
+# undef chdir
+# undef getcwd
+# endif
+#endif
+
+#ifndef initialize_main
+# define initialize_main(pargc, pargv)
+#endif
+
+
+/* Some systems (like Solaris, PTX, etc.) do not support the SA_RESTART flag
+ properly according to POSIX. So, we try to wrap common system calls with
+ checks for EINTR. Note that there are still plenty of system calls that
+ can fail with EINTR but this, reportedly, gets the vast majority of
+ failure cases. If you still experience failures you'll need to either get
+ a system where SA_RESTART works, or you need to avoid -j. */
+
+#define EINTRLOOP(_v,_c) while (((_v)=_c)==-1 && errno==EINTR)
+
+/* While system calls that return integers are pretty consistent about
+ returning -1 on failure and setting errno in that case, functions that
+ return pointers are not always so well behaved. Sometimes they return
+ NULL for expected behavior: one good example is readdir() which returns
+ NULL at the end of the directory--and _doesn't_ reset errno. So, we have
+ to do it ourselves here. */
+
+#define ENULLLOOP(_v,_c) do { errno = 0; (_v) = _c; } \
+ while((_v)==0 && errno==EINTR)
Index: create-4.3.1-getcwd-patch/make-4.3.1-new/src
===================================================================
--- create-4.3.1-getcwd-patch/make-4.3.1-new/src (nonexistent)
+++ create-4.3.1-getcwd-patch/make-4.3.1-new/src (revision 5)
Property changes on: create-4.3.1-getcwd-patch/make-4.3.1-new/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-4.3.1-getcwd-patch/make-4.3.1-new
===================================================================
--- create-4.3.1-getcwd-patch/make-4.3.1-new (nonexistent)
+++ create-4.3.1-getcwd-patch/make-4.3.1-new (revision 5)
Property changes on: create-4.3.1-getcwd-patch/make-4.3.1-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-4.3.1-getcwd-patch
===================================================================
--- create-4.3.1-getcwd-patch (nonexistent)
+++ create-4.3.1-getcwd-patch (revision 5)
Property changes on: create-4.3.1-getcwd-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-4.3.1-gnulib-patch/create.patch.sh
===================================================================
--- create-4.3.1-gnulib-patch/create.patch.sh (nonexistent)
+++ create-4.3.1-gnulib-patch/create.patch.sh (revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=4.3.1
+
+tar --files-from=file.list -xJvf ../make-$VERSION.tar.xz
+mv make-$VERSION make-$VERSION-orig
+
+cp -rf ./make-$VERSION-new ./make-$VERSION
+
+diff --unified -Nr make-$VERSION-orig make-$VERSION > make-$VERSION-gnulib.patch
+
+mv make-$VERSION-gnulib.patch ../patches
+
+rm -rf ./make-$VERSION
+rm -rf ./make-$VERSION-orig
Property changes on: create-4.3.1-gnulib-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-4.3.1-gnulib-patch/file.list
===================================================================
--- create-4.3.1-gnulib-patch/file.list (nonexistent)
+++ create-4.3.1-gnulib-patch/file.list (revision 5)
@@ -0,0 +1 @@
+make-4.3.1/src/job.c
Index: create-4.3.1-gnulib-patch/make-4.3.1-new/src/job.c
===================================================================
--- create-4.3.1-gnulib-patch/make-4.3.1-new/src/job.c (nonexistent)
+++ create-4.3.1-gnulib-patch/make-4.3.1-new/src/job.c (revision 5)
@@ -0,0 +1,3748 @@
+/* Job execution and handling for GNU Make.
+Copyright (C) 1988-2020 Free Software Foundation, Inc.
+This file is part of GNU Make.
+
+GNU Make is free software; you can redistribute it and/or modify it under the
+terms of the GNU General Public License as published by the Free Software
+Foundation; either version 3 of the License, or (at your option) any later
+version.
+
+GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with
+this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "makeint.h"
+
+#include <assert.h>
+#include <string.h>
+
+#include "job.h"
+#include "debug.h"
+#include "filedef.h"
+#include "commands.h"
+#include "variable.h"
+#include "os.h"
+
+/* Default shell to use. */
+#ifdef WINDOWS32
+# ifdef HAVE_STRINGS_H
+# include <strings.h> /* for strcasecmp, strncasecmp */
+# endif
+# include <windows.h>
+
+const char *default_shell = "sh.exe";
+int no_default_sh_exe = 1;
+int batch_mode_shell = 1;
+HANDLE main_thread;
+
+#elif defined (_AMIGA)
+
+const char *default_shell = "";
+extern int MyExecute (char **);
+int batch_mode_shell = 0;
+
+#elif defined (__MSDOS__)
+
+/* The default shell is a pointer so we can change it if Makefile
+ says so. It is without an explicit path so we get a chance
+ to search the $PATH for it (since MSDOS doesn't have standard
+ directories we could trust). */
+const char *default_shell = "command.com";
+int batch_mode_shell = 0;
+
+#elif defined (__EMX__)
+
+const char *default_shell = "/bin/sh";
+int batch_mode_shell = 0;
+
+#elif defined (VMS)
+
+# include <descrip.h>
+# include <stsdef.h>
+const char *default_shell = "";
+int batch_mode_shell = 0;
+
+#define strsignal vms_strsignal
+char * vms_strsignal (int status);
+
+#ifndef C_FACILITY_NO
+# define C_FACILITY_NO 0x350000
+#endif
+#ifndef VMS_POSIX_EXIT_MASK
+# define VMS_POSIX_EXIT_MASK (C_FACILITY_NO | 0xA000)
+#endif
+
+#else
+
+const char *default_shell = "/bin/sh";
+int batch_mode_shell = 0;
+
+#endif
+
+#ifdef __MSDOS__
+# include <process.h>
+static int execute_by_shell;
+static int dos_pid = 123;
+int dos_status;
+int dos_command_running;
+#endif /* __MSDOS__ */
+
+#ifdef _AMIGA
+# include <proto/dos.h>
+static int amiga_pid = 123;
+static int amiga_status;
+static char amiga_bname[32];
+static int amiga_batch_file;
+#endif /* Amiga. */
+
+#ifdef VMS
+# ifndef __GNUC__
+# include <processes.h>
+# endif
+# include <starlet.h>
+# include <lib$routines.h>
+static void vmsWaitForChildren (int *);
+#endif
+
+#ifdef WINDOWS32
+# include <windows.h>
+# include <io.h>
+# include <process.h>
+# include "sub_proc.h"
+# include "w32err.h"
+# include "pathstuff.h"
+# define WAIT_NOHANG 1
+#endif /* WINDOWS32 */
+
+#ifdef __EMX__
+# include <process.h>
+#endif
+
+#if defined (HAVE_SYS_WAIT_H) || defined (HAVE_UNION_WAIT)
+# include <sys/wait.h>
+#endif
+
+#ifdef HAVE_WAITPID
+# define WAIT_NOHANG(status) waitpid (-1, (status), WNOHANG)
+#else /* Don't have waitpid. */
+# ifdef HAVE_WAIT3
+# ifndef wait3
+extern int wait3 ();
+# endif
+# define WAIT_NOHANG(status) wait3 ((status), WNOHANG, (struct rusage *) 0)
+# endif /* Have wait3. */
+#endif /* Have waitpid. */
+
+#ifdef USE_POSIX_SPAWN
+# include <spawn.h>
+# include "findprog.h"
+#endif
+
+#if !defined (wait) && !defined (POSIX)
+int wait ();
+#endif
+
+#ifndef HAVE_UNION_WAIT
+
+# define WAIT_T int
+
+# ifndef WTERMSIG
+# define WTERMSIG(x) ((x) & 0x7f)
+# endif
+# ifndef WCOREDUMP
+# define WCOREDUMP(x) ((x) & 0x80)
+# endif
+# ifndef WEXITSTATUS
+# define WEXITSTATUS(x) (((x) >> 8) & 0xff)
+# endif
+# ifndef WIFSIGNALED
+# define WIFSIGNALED(x) (WTERMSIG (x) != 0)
+# endif
+# ifndef WIFEXITED
+# define WIFEXITED(x) (WTERMSIG (x) == 0)
+# endif
+
+#else /* Have 'union wait'. */
+
+# define WAIT_T union wait
+# ifndef WTERMSIG
+# define WTERMSIG(x) ((x).w_termsig)
+# endif
+# ifndef WCOREDUMP
+# define WCOREDUMP(x) ((x).w_coredump)
+# endif
+# ifndef WEXITSTATUS
+# define WEXITSTATUS(x) ((x).w_retcode)
+# endif
+# ifndef WIFSIGNALED
+# define WIFSIGNALED(x) (WTERMSIG(x) != 0)
+# endif
+# ifndef WIFEXITED
+# define WIFEXITED(x) (WTERMSIG(x) == 0)
+# endif
+
+#endif /* Don't have 'union wait'. */
+
+#if !defined(HAVE_UNISTD_H) && !defined(WINDOWS32)
+int dup2 ();
+int execve ();
+void _exit ();
+# ifndef VMS
+int geteuid ();
+int getegid ();
+int setgid ();
+int getgid ();
+# endif
+#endif
+
+/* Different systems have different requirements for pid_t.
+ Plus we have to support gettext string translation... Argh. */
+static const char *
+pid2str (pid_t pid)
+{
+ static char pidstring[100];
+#if defined(WINDOWS32) && (__GNUC__ > 3 || _MSC_VER > 1300)
+ /* %Id is only needed for 64-builds, which were not supported by
+ older versions of Windows compilers. */
+ sprintf (pidstring, "%Id", pid);
+#else
+ sprintf (pidstring, "%lu", (unsigned long) pid);
+#endif
+ return pidstring;
+}
+
+#ifndef HAVE_GETLOADAVG
+int getloadavg (double loadavg[], int nelem);
+#endif
+
+static void free_child (struct child *);
+static void start_job_command (struct child *child);
+static int load_too_high (void);
+static int job_next_command (struct child *);
+static int start_waiting_job (struct child *);
+
+/* Chain of all live (or recently deceased) children. */
+
+struct child *children = 0;
+
+/* Number of children currently running. */
+
+unsigned int job_slots_used = 0;
+
+/* Nonzero if the 'good' standard input is in use. */
+
+static int good_stdin_used = 0;
+
+/* Chain of children waiting to run until the load average goes down. */
+
+static struct child *waiting_jobs = 0;
+
+/* Non-zero if we use a *real* shell (always so on Unix). */
+
+int unixy_shell = 1;
+
+/* Number of jobs started in the current second. */
+
+unsigned long job_counter = 0;
+
+/* Number of jobserver tokens this instance is currently using. */
+
+unsigned int jobserver_tokens = 0;
+
+
+#ifdef WINDOWS32
+/*
+ * The macro which references this function is defined in makeint.h.
+ */
+int
+w32_kill (pid_t pid, int sig)
+{
+ return ((process_kill ((HANDLE)pid, sig) == TRUE) ? 0 : -1);
+}
+
+/* This function creates a temporary file name with an extension specified
+ * by the unixy arg.
+ * Return an xmalloc'ed string of a newly created temp file and its
+ * file descriptor, or die. */
+static char *
+create_batch_file (char const *base, int unixy, int *fd)
+{
+ const char *const ext = unixy ? "sh" : "bat";
+ const char *error_string = NULL;
+ char temp_path[MAXPATHLEN]; /* need to know its length */
+ unsigned path_size = GetTempPath (sizeof temp_path, temp_path);
+ int path_is_dot = 0;
+ /* The following variable is static so we won't try to reuse a name
+ that was generated a little while ago, because that file might
+ not be on disk yet, since we use FILE_ATTRIBUTE_TEMPORARY below,
+ which tells the OS it doesn't need to flush the cache to disk.
+ If the file is not yet on disk, we might think the name is
+ available, while it really isn't. This happens in parallel
+ builds, where Make doesn't wait for one job to finish before it
+ launches the next one. */
+ static unsigned uniq = 0;
+ static int second_loop = 0;
+ const size_t sizemax = strlen (base) + strlen (ext) + 10;
+
+ if (path_size == 0)
+ {
+ path_size = GetCurrentDirectory (sizeof temp_path, temp_path);
+ path_is_dot = 1;
+ }
+
+ ++uniq;
+ if (uniq >= 0x10000 && !second_loop)
+ {
+ /* If we already had 64K batch files in this
+ process, make a second loop through the numbers,
+ looking for free slots, i.e. files that were
+ deleted in the meantime. */
+ second_loop = 1;
+ uniq = 1;
+ }
+ while (path_size > 0 &&
+ path_size + sizemax < sizeof temp_path &&
+ !(uniq >= 0x10000 && second_loop))
+ {
+ unsigned size = sprintf (temp_path + path_size,
+ "%s%s-%x.%s",
+ temp_path[path_size - 1] == '\\' ? "" : "\\",
+ base, uniq, ext);
+ HANDLE h = CreateFile (temp_path, /* file name */
+ GENERIC_READ | GENERIC_WRITE, /* desired access */
+ 0, /* no share mode */
+ NULL, /* default security attributes */
+ CREATE_NEW, /* creation disposition */
+ FILE_ATTRIBUTE_NORMAL | /* flags and attributes */
+ FILE_ATTRIBUTE_TEMPORARY, /* we'll delete it */
+ NULL); /* no template file */
+
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ const DWORD er = GetLastError ();
+
+ if (er == ERROR_FILE_EXISTS || er == ERROR_ALREADY_EXISTS)
+ {
+ ++uniq;
+ if (uniq == 0x10000 && !second_loop)
+ {
+ second_loop = 1;
+ uniq = 1;
+ }
+ }
+
+ /* the temporary path is not guaranteed to exist */
+ else if (path_is_dot == 0)
+ {
+ path_size = GetCurrentDirectory (sizeof temp_path, temp_path);
+ path_is_dot = 1;
+ }
+
+ else
+ {
+ error_string = map_windows32_error_to_string (er);
+ break;
+ }
+ }
+ else
+ {
+ const unsigned final_size = path_size + size + 1;
+ char *const path = xmalloc (final_size);
+ memcpy (path, temp_path, final_size);
+ *fd = _open_osfhandle ((intptr_t)h, 0);
+ if (unixy)
+ {
+ char *p;
+ int ch;
+ for (p = path; (ch = *p) != 0; ++p)
+ if (ch == '\\')
+ *p = '/';
+ }
+ return path; /* good return */
+ }
+ }
+
+ *fd = -1;
+ if (error_string == NULL)
+ error_string = _("Cannot create a temporary file\n");
+ O (fatal, NILF, error_string);
+
+ /* not reached */
+ return NULL;
+}
+#endif /* WINDOWS32 */
+
+#ifdef __EMX__
+/* returns whether path is assumed to be a unix like shell. */
+int
+_is_unixy_shell (const char *path)
+{
+ /* list of non unix shells */
+ const char *known_os2shells[] = {
+ "cmd.exe",
+ "cmd",
+ "4os2.exe",
+ "4os2",
+ "4dos.exe",
+ "4dos",
+ "command.com",
+ "command",
+ NULL
+ };
+
+ /* find the rightmost '/' or '\\' */
+ const char *name = strrchr (path, '/');
+ const char *p = strrchr (path, '\\');
+ unsigned i;
+
+ if (name && p) /* take the max */
+ name = (name > p) ? name : p;
+ else if (p) /* name must be 0 */
+ name = p;
+ else if (!name) /* name and p must be 0 */
+ name = path;
+
+ if (*name == '/' || *name == '\\') name++;
+
+ i = 0;
+ while (known_os2shells[i] != NULL)
+ {
+ if (strcasecmp (name, known_os2shells[i]) == 0)
+ return 0; /* not a unix shell */
+ i++;
+ }
+
+ /* in doubt assume a unix like shell */
+ return 1;
+}
+#endif /* __EMX__ */
+
+/* determines whether path looks to be a Bourne-like shell. */
+int
+is_bourne_compatible_shell (const char *path)
+{
+ /* List of known POSIX (or POSIX-ish) shells. */
+ static const char *unix_shells[] = {
+ "sh",
+ "bash",
+ "ksh",
+ "rksh",
+ "zsh",
+ "ash",
+ "dash",
+ NULL
+ };
+ const char **s;
+
+ /* find the rightmost '/' or '\\' */
+ const char *name = strrchr (path, '/');
+ char *p = strrchr (path, '\\');
+
+ if (name && p) /* take the max */
+ name = (name > p) ? name : p;
+ else if (p) /* name must be 0 */
+ name = p;
+ else if (!name) /* name and p must be 0 */
+ name = path;
+
+ if (*name == '/' || *name == '\\')
+ ++name;
+
+ /* this should be able to deal with extensions on Windows-like systems */
+ for (s = unix_shells; *s != NULL; ++s)
+ {
+#if defined(WINDOWS32) || defined(__MSDOS__)
+ size_t len = strlen (*s);
+ if ((strlen (name) >= len && STOP_SET (name[len], MAP_DOT|MAP_NUL))
+ && strncasecmp (name, *s, len) == 0)
+#else
+ if (strcmp (name, *s) == 0)
+#endif
+ return 1; /* a known unix-style shell */
+ }
+
+ /* if not on the list, assume it's not a Bourne-like shell */
+ return 0;
+}
+
+#ifdef POSIX
+extern sigset_t fatal_signal_set;
+
+static void
+block_sigs ()
+{
+ sigprocmask (SIG_BLOCK, &fatal_signal_set, (sigset_t *) 0);
+}
+
+static void
+unblock_sigs ()
+{
+ sigprocmask (SIG_UNBLOCK, &fatal_signal_set, (sigset_t *) 0);
+}
+
+void
+unblock_all_sigs ()
+{
+ sigset_t empty;
+ sigemptyset (&empty);
+ sigprocmask (SIG_SETMASK, &empty, (sigset_t *) 0);
+}
+
+#elif defined(HAVE_SIGSETMASK)
+
+extern int fatal_signal_mask;
+
+static void
+block_sigs ()
+{
+ sigblock (fatal_signal_mask);
+}
+
+static void
+unblock_sigs ()
+{
+ sigsetmask (siggetmask () & ~fatal_signal_mask);
+}
+
+void
+unblock_all_sigs ()
+{
+ sigsetmask (0);
+}
+
+#else
+
+#define block_sigs()
+#define unblock_sigs()
+
+void
+unblock_all_sigs ()
+{
+}
+
+#endif
+
+/* Write an error message describing the exit status given in
+ EXIT_CODE, EXIT_SIG, and COREDUMP, for the target TARGET_NAME.
+ Append "(ignored)" if IGNORED is nonzero. */
+
+static void
+child_error (struct child *child,
+ int exit_code, int exit_sig, int coredump, int ignored)
+{
+ const char *pre = "*** ";
+ const char *post = "";
+ const char *dump = "";
+ const struct file *f = child->file;
+ const floc *flocp = &f->cmds->fileinfo;
+ const char *nm;
+ size_t l;
+
+ if (ignored && run_silent)
+ return;
+
+ if (exit_sig && coredump)
+ dump = _(" (core dumped)");
+
+ if (ignored)
+ {
+ pre = "";
+ post = _(" (ignored)");
+ }
+
+ if (! flocp->filenm)
+ nm = _("<builtin>");
+ else
+ {
+ char *a = alloca (strlen (flocp->filenm) + 6 + INTSTR_LENGTH + 1);
+ sprintf (a, "%s:%lu", flocp->filenm, flocp->lineno + flocp->offset);
+ nm = a;
+ }
+
+ l = strlen (pre) + strlen (nm) + strlen (f->name) + strlen (post);
+
+ OUTPUT_SET (&child->output);
+
+ show_goal_error ();
+
+ if (exit_sig == 0)
+ error (NILF, l + INTSTR_LENGTH,
+ _("%s[%s: %s] Error %d%s"), pre, nm, f->name, exit_code, post);
+ else
+ {
+ const char *s = strsignal (exit_sig);
+ error (NILF, l + strlen (s) + strlen (dump),
+ "%s[%s: %s] %s%s%s", pre, nm, f->name, s, dump, post);
+ }
+
+ OUTPUT_UNSET ();
+}
+
+
+/* Handle a dead child. This handler may or may not ever be installed.
+
+ If we're using the jobserver feature without pselect(), we need it.
+ First, installing it ensures the read will interrupt on SIGCHLD. Second,
+ we close the dup'd read FD to ensure we don't enter another blocking read
+ without reaping all the dead children. In this case we don't need the
+ dead_children count.
+
+ If we don't have either waitpid or wait3, then make is unreliable, but we
+ use the dead_children count to reap children as best we can. */
+
+static unsigned int dead_children = 0;
+
+RETSIGTYPE
+child_handler (int sig UNUSED)
+{
+ ++dead_children;
+
+ jobserver_signal ();
+
+#ifdef __EMX__
+ /* The signal handler must called only once! */
+ signal (SIGCHLD, SIG_DFL);
+#endif
+}
+
+extern pid_t shell_function_pid;
+
+/* Reap all dead children, storing the returned status and the new command
+ state ('cs_finished') in the 'file' member of the 'struct child' for the
+ dead child, and removing the child from the chain. In addition, if BLOCK
+ nonzero, we block in this function until we've reaped at least one
+ complete child, waiting for it to die if necessary. If ERR is nonzero,
+ print an error message first. */
+
+void
+reap_children (int block, int err)
+{
+#ifndef WINDOWS32
+ WAIT_T status;
+#endif
+ /* Initially, assume we have some. */
+ int reap_more = 1;
+
+#ifdef WAIT_NOHANG
+# define REAP_MORE reap_more
+#else
+# define REAP_MORE dead_children
+#endif
+
+ /* 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))
+ {
+ unsigned int remote = 0;
+ pid_t pid;
+ int exit_code, exit_sig, coredump;
+ struct child *lastc, *c;
+ int child_failed;
+ int any_remote, any_local;
+ int dontcare;
+
+ if (err && block)
+ {
+ static int printed = 0;
+
+ /* We might block for a while, so let the user know why.
+ Only print this message once no matter how many jobs are left. */
+ fflush (stdout);
+ if (!printed)
+ O (error, NILF, _("*** Waiting for unfinished jobs...."));
+ printed = 1;
+ }
+
+ /* We have one less dead child to reap. As noted in
+ child_handler() above, this count is completely unimportant for
+ all modern, POSIX-y systems that support wait3() or waitpid().
+ The rest of this comment below applies only to early, broken
+ pre-POSIX systems. We keep the count only because... it's there...
+
+ The test and decrement are not atomic; if it is compiled into:
+ register = dead_children - 1;
+ dead_children = register;
+ a SIGCHLD could come between the two instructions.
+ child_handler increments dead_children.
+ The second instruction here would lose that increment. But the
+ only effect of dead_children being wrong is that we might wait
+ longer than necessary to reap a child, and lose some parallelism;
+ and we might print the "Waiting for unfinished jobs" message above
+ when not necessary. */
+
+ if (dead_children > 0)
+ --dead_children;
+
+ any_remote = 0;
+ any_local = shell_function_pid != 0;
+ lastc = 0;
+ for (c = children; c != 0; lastc = c, c = c->next)
+ {
+ any_remote |= c->remote;
+ any_local |= ! c->remote;
+
+ /* If pid < 0, this child never even started. Handle it. */
+ if (c->pid < 0)
+ {
+ exit_sig = 0;
+ coredump = 0;
+ /* According to POSIX, 127 is used for command not found. */
+ exit_code = 127;
+ goto process_child;
+ }
+
+ DB (DB_JOBS, (_("Live child %p (%s) PID %s %s\n"),
+ c, c->file->name, pid2str (c->pid),
+ c->remote ? _(" (remote)") : ""));
+#ifdef VMS
+ break;
+#endif
+ }
+
+ /* First, check for remote children. */
+ if (any_remote)
+ pid = remote_status (&exit_code, &exit_sig, &coredump, 0);
+ else
+ pid = 0;
+
+ if (pid > 0)
+ /* We got a remote child. */
+ remote = 1;
+ else if (pid < 0)
+ {
+ /* A remote status command failed miserably. Punt. */
+ pfatal_with_name ("remote_status");
+ }
+ else
+ {
+ /* No remote children. Check for local children. */
+#if !defined(__MSDOS__) && !defined(_AMIGA) && !defined(WINDOWS32)
+ if (any_local)
+ {
+#ifdef VMS
+ /* Todo: This needs more untangling multi-process support */
+ /* Just do single child process support now */
+ vmsWaitForChildren (&status);
+ pid = c->pid;
+
+ /* VMS failure status can not be fully translated */
+ status = $VMS_STATUS_SUCCESS (c->cstatus) ? 0 : (1 << 8);
+
+ /* A Posix failure can be exactly translated */
+ if ((c->cstatus & VMS_POSIX_EXIT_MASK) == VMS_POSIX_EXIT_MASK)
+ status = (c->cstatus >> 3 & 255) << 8;
+#else
+#ifdef WAIT_NOHANG
+ if (!block)
+ pid = WAIT_NOHANG (&status);
+ else
+#endif
+ EINTRLOOP (pid, wait (&status));
+#endif /* !VMS */
+ }
+ else
+ pid = 0;
+
+ if (pid < 0)
+ {
+ /* The wait*() failed miserably. Punt. */
+ pfatal_with_name ("wait");
+ }
+ else if (pid > 0)
+ {
+ /* We got a child exit; chop the status word up. */
+ exit_code = WEXITSTATUS (status);
+ exit_sig = WIFSIGNALED (status) ? WTERMSIG (status) : 0;
+ coredump = WCOREDUMP (status);
+ }
+ else
+ {
+ /* No local children are dead. */
+ reap_more = 0;
+
+ 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)
+ pfatal_with_name ("remote_status");
+
+ 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;
+ status = dos_status;
+ exit_code = WEXITSTATUS (status);
+ if (exit_code == 0xff)
+ exit_code = -1;
+ exit_sig = WIFSIGNALED (status) ? WTERMSIG (status) : 0;
+ coredump = 0;
+#endif /* __MSDOS__ */
+#ifdef _AMIGA
+ /* Same on Amiga */
+ pid = amiga_pid - 1;
+ status = amiga_status;
+ exit_code = amiga_status;
+ exit_sig = 0;
+ coredump = 0;
+#endif /* _AMIGA */
+#ifdef WINDOWS32
+ {
+ HANDLE hPID;
+ HANDLE hcTID, hcPID;
+ DWORD dwWaitStatus = 0;
+ exit_code = 0;
+ exit_sig = 0;
+ coredump = 0;
+
+ /* Record the thread ID of the main process, so that we
+ could suspend it in the signal handler. */
+ if (!main_thread)
+ {
+ hcTID = GetCurrentThread ();
+ hcPID = GetCurrentProcess ();
+ if (!DuplicateHandle (hcPID, hcTID, hcPID, &main_thread, 0,
+ FALSE, DUPLICATE_SAME_ACCESS))
+ {
+ DWORD e = GetLastError ();
+ fprintf (stderr,
+ "Determine main thread ID (Error %ld: %s)\n",
+ e, map_windows32_error_to_string (e));
+ }
+ else
+ DB (DB_VERBOSE, ("Main thread handle = %p\n", main_thread));
+ }
+
+ /* wait for anything to finish */
+ hPID = process_wait_for_any (block, &dwWaitStatus);
+ if (hPID)
+ {
+ /* was an error found on this process? */
+ int werr = process_last_err (hPID);
+
+ /* get exit data */
+ exit_code = process_exit_code (hPID);
+
+ /* the extra tests of exit_code are here to prevent
+ map_windows32_error_to_string from calling 'fatal',
+ which will then call reap_children again */
+ if (werr && exit_code > 0 && exit_code < WSABASEERR)
+ fprintf (stderr, "make (e=%d): %s", exit_code,
+ map_windows32_error_to_string (exit_code));
+
+ /* signal */
+ exit_sig = process_signal (hPID);
+
+ /* cleanup process */
+ process_cleanup (hPID);
+
+ coredump = 0;
+ }
+ else if (dwWaitStatus == WAIT_FAILED)
+ {
+ /* The WaitForMultipleObjects() failed miserably. Punt. */
+ pfatal_with_name ("WaitForMultipleObjects");
+ }
+ else if (dwWaitStatus == WAIT_TIMEOUT)
+ {
+ /* No child processes are finished. Give up waiting. */
+ reap_more = 0;
+ break;
+ }
+
+ pid = (pid_t) hPID;
+ }
+#endif /* WINDOWS32 */
+ }
+
+ /* Some child finished: increment the command count. */
+ ++command_count;
+
+ /* Check if this is the child of the 'shell' function. */
+ if (!remote && pid == shell_function_pid)
+ {
+ shell_completed (exit_code, exit_sig);
+ break;
+ }
+
+ /* Search for a child matching the deceased one. */
+ lastc = 0;
+ for (c = children; c != 0; lastc = c, c = c->next)
+ if (c->pid == pid && c->remote == remote)
+ break;
+
+ if (c == 0)
+ /* An unknown child died.
+ Ignore it; it was inherited from our invoker. */
+ continue;
+
+ DB (DB_JOBS, (exit_sig == 0 && exit_code == 0
+ ? _("Reaping winning child %p PID %s %s\n")
+ : _("Reaping losing child %p PID %s %s\n"),
+ c, pid2str (c->pid), c->remote ? _(" (remote)") : ""));
+
+ /* If we have started jobs in this second, remove one. */
+ if (job_counter)
+ --job_counter;
+
+ process_child:
+
+#if defined(USE_POSIX_SPAWN)
+ /* Some versions of posix_spawn() do not detect errors such as command
+ not found until after they fork. In that case they will exit with a
+ code of 127. Try to detect that and provide a useful error message.
+ Otherwise we'll just show the error below, as normal. */
+ if (exit_sig == 0 && exit_code == 127 && c->cmd_name)
+ {
+ const char *e = NULL;
+ struct stat st;
+ int r;
+
+ /* There are various ways that this will show a different error than
+ fork/exec. To really get the right error we'd have to fall back
+ to fork/exec but I don't want to bother with that. Just do the
+ best we can. */
+
+ EINTRLOOP(r, stat(c->cmd_name, &st));
+ if (r < 0)
+ e = strerror (errno);
+ else if (S_ISDIR(st.st_mode) || !(st.st_mode & S_IXUSR))
+ e = strerror (EACCES);
+ else if (st.st_size == 0)
+ e = strerror (ENOEXEC);
+
+ if (e)
+ OSS(error, NILF, "%s: %s", c->cmd_name, e);
+ }
+#endif
+
+ /* Determine the failure status: 0 for success, 1 for updating target in
+ question mode, 2 for anything else. */
+ if (exit_sig == 0 && exit_code == 0)
+ child_failed = MAKE_SUCCESS;
+ else if (exit_sig == 0 && exit_code == 1 && question_flag && c->recursive)
+ child_failed = MAKE_TROUBLE;
+ else
+ child_failed = MAKE_FAILURE;
+
+ if (c->sh_batch_file)
+ {
+ int rm_status;
+
+ DB (DB_JOBS, (_("Cleaning up temp batch file %s\n"),
+ c->sh_batch_file));
+
+ errno = 0;
+ rm_status = remove (c->sh_batch_file);
+ if (rm_status)
+ DB (DB_JOBS, (_("Cleaning up temp batch file %s failed (%d)\n"),
+ c->sh_batch_file, errno));
+
+ /* all done with memory */
+ free (c->sh_batch_file);
+ c->sh_batch_file = NULL;
+ }
+
+ /* If this child had the good stdin, say it is now free. */
+ if (c->good_stdin)
+ good_stdin_used = 0;
+
+ dontcare = c->dontcare;
+
+ if (child_failed && !c->noerror && !ignore_errors_flag)
+ {
+ /* The commands failed. Write an error message,
+ delete non-precious targets, and abort. */
+ static int delete_on_error = -1;
+
+ if (!dontcare && child_failed == MAKE_FAILURE)
+ child_error (c, exit_code, exit_sig, coredump, 0);
+
+ c->file->update_status = child_failed == MAKE_FAILURE ? us_failed : us_question;
+ if (delete_on_error == -1)
+ {
+ struct file *f = lookup_file (".DELETE_ON_ERROR");
+ delete_on_error = f != 0 && f->is_target;
+ }
+ if (exit_sig != 0 || delete_on_error)
+ delete_child_targets (c);
+ }
+ else
+ {
+ if (child_failed)
+ {
+ /* The commands failed, but we don't care. */
+ child_error (c, exit_code, exit_sig, coredump, 1);
+ child_failed = 0;
+ }
+
+ /* If there are more commands to run, try to start them. */
+ if (job_next_command (c))
+ {
+ if (handling_fatal_signal)
+ {
+ /* Never start new commands while we are dying.
+ Since there are more commands that wanted to be run,
+ the target was not completely remade. So we treat
+ this as if a command had failed. */
+ c->file->update_status = us_failed;
+ }
+ else
+ {
+#ifndef NO_OUTPUT_SYNC
+ /* If we're sync'ing per line, write the previous line's
+ output before starting the next one. */
+ if (output_sync == OUTPUT_SYNC_LINE)
+ output_dump (&c->output);
+#endif
+ /* Check again whether to start remotely.
+ Whether or not we want to changes over time.
+ Also, start_remote_job may need state set up
+ by start_remote_job_p. */
+ c->remote = start_remote_job_p (0);
+ start_job_command (c);
+ /* Fatal signals are left blocked in case we were
+ about to put that child on the chain. But it is
+ already there, so it is safe for a fatal signal to
+ arrive now; it will clean up this child's targets. */
+ unblock_sigs ();
+ if (c->file->command_state == cs_running)
+ /* We successfully started the new command.
+ Loop to reap more children. */
+ continue;
+ }
+
+ if (c->file->update_status != us_success)
+ /* We failed to start the commands. */
+ delete_child_targets (c);
+ }
+ else
+ /* There are no more commands. We got through them all
+ without an unignored error. Now the target has been
+ successfully updated. */
+ c->file->update_status = us_success;
+ }
+
+ /* When we get here, all the commands for c->file are finished. */
+
+#ifndef NO_OUTPUT_SYNC
+ /* Synchronize any remaining parallel output. */
+ output_dump (&c->output);
+#endif
+
+ /* At this point c->file->update_status is success or failed. But
+ c->file->command_state is still cs_running if all the commands
+ ran; notice_finished_file looks for cs_running to tell it that
+ it's interesting to check the file's modtime again now. */
+
+ if (! handling_fatal_signal)
+ /* Notice if the target of the commands has been changed.
+ This also propagates its values for command_state and
+ update_status to its also_make files. */
+ notice_finished_file (c->file);
+
+ /* Block fatal signals while frobnicating the list, so that
+ children and job_slots_used are always consistent. Otherwise
+ a fatal signal arriving after the child is off the chain and
+ before job_slots_used is decremented would believe a child was
+ live and call reap_children again. */
+ block_sigs ();
+
+ if (c->pid > 0)
+ {
+ DB (DB_JOBS, (_("Removing child %p PID %s%s from chain.\n"),
+ c, pid2str (c->pid), c->remote ? _(" (remote)") : ""));
+ }
+
+ /* There is now another slot open. */
+ if (job_slots_used > 0)
+ job_slots_used -= c->jobslot;
+
+ /* Remove the child from the chain and free it. */
+ if (lastc == 0)
+ children = c->next;
+ else
+ lastc->next = c->next;
+
+ free_child (c);
+
+ unblock_sigs ();
+
+ /* If the job failed, and the -k flag was not given, die,
+ unless we are already in the process of dying. */
+ if (!err && child_failed && !dontcare && !keep_going_flag &&
+ /* fatal_error_signal will die with the right signal. */
+ !handling_fatal_signal)
+ die (child_failed);
+
+ /* Only block for one child. */
+ block = 0;
+ }
+
+ return;
+}
+
+/* Free the storage allocated for CHILD. */
+
+static void
+free_child (struct child *child)
+{
+ output_close (&child->output);
+
+ if (!jobserver_tokens)
+ ONS (fatal, NILF, "INTERNAL: Freeing child %p (%s) but no tokens left!\n",
+ child, child->file->name);
+
+ /* If we're using the jobserver and this child is not the only outstanding
+ job, put a token back into the pipe for it. */
+
+ if (jobserver_enabled () && jobserver_tokens > 1)
+ {
+ jobserver_release (1);
+ DB (DB_JOBS, (_("Released token for child %p (%s).\n"),
+ child, child->file->name));
+ }
+
+ --jobserver_tokens;
+
+ if (handling_fatal_signal) /* Don't bother free'ing if about to die. */
+ return;
+
+ if (child->command_lines != 0)
+ {
+ unsigned int i;
+ for (i = 0; i < child->file->cmds->ncommand_lines; ++i)
+ free (child->command_lines[i]);
+ free (child->command_lines);
+ }
+
+ if (child->environment != 0)
+ {
+ char **ep = child->environment;
+ while (*ep != 0)
+ free (*ep++);
+ free (child->environment);
+ }
+
+ free (child->cmd_name);
+ free (child);
+}
+
+
+/* Start a job to run the commands specified in CHILD.
+ CHILD is updated to reflect the commands and ID of the child process.
+
+ NOTE: On return fatal signals are blocked! The caller is responsible
+ for calling 'unblock_sigs', once the new child is safely on the chain so
+ it can be cleaned up in the event of a fatal signal. */
+
+static void
+start_job_command (struct child *child)
+{
+ int flags;
+ char *p;
+#ifdef VMS
+# define FREE_ARGV(_a)
+ char *argv;
+#else
+# define FREE_ARGV(_a) do{ if (_a) { free ((_a)[0]); free (_a); } }while(0)
+ char **argv;
+#endif
+
+ /* If we have a completely empty commandset, stop now. */
+ if (!child->command_ptr)
+ goto next_command;
+
+ /* Combine the flags parsed for the line itself with
+ the flags specified globally for this target. */
+ flags = (child->file->command_flags
+ | child->file->cmds->lines_flags[child->command_line - 1]);
+
+ p = child->command_ptr;
+ child->noerror = ((flags & COMMANDS_NOERROR) != 0);
+
+ while (*p != '\0')
+ {
+ if (*p == '@')
+ flags |= COMMANDS_SILENT;
+ else if (*p == '+')
+ flags |= COMMANDS_RECURSE;
+ else if (*p == '-')
+ child->noerror = 1;
+ /* Don't skip newlines. */
+ else if (!ISBLANK (*p))
+ break;
+ ++p;
+ }
+
+ child->recursive = ((flags & COMMANDS_RECURSE) != 0);
+
+ /* Update the file's command flags with any new ones we found. We only
+ keep the COMMANDS_RECURSE setting. Even this isn't 100% correct; we are
+ now marking more commands recursive than should be in the case of
+ multiline define/endef scripts where only one line is marked "+". In
+ order to really fix this, we'll have to keep a lines_flags for every
+ actual line, after expansion. */
+ child->file->cmds->lines_flags[child->command_line - 1] |= flags & COMMANDS_RECURSE;
+
+ /* POSIX requires that a recipe prefix after a backslash-newline should
+ be ignored. Remove it now so the output is correct. */
+ {
+ char prefix = child->file->cmds->recipe_prefix;
+ char *p1, *p2;
+ p1 = p2 = p;
+ while (*p1 != '\0')
+ {
+ *(p2++) = *p1;
+ if (p1[0] == '\n' && p1[1] == prefix)
+ ++p1;
+ ++p1;
+ }
+ *p2 = *p1;
+ }
+
+ /* Figure out an argument list from this command line. */
+ {
+ char *end = 0;
+#ifdef VMS
+ /* Skip any leading whitespace */
+ while (*p)
+ {
+ if (!ISSPACE (*p))
+ {
+ if (*p != '\\')
+ break;
+ if ((p[1] != '\n') && (p[1] != 'n') && (p[1] != 't'))
+ break;
+ }
+ p++;
+ }
+
+ argv = p;
+ /* Please note, for VMS argv is a string (not an array of strings) which
+ contains the complete command line, which for multi-line variables
+ still includes the newlines. So detect newlines and set 'end' (which
+ is used for child->command_ptr) instead of (re-)writing
+ construct_command_argv */
+ if (!one_shell)
+ {
+ char *s = p;
+ int instring = 0;
+ while (*s)
+ {
+ if (*s == '"')
+ instring = !instring;
+ else if (*s == '\\' && !instring && *(s+1) != 0)
+ s++;
+ else if (*s == '\n' && !instring)
+ {
+ end = s;
+ break;
+ }
+ ++s;
+ }
+ }
+#else
+ argv = construct_command_argv (p, &end, child->file,
+ child->file->cmds->lines_flags[child->command_line - 1],
+ &child->sh_batch_file);
+#endif
+ if (end == NULL)
+ child->command_ptr = NULL;
+ else
+ {
+ *end++ = '\0';
+ child->command_ptr = end;
+ }
+ }
+
+ /* If -q was given, say that updating 'failed' if there was any text on the
+ command line, or 'succeeded' otherwise. The exit status of 1 tells the
+ user that -q is saying 'something to do'; the exit status for a random
+ error is 2. */
+ if (argv != 0 && question_flag && !(flags & COMMANDS_RECURSE))
+ {
+ FREE_ARGV (argv);
+#ifdef VMS
+ /* On VMS, argv[0] can be a null string here */
+ if (argv[0] != 0)
+ {
+#endif
+ child->file->update_status = us_question;
+ notice_finished_file (child->file);
+ return;
+#ifdef VMS
+ }
+#endif
+ }
+
+ if (touch_flag && !(flags & COMMANDS_RECURSE))
+ {
+ /* Go on to the next command. It might be the recursive one.
+ We construct ARGV only to find the end of the command line. */
+ FREE_ARGV (argv);
+ argv = 0;
+ }
+
+ if (argv == 0)
+ {
+ next_command:
+#ifdef __MSDOS__
+ execute_by_shell = 0; /* in case construct_command_argv sets it */
+#endif
+ /* This line has no commands. Go to the next. */
+ if (job_next_command (child))
+ start_job_command (child);
+ else
+ {
+ /* No more commands. Make sure we're "running"; we might not be if
+ (e.g.) all commands were skipped due to -n. */
+ set_command_state (child->file, cs_running);
+ child->file->update_status = us_success;
+ notice_finished_file (child->file);
+ }
+
+ OUTPUT_UNSET();
+ return;
+ }
+
+ /* Are we going to synchronize this command's output? Do so if either we're
+ in SYNC_RECURSE mode or this command is not recursive. We'll also check
+ output_sync separately below in case it changes due to error. */
+ child->output.syncout = output_sync && (output_sync == OUTPUT_SYNC_RECURSE
+ || !(flags & COMMANDS_RECURSE));
+
+ OUTPUT_SET (&child->output);
+
+#ifndef NO_OUTPUT_SYNC
+ if (! child->output.syncout)
+ /* We don't want to sync this command: to avoid misordered
+ output ensure any already-synced content is written. */
+ output_dump (&child->output);
+#endif
+
+ /* Print the command if appropriate. */
+ if (just_print_flag || ISDB (DB_PRINT)
+ || (!(flags & COMMANDS_SILENT) && !run_silent))
+ OS (message, 0, "%s", p);
+
+ /* Tell update_goal_chain that a command has been started on behalf of
+ this target. It is important that this happens here and not in
+ reap_children (where we used to do it), because reap_children might be
+ reaping children from a different target. We want this increment to
+ guaranteedly indicate that a command was started for the dependency
+ chain (i.e., update_file recursion chain) we are processing. */
+
+ ++commands_started;
+
+ /* Optimize an empty command. People use this for timestamp rules,
+ so avoid forking a useless shell. Do this after we increment
+ commands_started so make still treats this special case as if it
+ performed some action (makes a difference as to what messages are
+ printed, etc. */
+
+#if !defined(VMS) && !defined(_AMIGA)
+ if (
+#if defined __MSDOS__ || defined (__EMX__)
+ unixy_shell /* the test is complicated and we already did it */
+#else
+ (argv[0] && is_bourne_compatible_shell (argv[0]))
+#endif
+ && (argv[1] && argv[1][0] == '-'
+ &&
+ ((argv[1][1] == 'c' && argv[1][2] == '\0')
+ ||
+ (argv[1][1] == 'e' && argv[1][2] == 'c' && argv[1][3] == '\0')))
+ && (argv[2] && argv[2][0] == ':' && argv[2][1] == '\0')
+ && argv[3] == NULL)
+ {
+ FREE_ARGV (argv);
+ goto next_command;
+ }
+#endif /* !VMS && !_AMIGA */
+
+ /* If -n was given, recurse to get the next line in the sequence. */
+
+ if (just_print_flag && !(flags & COMMANDS_RECURSE))
+ {
+ FREE_ARGV (argv);
+ goto next_command;
+ }
+
+ /* We're sure we're going to invoke a command: set up the output. */
+ output_start ();
+
+ /* Flush the output streams so they won't have things written twice. */
+
+ fflush (stdout);
+ fflush (stderr);
+
+ /* Decide whether to give this child the 'good' standard input
+ (one that points to the terminal or whatever), or the 'bad' one
+ that points to the read side of a broken pipe. */
+
+ child->good_stdin = !good_stdin_used;
+ if (child->good_stdin)
+ good_stdin_used = 1;
+
+ child->deleted = 0;
+
+#ifndef _AMIGA
+ /* Set up the environment for the child. */
+ if (child->environment == 0)
+ child->environment = target_environment (child->file);
+#endif
+
+#if !defined(__MSDOS__) && !defined(_AMIGA) && !defined(WINDOWS32)
+
+#ifndef VMS
+ /* start_waiting_job has set CHILD->remote if we can start a remote job. */
+ if (child->remote)
+ {
+ int is_remote, used_stdin;
+ pid_t id;
+ if (start_remote_job (argv, child->environment,
+ child->good_stdin ? 0 : get_bad_stdin (),
+ &is_remote, &id, &used_stdin))
+ /* Don't give up; remote execution may fail for various reasons. If
+ so, simply run the job locally. */
+ goto run_local;
+ else
+ {
+ if (child->good_stdin && !used_stdin)
+ {
+ child->good_stdin = 0;
+ good_stdin_used = 0;
+ }
+ child->remote = is_remote;
+ child->pid = id;
+ }
+ }
+ else
+#endif /* !VMS */
+ {
+ /* Fork the child process. */
+
+ char **parent_environ;
+
+ run_local:
+ block_sigs ();
+
+ child->remote = 0;
+
+#ifdef VMS
+ child->pid = child_execute_job ((struct childbase *)child, 1, argv);
+
+#else
+
+ parent_environ = environ;
+
+ jobserver_pre_child (flags & COMMANDS_RECURSE);
+
+ child->pid = child_execute_job ((struct childbase *)child,
+ child->good_stdin, argv);
+
+ environ = parent_environ; /* Restore value child may have clobbered. */
+ jobserver_post_child (flags & COMMANDS_RECURSE);
+
+#endif /* !VMS */
+ }
+
+#else /* __MSDOS__ or Amiga or WINDOWS32 */
+#ifdef __MSDOS__
+ {
+ int proc_return;
+
+ block_sigs ();
+ dos_status = 0;
+
+ /* We call 'system' to do the job of the SHELL, since stock DOS
+ shell is too dumb. Our 'system' knows how to handle long
+ command lines even if pipes/redirection is needed; it will only
+ call COMMAND.COM when its internal commands are used. */
+ if (execute_by_shell)
+ {
+ char *cmdline = argv[0];
+ /* We don't have a way to pass environment to 'system',
+ so we need to save and restore ours, sigh... */
+ char **parent_environ = environ;
+
+ environ = child->environment;
+
+ /* If we have a *real* shell, tell 'system' to call
+ it to do everything for us. */
+ if (unixy_shell)
+ {
+ /* A *real* shell on MSDOS may not support long
+ command lines the DJGPP way, so we must use 'system'. */
+ cmdline = argv[2]; /* get past "shell -c" */
+ }
+
+ dos_command_running = 1;
+ proc_return = system (cmdline);
+ environ = parent_environ;
+ execute_by_shell = 0; /* for the next time */
+ }
+ else
+ {
+ dos_command_running = 1;
+ proc_return = spawnvpe (P_WAIT, argv[0], argv, child->environment);
+ }
+
+ /* Need to unblock signals before turning off
+ dos_command_running, so that child's signals
+ will be treated as such (see fatal_error_signal). */
+ unblock_sigs ();
+ dos_command_running = 0;
+
+ /* If the child got a signal, dos_status has its
+ high 8 bits set, so be careful not to alter them. */
+ if (proc_return == -1)
+ dos_status |= 0xff;
+ else
+ dos_status |= (proc_return & 0xff);
+ ++dead_children;
+ child->pid = dos_pid++;
+ }
+#endif /* __MSDOS__ */
+#ifdef _AMIGA
+ amiga_status = MyExecute (argv);
+
+ ++dead_children;
+ child->pid = amiga_pid++;
+ if (amiga_batch_file)
+ {
+ amiga_batch_file = 0;
+ DeleteFile (amiga_bname); /* Ignore errors. */
+ }
+#endif /* Amiga */
+#ifdef WINDOWS32
+ {
+ HANDLE hPID;
+ char* arg0;
+ int outfd = FD_STDOUT;
+ int errfd = FD_STDERR;
+
+ /* make UNC paths safe for CreateProcess -- backslash format */
+ arg0 = argv[0];
+ if (arg0 && arg0[0] == '/' && arg0[1] == '/')
+ for ( ; arg0 && *arg0; arg0++)
+ if (*arg0 == '/')
+ *arg0 = '\\';
+
+ /* make sure CreateProcess() has Path it needs */
+ sync_Path_environment ();
+
+#ifndef NO_OUTPUT_SYNC
+ /* Divert child output if output_sync in use. */
+ if (child->output.syncout)
+ {
+ if (child->output.out >= 0)
+ outfd = child->output.out;
+ if (child->output.err >= 0)
+ errfd = child->output.err;
+ }
+#else
+ outfd = errfd = -1;
+#endif
+ hPID = process_easy (argv, child->environment, outfd, errfd);
+
+ if (hPID != INVALID_HANDLE_VALUE)
+ child->pid = (pid_t) hPID;
+ else
+ {
+ int i;
+ unblock_sigs ();
+ fprintf (stderr,
+ _("process_easy() failed to launch process (e=%ld)\n"),
+ process_last_err (hPID));
+ for (i = 0; argv[i]; i++)
+ fprintf (stderr, "%s ", argv[i]);
+ fprintf (stderr, _("\nCounted %d args in failed launch\n"), i);
+ child->pid = -1;
+ }
+ }
+#endif /* WINDOWS32 */
+#endif /* __MSDOS__ or Amiga or WINDOWS32 */
+
+ /* Bump the number of jobs started in this second. */
+ if (child->pid >= 0)
+ ++job_counter;
+
+ /* Set the state to running. */
+ set_command_state (child->file, cs_running);
+
+ /* Free the storage used by the child's argument list. */
+ FREE_ARGV (argv);
+
+ OUTPUT_UNSET();
+
+#undef FREE_ARGV
+}
+
+/* Try to start a child running.
+ Returns nonzero if the child was started (and maybe finished), or zero if
+ the load was too high and the child was put on the 'waiting_jobs' chain. */
+
+static int
+start_waiting_job (struct child *c)
+{
+ struct file *f = c->file;
+
+ /* If we can start a job remotely, we always want to, and don't care about
+ the local load average. We record that the job should be started
+ remotely in C->remote for start_job_command to test. */
+
+ c->remote = start_remote_job_p (1);
+
+ /* If we are running at least one job already and the load average
+ is too high, make this one wait. */
+ if (!c->remote
+ && ((job_slots_used > 0 && load_too_high ())
+#ifdef WINDOWS32
+ || process_table_full ()
+#endif
+ ))
+ {
+ /* Put this child on the chain of children waiting for the load average
+ to go down. */
+ set_command_state (f, cs_running);
+ c->next = waiting_jobs;
+ waiting_jobs = c;
+ return 0;
+ }
+
+ /* Start the first command; reap_children will run later command lines. */
+ start_job_command (c);
+
+ switch (f->command_state)
+ {
+ case cs_running:
+ c->next = children;
+ if (c->pid > 0)
+ {
+ DB (DB_JOBS, (_("Putting child %p (%s) PID %s%s on the chain.\n"),
+ c, c->file->name, pid2str (c->pid),
+ c->remote ? _(" (remote)") : ""));
+ /* One more job slot is in use. */
+ ++job_slots_used;
+ assert (c->jobslot == 0);
+ c->jobslot = 1;
+ }
+ children = c;
+ unblock_sigs ();
+ break;
+
+ case cs_not_started:
+ /* All the command lines turned out to be empty. */
+ f->update_status = us_success;
+ /* FALLTHROUGH */
+
+ case cs_finished:
+ notice_finished_file (f);
+ free_child (c);
+ break;
+
+ default:
+ assert (f->command_state == cs_finished);
+ break;
+ }
+
+ return 1;
+}
+
+/* Create a 'struct child' for FILE and start its commands running. */
+
+void
+new_job (struct file *file)
+{
+ struct commands *cmds = file->cmds;
+ struct child *c;
+ char **lines;
+ unsigned int i;
+
+ /* Let any previously decided-upon jobs that are waiting
+ for the load to go down start before this new one. */
+ start_waiting_jobs ();
+
+ /* Reap any children that might have finished recently. */
+ reap_children (0, 0);
+
+ /* Chop the commands up into lines if they aren't already. */
+ chop_commands (cmds);
+
+ /* Start the command sequence, record it in a new
+ 'struct child', and add that to the chain. */
+
+ c = xcalloc (sizeof (struct child));
+ output_init (&c->output);
+
+ c->file = file;
+ c->sh_batch_file = NULL;
+
+ /* Cache dontcare flag because file->dontcare can be changed once we
+ return. Check dontcare inheritance mechanism for details. */
+ c->dontcare = file->dontcare;
+
+ /* Start saving output in case the expansion uses $(info ...) etc. */
+ OUTPUT_SET (&c->output);
+
+ /* Expand the command lines and store the results in LINES. */
+ lines = xmalloc (cmds->ncommand_lines * sizeof (char *));
+ for (i = 0; i < cmds->ncommand_lines; ++i)
+ {
+ /* Collapse backslash-newline combinations that are inside variable
+ or function references. These are left alone by the parser so
+ that they will appear in the echoing of commands (where they look
+ nice); and collapsed by construct_command_argv when it tokenizes.
+ But letting them survive inside function invocations loses because
+ we don't want the functions to see them as part of the text. */
+
+ char *in, *out, *ref;
+
+ /* IN points to where in the line we are scanning.
+ OUT points to where in the line we are writing.
+ When we collapse a backslash-newline combination,
+ IN gets ahead of OUT. */
+
+ in = out = cmds->command_lines[i];
+ while ((ref = strchr (in, '$')) != 0)
+ {
+ ++ref; /* Move past the $. */
+
+ if (out != in)
+ /* Copy the text between the end of the last chunk
+ we processed (where IN points) and the new chunk
+ we are about to process (where REF points). */
+ memmove (out, in, ref - in);
+
+ /* Move both pointers past the boring stuff. */
+ out += ref - in;
+ in = ref;
+
+ if (*ref == '(' || *ref == '{')
+ {
+ char openparen = *ref;
+ char closeparen = openparen == '(' ? ')' : '}';
+ char *outref;
+ int count;
+ char *p;
+
+ *out++ = *in++; /* Copy OPENPAREN. */
+ outref = out;
+ /* IN now points past the opening paren or brace.
+ Count parens or braces until it is matched. */
+ count = 0;
+ while (*in != '\0')
+ {
+ if (*in == closeparen && --count < 0)
+ break;
+ else if (*in == '\\' && in[1] == '\n')
+ {
+ /* We have found a backslash-newline inside a
+ variable or function reference. Eat it and
+ any following whitespace. */
+
+ int quoted = 0;
+ for (p = in - 1; p > ref && *p == '\\'; --p)
+ quoted = !quoted;
+
+ if (quoted)
+ /* There were two or more backslashes, so this is
+ not really a continuation line. We don't collapse
+ the quoting backslashes here as is done in
+ collapse_continuations, because the line will
+ be collapsed again after expansion. */
+ *out++ = *in++;
+ else
+ {
+ /* Skip the backslash, newline, and whitespace. */
+ in += 2;
+ NEXT_TOKEN (in);
+
+ /* Discard any preceding whitespace that has
+ already been written to the output. */
+ while (out > outref && ISBLANK (out[-1]))
+ --out;
+
+ /* Replace it all with a single space. */
+ *out++ = ' ';
+ }
+ }
+ else
+ {
+ if (*in == openparen)
+ ++count;
+
+ *out++ = *in++;
+ }
+ }
+ }
+ }
+
+ /* There are no more references in this line to worry about.
+ Copy the remaining uninteresting text to the output. */
+ if (out != in)
+ memmove (out, in, strlen (in) + 1);
+
+ /* Finally, expand the line. */
+ cmds->fileinfo.offset = i;
+ lines[i] = allocated_variable_expand_for_file (cmds->command_lines[i],
+ file);
+ }
+
+ cmds->fileinfo.offset = 0;
+ c->command_lines = lines;
+
+ /* Fetch the first command line to be run. */
+ job_next_command (c);
+
+ /* Wait for a job slot to be freed up. If we allow an infinite number
+ don't bother; also job_slots will == 0 if we're using the jobserver. */
+
+ if (job_slots != 0)
+ while (job_slots_used == job_slots)
+ reap_children (1, 0);
+
+#ifdef MAKE_JOBSERVER
+ /* If we are controlling multiple jobs make sure we have a token before
+ starting the child. */
+
+ /* This can be inefficient. There's a decent chance that this job won't
+ actually have to run any subprocesses: the command script may be empty
+ or otherwise optimized away. It would be nice if we could defer
+ obtaining a token until just before we need it, in start_job_command.
+ To do that we'd need to keep track of whether we'd already obtained a
+ token (since start_job_command is called for each line of the job, not
+ just once). Also more thought needs to go into the entire algorithm;
+ this is where the old parallel job code waits, so... */
+
+ else if (jobserver_enabled ())
+ while (1)
+ {
+ int got_token;
+
+ DB (DB_JOBS, ("Need a job token; we %shave children\n",
+ children ? "" : "don't "));
+
+ /* If we don't already have a job started, use our "free" token. */
+ if (!jobserver_tokens)
+ break;
+
+ /* Prepare for jobserver token acquisition. */
+ jobserver_pre_acquire ();
+
+ /* Reap anything that's currently waiting. */
+ reap_children (0, 0);
+
+ /* Kick off any jobs we have waiting for an opportunity that
+ can run now (i.e., waiting for load). */
+ start_waiting_jobs ();
+
+ /* If our "free" slot is available, use it; we don't need a token. */
+ if (!jobserver_tokens)
+ break;
+
+ /* There must be at least one child already, or we have no business
+ waiting for a token. */
+ if (!children)
+ O (fatal, NILF, "INTERNAL: no children as we go to sleep on read\n");
+
+ /* Get a token. */
+ got_token = jobserver_acquire (waiting_jobs != NULL);
+
+ /* If we got one, we're done here. */
+ if (got_token == 1)
+ {
+ DB (DB_JOBS, (_("Obtained token for child %p (%s).\n"),
+ c, c->file->name));
+ break;
+ }
+ }
+#endif
+
+ ++jobserver_tokens;
+
+ /* Trace the build.
+ Use message here so that changes to working directories are logged. */
+ if (ISDB (DB_WHY))
+ {
+ char *newer = allocated_variable_expand_for_file ("$?", c->file);
+ const char *nm;
+
+ if (! cmds->fileinfo.filenm)
+ nm = _("<builtin>");
+ else
+ {
+ char *n = alloca (strlen (cmds->fileinfo.filenm) + 1 + 11 + 1);
+ sprintf (n, "%s:%lu", cmds->fileinfo.filenm, cmds->fileinfo.lineno);
+ nm = n;
+ }
+
+ OSSS (message, 0,
+ _("%s: update target '%s' due to: %s"), nm, c->file->name,
+ newer[0] == '\0' ? _("target does not exist") : newer);
+
+ free (newer);
+ }
+
+ /* The job is now primed. Start it running.
+ (This will notice if there is in fact no recipe.) */
+ start_waiting_job (c);
+
+ if (job_slots == 1 || not_parallel)
+ /* Since there is only one job slot, make things run linearly.
+ Wait for the child to die, setting the state to 'cs_finished'. */
+ while (file->command_state == cs_running)
+ reap_children (1, 0);
+
+ OUTPUT_UNSET ();
+ return;
+}
+
+/* Move CHILD's pointers to the next command for it to execute.
+ Returns nonzero if there is another command. */
+
+static int
+job_next_command (struct child *child)
+{
+ while (child->command_ptr == 0 || *child->command_ptr == '\0')
+ {
+ /* There are no more lines in the expansion of this line. */
+ if (child->command_line == child->file->cmds->ncommand_lines)
+ {
+ /* There are no more lines to be expanded. */
+ child->command_ptr = 0;
+ child->file->cmds->fileinfo.offset = 0;
+ return 0;
+ }
+ else
+ /* Get the next line to run. */
+ child->command_ptr = child->command_lines[child->command_line++];
+ }
+
+ child->file->cmds->fileinfo.offset = child->command_line - 1;
+ return 1;
+}
+
+/* Determine if the load average on the system is too high to start a new job.
+
+ On systems which provide /proc/loadavg (e.g., Linux), we use an idea
+ provided by Sven C. Dack <sven.c.dack@sky.com>: retrieve the current number
+ of processes the kernel is running and, if it's greater than the requested
+ load we don't allow another job to start. We allow a job to start with
+ equal processes since one of those will be for make itself, which will then
+ pause waiting for jobs to clear.
+
+ Otherwise, we obtain the system load average and compare that.
+
+ The system load average is only recomputed once every N (N>=1) seconds.
+ However, a very parallel make can easily start tens or even hundreds of
+ jobs in a second, which brings the system to its knees for a while until
+ that first batch of jobs clears out.
+
+ To avoid this we use a weighted algorithm to try to account for jobs which
+ have been started since the last second, and guess what the load average
+ would be now if it were computed.
+
+ This algorithm was provided by Thomas Riedl <thomas.riedl@siemens.com>,
+ based on load average being recomputed once per second, which is
+ (apparently) how Solaris operates. Linux recomputes only once every 5
+ seconds, but Linux is handled by the /proc/loadavg algorithm above.
+
+ Thomas writes:
+
+! calculate something load-oid and add to the observed sys.load,
+! so that latter can catch up:
+! - every job started increases jobctr;
+! - every dying job decreases a positive jobctr;
+! - the jobctr value gets zeroed every change of seconds,
+! after its value*weight_b is stored into the 'backlog' value last_sec
+! - weight_a times the sum of jobctr and last_sec gets
+! added to the observed sys.load.
+!
+! The two weights have been tried out on 24 and 48 proc. Sun Solaris-9
+! machines, using a several-thousand-jobs-mix of cpp, cc, cxx and smallish
+! sub-shelled commands (rm, echo, sed...) for tests.
+! lowering the 'direct influence' factor weight_a (e.g. to 0.1)
+! resulted in significant excession of the load limit, raising it
+! (e.g. to 0.5) took bad to small, fast-executing jobs and didn't
+! reach the limit in most test cases.
+!
+! lowering the 'history influence' weight_b (e.g. to 0.1) resulted in
+! exceeding the limit for longer-running stuff (compile jobs in
+! the .5 to 1.5 sec. range),raising it (e.g. to 0.5) overrepresented
+! small jobs' effects.
+
+ */
+
+#define LOAD_WEIGHT_A 0.25
+#define LOAD_WEIGHT_B 0.25
+
+static int
+load_too_high (void)
+{
+#if defined(__MSDOS__) || defined(VMS) || defined(_AMIGA) || defined(__riscos__)
+ return 1;
+#else
+ static double last_sec;
+ static time_t last_now;
+
+ /* This is disabled by default for now, because it will behave badly if the
+ user gives a value > the number of cores; in that situation the load will
+ never be exceeded, this function always returns false, and we'll start
+ all the jobs. Also, it's not quite right to limit jobs to the number of
+ cores not busy since a job takes some time to start etc. Maybe that's
+ OK, I'm not sure exactly how to handle that, but for sure we need to
+ clamp this value at the number of cores before this can be enabled.
+ */
+#define PROC_FD_INIT -1
+ static int proc_fd = PROC_FD_INIT;
+
+ double load, guess;
+ time_t now;
+
+#ifdef WINDOWS32
+ /* sub_proc.c is limited in the number of objects it can wait for. */
+ if (process_table_full ())
+ return 1;
+#endif
+
+ if (max_load_average < 0)
+ return 0;
+
+ /* If we haven't tried to open /proc/loadavg, try now. */
+#define LOADAVG "/proc/loadavg"
+ if (proc_fd == -2)
+ {
+ EINTRLOOP (proc_fd, open (LOADAVG, O_RDONLY));
+ if (proc_fd < 0)
+ DB (DB_JOBS, ("Using system load detection method.\n"));
+ else
+ {
+ DB (DB_JOBS, ("Using " LOADAVG " load detection method.\n"));
+ fd_noinherit (proc_fd);
+ }
+ }
+
+ /* Try to read /proc/loadavg if we managed to open it. */
+ if (proc_fd >= 0)
+ {
+ int r;
+
+ EINTRLOOP (r, lseek (proc_fd, 0, SEEK_SET));
+ if (r >= 0)
+ {
+#define PROC_LOADAVG_SIZE 64
+ char avg[PROC_LOADAVG_SIZE+1];
+
+ EINTRLOOP (r, read (proc_fd, avg, PROC_LOADAVG_SIZE));
+ if (r >= 0)
+ {
+ const char *p;
+
+ /* The syntax of /proc/loadavg is:
+ <1m> <5m> <15m> <running>/<total> <pid>
+ The load is considered too high if there are more jobs
+ running than the requested average. */
+
+ avg[r] = '\0';
+ p = strchr (avg, ' ');
+ if (p)
+ p = strchr (p+1, ' ');
+ if (p)
+ p = strchr (p+1, ' ');
+
+ if (p && ISDIGIT(p[1]))
+ {
+ int cnt = atoi (p+1);
+ DB (DB_JOBS, ("Running: system = %d / make = %u (max requested = %f)\n",
+ cnt, job_slots_used, max_load_average));
+ return (double)cnt > max_load_average;
+ }
+
+ DB (DB_JOBS, ("Failed to parse " LOADAVG ": %s\n", avg));
+ }
+ }
+
+ /* If we got here, something went wrong. Give up on this method. */
+ if (r < 0)
+ DB (DB_JOBS, ("Failed to read " LOADAVG ": %s\n", strerror (errno)));
+
+ close (proc_fd);
+ proc_fd = -1;
+ }
+
+ /* Find the real system load average. */
+ make_access ();
+ if (getloadavg (&load, 1) != 1)
+ {
+ static int lossage = -1;
+ /* Complain only once for the same error. */
+ if (lossage == -1 || errno != lossage)
+ {
+ if (errno == 0)
+ /* An errno value of zero means getloadavg is just unsupported. */
+ O (error, NILF,
+ _("cannot enforce load limits on this operating system"));
+ else
+ perror_with_name (_("cannot enforce load limit: "), "getloadavg");
+ }
+ lossage = errno;
+ load = 0;
+ }
+ user_access ();
+
+ /* If we're in a new second zero the counter and correct the backlog
+ value. Only keep the backlog for one extra second; after that it's 0. */
+ now = time (NULL);
+ if (last_now < now)
+ {
+ if (last_now == now - 1)
+ last_sec = LOAD_WEIGHT_B * job_counter;
+ else
+ last_sec = 0.0;
+
+ job_counter = 0;
+ last_now = now;
+ }
+
+ /* Try to guess what the load would be right now. */
+ guess = load + (LOAD_WEIGHT_A * (job_counter + last_sec));
+
+ DB (DB_JOBS, ("Estimated system load = %f (actual = %f) (max requested = %f)\n",
+ guess, load, max_load_average));
+
+ return guess >= max_load_average;
+#endif
+}
+
+/* Start jobs that are waiting for the load to be lower. */
+
+void
+start_waiting_jobs (void)
+{
+ struct child *job;
+
+ if (waiting_jobs == 0)
+ return;
+
+ do
+ {
+ /* Check for recently deceased descendants. */
+ reap_children (0, 0);
+
+ /* Take a job off the waiting list. */
+ job = waiting_jobs;
+ waiting_jobs = job->next;
+
+ /* Try to start that job. We break out of the loop as soon
+ as start_waiting_job puts one back on the waiting list. */
+ }
+ while (start_waiting_job (job) && waiting_jobs != 0);
+
+ return;
+}
+
+#ifndef WINDOWS32
+
+/* EMX: Start a child process. This function returns the new pid. */
+# if defined __EMX__
+pid_t
+child_execute_job (struct childbase *child, int good_stdin, char **argv)
+{
+ pid_t pid;
+ int fdin = good_stdin ? FD_STDIN : get_bad_stdin ();
+ int fdout = FD_STDOUT;
+ int fderr = FD_STDERR;
+ int save_fdin = -1;
+ int save_fdout = -1;
+ int save_fderr = -1;
+
+ /* Divert child output if we want to capture output. */
+ if (child->output.syncout)
+ {
+ if (child->output.out >= 0)
+ fdout = child->output.out;
+ if (child->output.err >= 0)
+ fderr = child->output.err;
+ }
+
+ /* For each FD which needs to be redirected first make a dup of the standard
+ FD to save and mark it close on exec so our child won't see it. Then
+ dup2() the standard FD to the redirect FD, and also mark the redirect FD
+ as close on exec. */
+ if (fdin != FD_STDIN)
+ {
+ save_fdin = dup (FD_STDIN);
+ if (save_fdin < 0)
+ O (fatal, NILF, _("no more file handles: could not duplicate stdin\n"));
+ fd_noinherit (save_fdin);
+
+ dup2 (fdin, FD_STDIN);
+ fd_noinherit (fdin);
+ }
+
+ if (fdout != FD_STDOUT)
+ {
+ save_fdout = dup (FD_STDOUT);
+ if (save_fdout < 0)
+ O (fatal, NILF,
+ _("no more file handles: could not duplicate stdout\n"));
+ fd_noinherit (save_fdout);
+
+ dup2 (fdout, FD_STDOUT);
+ fd_noinherit (fdout);
+ }
+
+ if (fderr != FD_STDERR)
+ {
+ if (fderr != fdout)
+ {
+ save_fderr = dup (FD_STDERR);
+ if (save_fderr < 0)
+ O (fatal, NILF,
+ _("no more file handles: could not duplicate stderr\n"));
+ fd_noinherit (save_fderr);
+ }
+
+ dup2 (fderr, FD_STDERR);
+ fd_noinherit (fderr);
+ }
+
+ /* Run the command. */
+ pid = exec_command (argv, child->environment);
+
+ /* Restore stdout/stdin/stderr of the parent and close temporary FDs. */
+ if (save_fdin >= 0)
+ {
+ if (dup2 (save_fdin, FD_STDIN) != FD_STDIN)
+ O (fatal, NILF, _("Could not restore stdin\n"));
+ else
+ close (save_fdin);
+ }
+
+ if (save_fdout >= 0)
+ {
+ if (dup2 (save_fdout, FD_STDOUT) != FD_STDOUT)
+ O (fatal, NILF, _("Could not restore stdout\n"));
+ else
+ close (save_fdout);
+ }
+
+ if (save_fderr >= 0)
+ {
+ if (dup2 (save_fderr, FD_STDERR) != FD_STDERR)
+ O (fatal, NILF, _("Could not restore stderr\n"));
+ else
+ close (save_fderr);
+ }
+
+ if (pid < 0)
+ OSS (error, NILF, "%s: %s", argv[0], strerror (errno));
+
+ return pid;
+}
+
+#elif !defined (_AMIGA) && !defined (__MSDOS__) && !defined (VMS)
+
+/* POSIX:
+ Create a child process executing the command in ARGV.
+ Returns the PID or -1. */
+pid_t
+child_execute_job (struct childbase *child, int good_stdin, char **argv)
+{
+ const int fdin = good_stdin ? FD_STDIN : get_bad_stdin ();
+ int fdout = FD_STDOUT;
+ int fderr = FD_STDERR;
+ pid_t pid;
+ int r;
+#if defined(USE_POSIX_SPAWN)
+ char *cmd;
+ posix_spawnattr_t attr;
+ posix_spawn_file_actions_t fa;
+ short flags = 0;
+#endif
+
+ /* Divert child output if we want to capture it. */
+ if (child->output.syncout)
+ {
+ if (child->output.out >= 0)
+ fdout = child->output.out;
+ if (child->output.err >= 0)
+ fderr = child->output.err;
+ }
+
+#if !defined(USE_POSIX_SPAWN)
+
+ pid = vfork();
+ if (pid != 0)
+ return pid;
+
+ /* We are the child. */
+ unblock_all_sigs ();
+
+#ifdef SET_STACK_SIZE
+ /* Reset limits, if necessary. */
+ if (stack_limit.rlim_cur)
+ setrlimit (RLIMIT_STACK, &stack_limit);
+#endif
+
+ /* For any redirected FD, dup2() it to the standard FD.
+ They are all marked close-on-exec already. */
+ if (fdin >= 0 && fdin != FD_STDIN)
+ EINTRLOOP (r, dup2 (fdin, FD_STDIN));
+ if (fdout != FD_STDOUT)
+ EINTRLOOP (r, dup2 (fdout, FD_STDOUT));
+ if (fderr != FD_STDERR)
+ EINTRLOOP (r, dup2 (fderr, FD_STDERR));
+
+ /* Run the command. */
+ exec_command (argv, child->environment);
+
+#else /* USE_POSIX_SPAWN */
+
+ if ((r = posix_spawnattr_init (&attr)) != 0)
+ goto done;
+
+ if ((r = posix_spawn_file_actions_init (&fa)) != 0)
+ {
+ posix_spawnattr_destroy (&attr);
+ goto done;
+ }
+
+ /* Unblock all signals. */
+#ifdef HAVE_POSIX_SPAWNATTR_SETSIGMASK
+ {
+ sigset_t mask;
+ sigemptyset (&mask);
+ r = posix_spawnattr_setsigmask (&attr, &mask);
+ if (r != 0)
+ goto cleanup;
+ flags |= POSIX_SPAWN_SETSIGMASK;
+ }
+#endif /* have posix_spawnattr_setsigmask() */
+
+ /* USEVFORK can give significant speedup on systems where it's available. */
+#ifdef POSIX_SPAWN_USEVFORK
+ flags |= POSIX_SPAWN_USEVFORK;
+#endif
+
+ /* For any redirected FD, dup2() it to the standard FD.
+ They are all marked close-on-exec already. */
+ if (fdin >= 0 && fdin != FD_STDIN)
+ if ((r = posix_spawn_file_actions_adddup2 (&fa, fdin, FD_STDIN)) != 0)
+ goto cleanup;
+ if (fdout != FD_STDOUT)
+ if ((r = posix_spawn_file_actions_adddup2 (&fa, fdout, FD_STDOUT)) != 0)
+ goto cleanup;
+ if (fderr != FD_STDERR)
+ if ((r = posix_spawn_file_actions_adddup2 (&fa, fderr, FD_STDERR)) != 0)
+ goto cleanup;
+
+ /* Be the user, permanently. */
+ flags |= POSIX_SPAWN_RESETIDS;
+
+ /* Apply the spawn flags. */
+ if ((r = posix_spawnattr_setflags (&attr, flags)) != 0)
+ goto cleanup;
+
+ /* Look up the program on the child's PATH, if needed. */
+ {
+ const char *p = NULL;
+ char **pp;
+
+ for (pp = child->environment; *pp != NULL; ++pp)
+ if ((*pp)[0] == 'P' && (*pp)[1] == 'A' && (*pp)[2] == 'T'
+ && (*pp)[3] == 'H' &&(*pp)[4] == '=')
+ {
+ p = (*pp) + 5;
+ break;
+ }
+
+ /* execvp() will use a default PATH if none is set; emulate that. */
+ if (p == NULL)
+ {
+ size_t l = confstr (_CS_PATH, NULL, 0);
+ if (l)
+ {
+ char *dp = alloca (l);
+ confstr (_CS_PATH, dp, l);
+ p = dp;
+ }
+ }
+
+ cmd = (char *)find_in_given_path (argv[0], p, NULL, 0);
+ }
+
+ if (!cmd)
+ {
+ r = errno;
+ goto cleanup;
+ }
+
+ /* Start the program. */
+ while ((r = posix_spawn (&pid, cmd, &fa, &attr, argv,
+ child->environment)) == EINTR)
+ ;
+
+ /* posix_spawn() doesn't provide sh fallback like exec() does; implement
+ it here. POSIX doesn't specify the path to sh so use the default. */
+
+ if (r == ENOEXEC)
+ {
+ char **nargv;
+ char **pp;
+ size_t l = 0;
+
+ for (pp = argv; *pp != NULL; ++pp)
+ ++l;
+
+ nargv = xmalloc (sizeof (char *) * (l + 3));
+ nargv[0] = (char *)default_shell;
+ nargv[1] = cmd;
+ memcpy (&nargv[2], &argv[1], sizeof (char *) * l);
+
+ while ((r = posix_spawn (&pid, nargv[0], &fa, &attr, nargv,
+ child->environment)) == EINTR)
+ ;
+
+ free (nargv);
+ }
+
+ if (r == 0)
+ {
+ /* Spawn succeeded but may fail later: remember the command. */
+ free (child->cmd_name);
+ if (cmd != argv[0])
+ child->cmd_name = cmd;
+ else
+ child->cmd_name = xstrdup(cmd);
+ }
+
+ cleanup:
+ posix_spawn_file_actions_destroy (&fa);
+ posix_spawnattr_destroy (&attr);
+
+ done:
+ if (r != 0)
+ pid = -1;
+
+#endif /* USE_POSIX_SPAWN */
+
+ if (pid < 0)
+ OSS (error, NILF, "%s: %s", argv[0], strerror (r));
+
+ return pid;
+}
+#endif /* !AMIGA && !__MSDOS__ && !VMS */
+#endif /* !WINDOWS32 */
+
+#ifndef _AMIGA
+/* Replace the current process with one running the command in ARGV,
+ with environment ENVP. This function does not return. */
+
+/* EMX: This function returns the pid of the child process. */
+# ifdef __EMX__
+pid_t
+# else
+void
+# endif
+exec_command (char **argv, char **envp)
+{
+#ifdef VMS
+ /* to work around a problem with signals and execve: ignore them */
+#ifdef SIGCHLD
+ signal (SIGCHLD,SIG_IGN);
+#endif
+ /* Run the program. */
+ execve (argv[0], argv, envp);
+ OSS (error, NILF, "%s: %s", argv[0], strerror (errno));
+ _exit (EXIT_FAILURE);
+#else
+#ifdef WINDOWS32
+ HANDLE hPID;
+ HANDLE hWaitPID;
+ int exit_code = EXIT_FAILURE;
+
+ /* make sure CreateProcess() has Path it needs */
+ sync_Path_environment ();
+
+ /* launch command */
+ hPID = process_easy (argv, envp, -1, -1);
+
+ /* make sure launch ok */
+ if (hPID == INVALID_HANDLE_VALUE)
+ {
+ int i;
+ fprintf (stderr, _("process_easy() failed to launch process (e=%ld)\n"),
+ process_last_err (hPID));
+ for (i = 0; argv[i]; i++)
+ fprintf (stderr, "%s ", argv[i]);
+ fprintf (stderr, _("\nCounted %d args in failed launch\n"), i);
+ exit (EXIT_FAILURE);
+ }
+
+ /* wait and reap last child */
+ hWaitPID = process_wait_for_any (1, 0);
+ while (hWaitPID)
+ {
+ /* was an error found on this process? */
+ int err = process_last_err (hWaitPID);
+
+ /* get exit data */
+ exit_code = process_exit_code (hWaitPID);
+
+ if (err)
+ fprintf (stderr, "make (e=%d, rc=%d): %s",
+ err, exit_code, map_windows32_error_to_string (err));
+
+ /* cleanup process */
+ process_cleanup (hWaitPID);
+
+ /* expect to find only last pid, warn about other pids reaped */
+ if (hWaitPID == hPID)
+ break;
+ else
+ {
+ char *pidstr = xstrdup (pid2str ((pid_t)hWaitPID));
+
+ fprintf (stderr,
+ _("make reaped child pid %s, still waiting for pid %s\n"),
+ pidstr, pid2str ((pid_t)hPID));
+ free (pidstr);
+ }
+ }
+
+ /* return child's exit code as our exit code */
+ exit (exit_code);
+
+#else /* !WINDOWS32 */
+
+# ifdef __EMX__
+ pid_t pid;
+# endif
+
+ /* Be the user, permanently. */
+ child_access ();
+
+# ifdef __EMX__
+ /* Run the program. */
+ pid = spawnvpe (P_NOWAIT, argv[0], argv, envp);
+ if (pid >= 0)
+ return pid;
+
+ /* the file might have a strange shell extension */
+ if (errno == ENOENT)
+ errno = ENOEXEC;
+
+# else
+ /* Run the program. */
+ environ = envp;
+ execvp (argv[0], argv);
+
+# endif /* !__EMX__ */
+
+ switch (errno)
+ {
+ case ENOENT:
+ OSS (error, NILF, "%s: %s", argv[0], strerror (errno));
+ break;
+ case ENOEXEC:
+ {
+ /* The file was not a program. Try it as a shell script. */
+ const char *shell;
+ char **new_argv;
+ int argc;
+ int i=1;
+
+# ifdef __EMX__
+ /* Do not use $SHELL from the environment */
+ struct variable *p = lookup_variable ("SHELL", 5);
+ if (p)
+ shell = p->value;
+ else
+ shell = 0;
+# else
+ shell = getenv ("SHELL");
+# endif
+ if (shell == 0)
+ shell = default_shell;
+
+ argc = 1;
+ while (argv[argc] != 0)
+ ++argc;
+
+# ifdef __EMX__
+ if (!unixy_shell)
+ ++argc;
+# endif
+
+ new_argv = alloca ((1 + argc + 1) * sizeof (char *));
+ new_argv[0] = (char *)shell;
+
+# ifdef __EMX__
+ if (!unixy_shell)
+ {
+ new_argv[1] = "/c";
+ ++i;
+ --argc;
+ }
+# endif
+
+ new_argv[i] = argv[0];
+ while (argc > 0)
+ {
+ new_argv[i + argc] = argv[argc];
+ --argc;
+ }
+
+# ifdef __EMX__
+ pid = spawnvpe (P_NOWAIT, shell, new_argv, envp);
+ if (pid >= 0)
+ break;
+# else
+ execvp (shell, new_argv);
+# endif
+ OSS (error, NILF, "%s: %s", new_argv[0], strerror (errno));
+ break;
+ }
+
+# ifdef __EMX__
+ case EINVAL:
+ /* this nasty error was driving me nuts :-( */
+ O (error, NILF, _("spawnvpe: environment space might be exhausted"));
+ /* FALLTHROUGH */
+# endif
+
+ default:
+ OSS (error, NILF, "%s: %s", argv[0], strerror (errno));
+ break;
+ }
+
+# ifdef __EMX__
+ return pid;
+# else
+ _exit (127);
+# endif
+#endif /* !WINDOWS32 */
+#endif /* !VMS */
+}
+#else /* On Amiga */
+void
+exec_command (char **argv)
+{
+ MyExecute (argv);
+}
+
+void clean_tmp (void)
+{
+ DeleteFile (amiga_bname);
+}
+
+#endif /* On Amiga */
+
+#ifndef VMS
+/* Figure out the argument list necessary to run LINE as a command. Try to
+ avoid using a shell. This routine handles only ' quoting, and " quoting
+ when no backslash, $ or ' characters are seen in the quotes. Starting
+ quotes may be escaped with a backslash. If any of the characters in
+ sh_chars is seen, or any of the builtin commands listed in sh_cmds
+ is the first word of a line, the shell is used.
+
+ If RESTP is not NULL, *RESTP is set to point to the first newline in LINE.
+ If *RESTP is NULL, newlines will be ignored.
+
+ SHELL is the shell to use, or nil to use the default shell.
+ IFS is the value of $IFS, or nil (meaning the default).
+
+ FLAGS is the value of lines_flags for this command line. It is
+ used in the WINDOWS32 port to check whether + or $(MAKE) were found
+ in this command line, in which case the effect of just_print_flag
+ is overridden. */
+
+static char **
+construct_command_argv_internal (char *line, char **restp, const char *shell,
+ const char *shellflags, const char *ifs,
+ int flags, char **batch_filename UNUSED)
+{
+#ifdef __MSDOS__
+ /* MSDOS supports both the stock DOS shell and ports of Unixy shells.
+ We call 'system' for anything that requires ''slow'' processing,
+ because DOS shells are too dumb. When $SHELL points to a real
+ (unix-style) shell, 'system' just calls it to do everything. When
+ $SHELL points to a DOS shell, 'system' does most of the work
+ internally, calling the shell only for its internal commands.
+ However, it looks on the $PATH first, so you can e.g. have an
+ external command named 'mkdir'.
+
+ Since we call 'system', certain characters and commands below are
+ actually not specific to COMMAND.COM, but to the DJGPP implementation
+ of 'system'. In particular:
+
+ The shell wildcard characters are in DOS_CHARS because they will
+ not be expanded if we call the child via 'spawnXX'.
+
+ The ';' is in DOS_CHARS, because our 'system' knows how to run
+ multiple commands on a single line.
+
+ DOS_CHARS also include characters special to 4DOS/NDOS, so we
+ won't have to tell one from another and have one more set of
+ commands and special characters. */
+ static const char *sh_chars_dos = "*?[];|<>%^&()";
+ static const char *sh_cmds_dos[] =
+ { "break", "call", "cd", "chcp", "chdir", "cls", "copy", "ctty", "date",
+ "del", "dir", "echo", "erase", "exit", "for", "goto", "if", "md",
+ "mkdir", "path", "pause", "prompt", "rd", "rmdir", "rem", "ren",
+ "rename", "set", "shift", "time", "type", "ver", "verify", "vol", ":",
+ 0 };
+
+ static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^";
+ static const char *sh_cmds_sh[] =
+ { "cd", "echo", "eval", "exec", "exit", "login", "logout", "set", "umask",
+ "wait", "while", "for", "case", "if", ":", ".", "break", "continue",
+ "export", "read", "readonly", "shift", "times", "trap", "switch",
+ "unset", "ulimit", "command", 0 };
+
+ const char *sh_chars;
+ const char **sh_cmds;
+
+#elif defined (__EMX__)
+ static const char *sh_chars_dos = "*?[];|<>%^&()";
+ static const char *sh_cmds_dos[] =
+ { "break", "call", "cd", "chcp", "chdir", "cls", "copy", "ctty", "date",
+ "del", "dir", "echo", "erase", "exit", "for", "goto", "if", "md",
+ "mkdir", "path", "pause", "prompt", "rd", "rmdir", "rem", "ren",
+ "rename", "set", "shift", "time", "type", "ver", "verify", "vol", ":",
+ 0 };
+
+ static const char *sh_chars_os2 = "*?[];|<>%^()\"'&";
+ static const char *sh_cmds_os2[] =
+ { "call", "cd", "chcp", "chdir", "cls", "copy", "date", "del", "detach",
+ "dir", "echo", "endlocal", "erase", "exit", "for", "goto", "if", "keys",
+ "md", "mkdir", "move", "path", "pause", "prompt", "rd", "rem", "ren",
+ "rename", "rmdir", "set", "setlocal", "shift", "start", "time", "type",
+ "ver", "verify", "vol", ":", 0 };
+
+ static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^~'";
+ static const char *sh_cmds_sh[] =
+ { "echo", "cd", "eval", "exec", "exit", "login", "logout", "set", "umask",
+ "wait", "while", "for", "case", "if", ":", ".", "break", "continue",
+ "export", "read", "readonly", "shift", "times", "trap", "switch",
+ "unset", "command", 0 };
+
+ const char *sh_chars;
+ const char **sh_cmds;
+
+#elif defined (_AMIGA)
+ static const char *sh_chars = "#;\"|<>()?*$`";
+ static const char *sh_cmds[] =
+ { "cd", "eval", "if", "delete", "echo", "copy", "rename", "set", "setenv",
+ "date", "makedir", "skip", "else", "endif", "path", "prompt", "unset",
+ "unsetenv", "version", "command", 0 };
+
+#elif defined (WINDOWS32)
+ /* We used to have a double quote (") in sh_chars_dos[] below, but
+ that caused any command line with quoted file names be run
+ through a temporary batch file, which introduces command-line
+ limit of 4K characters imposed by cmd.exe. Since CreateProcess
+ can handle quoted file names just fine, removing the quote lifts
+ the limit from a very frequent use case, because using quoted
+ file names is commonplace on MS-Windows. */
+ static const char *sh_chars_dos = "|&<>";
+ static const char *sh_cmds_dos[] =
+ { "assoc", "break", "call", "cd", "chcp", "chdir", "cls", "color", "copy",
+ "ctty", "date", "del", "dir", "echo", "echo.", "endlocal", "erase",
+ "exit", "for", "ftype", "goto", "if", "if", "md", "mkdir", "move",
+ "path", "pause", "prompt", "rd", "rem", "ren", "rename", "rmdir",
+ "set", "setlocal", "shift", "time", "title", "type", "ver", "verify",
+ "vol", ":", 0 };
+
+ static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^";
+ static const char *sh_cmds_sh[] =
+ { "cd", "eval", "exec", "exit", "login", "logout", "set", "umask", "wait",
+ "while", "for", "case", "if", ":", ".", "break", "continue", "export",
+ "read", "readonly", "shift", "times", "trap", "switch", "test", "command",
+#ifdef BATCH_MODE_ONLY_SHELL
+ "echo",
+#endif
+ 0 };
+
+ const char *sh_chars;
+ const char **sh_cmds;
+#elif defined(__riscos__)
+ static const char *sh_chars = "";
+ static const char *sh_cmds[] = { 0 };
+#else /* must be UNIX-ish */
+ static const char *sh_chars = "#;\"*?[]&|<>(){}$`^~!";
+ static const char *sh_cmds[] =
+ { ".", ":", "alias", "bg", "break", "case", "cd", "command", "continue",
+ "eval", "exec", "exit", "export", "fc", "fg", "for", "getopts", "hash",
+ "if", "jobs", "login", "logout", "read", "readonly", "return", "set",
+ "shift", "test", "times", "trap", "type", "ulimit", "umask", "unalias",
+ "unset", "wait", "while", 0 };
+
+# ifdef HAVE_DOS_PATHS
+ /* This is required if the MSYS/Cygwin ports (which do not define
+ WINDOWS32) are compiled with HAVE_DOS_PATHS defined, which uses
+ sh_chars_sh directly (see below). The value must be identical
+ to that of sh_chars immediately above. */
+ static const char *sh_chars_sh = "#;\"*?[]&|<>(){}$`^~!";
+# endif /* HAVE_DOS_PATHS */
+#endif
+ size_t i;
+ char *p;
+#ifndef NDEBUG
+ char *end;
+#endif
+ char *ap;
+ const char *cap;
+ const char *cp;
+ int instring, word_has_equals, seen_nonequals, last_argument_was_empty;
+ char **new_argv = 0;
+ char *argstr = 0;
+#ifdef WINDOWS32
+ int slow_flag = 0;
+
+ if (!unixy_shell)
+ {
+ sh_cmds = sh_cmds_dos;
+ sh_chars = sh_chars_dos;
+ }
+ else
+ {
+ sh_cmds = sh_cmds_sh;
+ sh_chars = sh_chars_sh;
+ }
+#endif /* WINDOWS32 */
+
+ if (restp != NULL)
+ *restp = NULL;
+
+ /* Make sure not to bother processing an empty line but stop at newline. */
+ while (ISBLANK (*line))
+ ++line;
+ if (*line == '\0')
+ return 0;
+
+ if (shellflags == 0)
+ shellflags = posix_pedantic ? "-ec" : "-c";
+
+ /* See if it is safe to parse commands internally. */
+ if (shell == 0)
+ shell = default_shell;
+#ifdef WINDOWS32
+ else if (strcmp (shell, default_shell))
+ {
+ char *s1 = _fullpath (NULL, shell, 0);
+ char *s2 = _fullpath (NULL, default_shell, 0);
+
+ slow_flag = strcmp ((s1 ? s1 : ""), (s2 ? s2 : ""));
+
+ free (s1);
+ free (s2);
+ }
+ if (slow_flag)
+ goto slow;
+#else /* not WINDOWS32 */
+#if defined (__MSDOS__) || defined (__EMX__)
+ else if (strcasecmp (shell, default_shell))
+ {
+ extern int _is_unixy_shell (const char *_path);
+
+ DB (DB_BASIC, (_("$SHELL changed (was '%s', now '%s')\n"),
+ default_shell, shell));
+ unixy_shell = _is_unixy_shell (shell);
+ /* we must allocate a copy of shell: construct_command_argv() will free
+ * shell after this function returns. */
+ default_shell = xstrdup (shell);
+ }
+ if (unixy_shell)
+ {
+ sh_chars = sh_chars_sh;
+ sh_cmds = sh_cmds_sh;
+ }
+ else
+ {
+ sh_chars = sh_chars_dos;
+ sh_cmds = sh_cmds_dos;
+# ifdef __EMX__
+ if (_osmode == OS2_MODE)
+ {
+ sh_chars = sh_chars_os2;
+ sh_cmds = sh_cmds_os2;
+ }
+# endif
+ }
+#else /* !__MSDOS__ */
+ else if (strcmp (shell, default_shell))
+ goto slow;
+#endif /* !__MSDOS__ && !__EMX__ */
+#endif /* not WINDOWS32 */
+
+ if (ifs)
+ for (cap = ifs; *cap != '\0'; ++cap)
+ if (*cap != ' ' && *cap != '\t' && *cap != '\n')
+ goto slow;
+
+ if (shellflags)
+ if (shellflags[0] != '-'
+ || ((shellflags[1] != 'c' || shellflags[2] != '\0')
+ && (shellflags[1] != 'e' || shellflags[2] != 'c' || shellflags[3] != '\0')))
+ goto slow;
+
+ i = strlen (line) + 1;
+
+ /* More than 1 arg per character is impossible. */
+ new_argv = xmalloc (i * sizeof (char *));
+
+ /* All the args can fit in a buffer as big as LINE is. */
+ ap = new_argv[0] = argstr = xmalloc (i);
+#ifndef NDEBUG
+ end = ap + i;
+#endif
+
+ /* I is how many complete arguments have been found. */
+ i = 0;
+ instring = word_has_equals = seen_nonequals = last_argument_was_empty = 0;
+ for (p = line; *p != '\0'; ++p)
+ {
+ assert (ap <= end);
+
+ if (instring)
+ {
+ /* Inside a string, just copy any char except a closing quote
+ or a backslash-newline combination. */
+ if (*p == instring)
+ {
+ instring = 0;
+ if (ap == new_argv[0] || *(ap-1) == '\0')
+ last_argument_was_empty = 1;
+ }
+ else if (*p == '\\' && p[1] == '\n')
+ {
+ /* Backslash-newline is handled differently depending on what
+ kind of string we're in: inside single-quoted strings you
+ keep them; in double-quoted strings they disappear. For
+ DOS/Windows/OS2, if we don't have a POSIX shell, we keep the
+ pre-POSIX behavior of removing the backslash-newline. */
+ if (instring == '"'
+#if defined (__MSDOS__) || defined (__EMX__) || defined (WINDOWS32)
+ || !unixy_shell
+#endif
+ )
+ ++p;
+ else
+ {
+ *(ap++) = *(p++);
+ *(ap++) = *p;
+ }
+ }
+ else if (*p == '\n' && restp != NULL)
+ {
+ /* End of the command line. */
+ *restp = p;
+ goto end_of_line;
+ }
+ /* Backslash, $, and ` are special inside double quotes.
+ If we see any of those, punt.
+ But on MSDOS, if we use COMMAND.COM, double and single
+ quotes have the same effect. */
+ else if (instring == '"' && strchr ("\\$`", *p) != 0 && unixy_shell)
+ goto slow;
+#ifdef WINDOWS32
+ /* Quoted wildcard characters must be passed quoted to the
+ command, so give up the fast route. */
+ else if (instring == '"' && strchr ("*?", *p) != 0 && !unixy_shell)
+ goto slow;
+ else if (instring == '"' && strncmp (p, "\\\"", 2) == 0)
+ *ap++ = *++p;
+#endif
+ else
+ *ap++ = *p;
+ }
+ else if (strchr (sh_chars, *p) != 0)
+ /* Not inside a string, but it's a special char. */
+ goto slow;
+ else if (one_shell && *p == '\n')
+ /* In .ONESHELL mode \n is a separator like ; or && */
+ goto slow;
+#ifdef __MSDOS__
+ else if (*p == '.' && p[1] == '.' && p[2] == '.' && p[3] != '.')
+ /* '...' is a wildcard in DJGPP. */
+ goto slow;
+#endif
+ else
+ /* Not a special char. */
+ switch (*p)
+ {
+ case '=':
+ /* Equals is a special character in leading words before the
+ first word with no equals sign in it. This is not the case
+ with sh -k, but we never get here when using nonstandard
+ shell flags. */
+ if (! seen_nonequals && unixy_shell)
+ goto slow;
+ word_has_equals = 1;
+ *ap++ = '=';
+ break;
+
+ case '\\':
+ /* Backslash-newline has special case handling, ref POSIX.
+ We're in the fastpath, so emulate what the shell would do. */
+ if (p[1] == '\n')
+ {
+ /* Throw out the backslash and newline. */
+ ++p;
+
+ /* At the beginning of the argument, skip any whitespace other
+ than newline before the start of the next word. */
+ if (ap == new_argv[i])
+ while (ISBLANK (p[1]))
+ ++p;
+ }
+#ifdef WINDOWS32
+ /* Backslash before whitespace is not special if our shell
+ is not Unixy. */
+ else if (ISSPACE (p[1]) && !unixy_shell)
+ {
+ *ap++ = *p;
+ break;
+ }
+#endif
+ else if (p[1] != '\0')
+ {
+#ifdef HAVE_DOS_PATHS
+ /* Only remove backslashes before characters special to Unixy
+ shells. All other backslashes are copied verbatim, since
+ they are probably DOS-style directory separators. This
+ still leaves a small window for problems, but at least it
+ should work for the vast majority of naive users. */
+
+#ifdef __MSDOS__
+ /* A dot is only special as part of the "..."
+ wildcard. */
+ if (strneq (p + 1, ".\\.\\.", 5))
+ {
+ *ap++ = '.';
+ *ap++ = '.';
+ p += 4;
+ }
+ else
+#endif
+ if (p[1] != '\\' && p[1] != '\''
+ && !ISSPACE (p[1])
+ && strchr (sh_chars_sh, p[1]) == 0)
+ /* back up one notch, to copy the backslash */
+ --p;
+#endif /* HAVE_DOS_PATHS */
+
+ /* Copy and skip the following char. */
+ *ap++ = *++p;
+ }
+ break;
+
+ case '\'':
+ case '"':
+ instring = *p;
+ break;
+
+ case '\n':
+ if (restp != NULL)
+ {
+ /* End of the command line. */
+ *restp = p;
+ goto end_of_line;
+ }
+ else
+ /* Newlines are not special. */
+ *ap++ = '\n';
+ break;
+
+ case ' ':
+ case '\t':
+ /* We have the end of an argument.
+ Terminate the text of the argument. */
+ *ap++ = '\0';
+ new_argv[++i] = ap;
+ last_argument_was_empty = 0;
+
+ /* Update SEEN_NONEQUALS, which tells us if every word
+ heretofore has contained an '='. */
+ seen_nonequals |= ! word_has_equals;
+ if (word_has_equals && ! seen_nonequals)
+ /* An '=' in a word before the first
+ word without one is magical. */
+ goto slow;
+ word_has_equals = 0; /* Prepare for the next word. */
+
+ /* If this argument is the command name,
+ see if it is a built-in shell command.
+ If so, have the shell handle it. */
+ if (i == 1)
+ {
+ int j;
+ for (j = 0; sh_cmds[j] != 0; ++j)
+ {
+ if (streq (sh_cmds[j], new_argv[0]))
+ goto slow;
+#if defined(__EMX__) || defined(WINDOWS32)
+ /* Non-Unix shells are case insensitive. */
+ if (!unixy_shell
+ && strcasecmp (sh_cmds[j], new_argv[0]) == 0)
+ goto slow;
+#endif
+ }
+ }
+
+ /* Skip whitespace chars, but not newlines. */
+ while (ISBLANK (p[1]))
+ ++p;
+ break;
+
+ default:
+ *ap++ = *p;
+ break;
+ }
+ }
+ end_of_line:
+
+ if (instring)
+ /* Let the shell deal with an unterminated quote. */
+ goto slow;
+
+ /* Terminate the last argument and the argument list. */
+
+ *ap = '\0';
+ if (new_argv[i][0] != '\0' || last_argument_was_empty)
+ ++i;
+ new_argv[i] = 0;
+
+ if (i == 1)
+ {
+ int j;
+ for (j = 0; sh_cmds[j] != 0; ++j)
+ if (streq (sh_cmds[j], new_argv[0]))
+ goto slow;
+ }
+
+ if (new_argv[0] == 0)
+ {
+ /* Line was empty. */
+ free (argstr);
+ free (new_argv);
+ return 0;
+ }
+
+ return new_argv;
+
+ slow:;
+ /* We must use the shell. */
+
+ if (new_argv != 0)
+ {
+ /* Free the old argument list we were working on. */
+ free (argstr);
+ free (new_argv);
+ }
+
+#ifdef __MSDOS__
+ execute_by_shell = 1; /* actually, call 'system' if shell isn't unixy */
+#endif
+
+#ifdef _AMIGA
+ {
+ char *ptr;
+ char *buffer;
+ char *dptr;
+
+ buffer = xmalloc (strlen (line)+1);
+
+ ptr = line;
+ for (dptr=buffer; *ptr; )
+ {
+ if (*ptr == '\\' && ptr[1] == '\n')
+ ptr += 2;
+ else if (*ptr == '@') /* Kludge: multiline commands */
+ {
+ ptr += 2;
+ *dptr++ = '\n';
+ }
+ else
+ *dptr++ = *ptr++;
+ }
+ *dptr = 0;
+
+ new_argv = xmalloc (2 * sizeof (char *));
+ new_argv[0] = buffer;
+ new_argv[1] = 0;
+ }
+#else /* Not Amiga */
+#ifdef WINDOWS32
+ /*
+ * Not eating this whitespace caused things like
+ *
+ * sh -c "\n"
+ *
+ * which gave the shell fits. I think we have to eat
+ * whitespace here, but this code should be considered
+ * suspicious if things start failing....
+ */
+
+ /* Make sure not to bother processing an empty line. */
+ NEXT_TOKEN (line);
+ if (*line == '\0')
+ return 0;
+#endif /* WINDOWS32 */
+
+ {
+ /* SHELL may be a multi-word command. Construct a command line
+ "$(SHELL) $(.SHELLFLAGS) LINE", with all special chars in LINE escaped.
+ Then recurse, expanding this command line to get the final
+ argument list. */
+
+ char *new_line;
+ size_t shell_len = strlen (shell);
+ size_t line_len = strlen (line);
+ size_t sflags_len = shellflags ? strlen (shellflags) : 0;
+#ifdef WINDOWS32
+ char *command_ptr = NULL; /* used for batch_mode_shell mode */
+#endif
+
+# ifdef __EMX__ /* is this necessary? */
+ if (!unixy_shell && shellflags)
+ shellflags[0] = '/'; /* "/c" */
+# endif
+
+ /* In .ONESHELL mode we are allowed to throw the entire current
+ recipe string at a single shell and trust that the user
+ has configured the shell and shell flags, and formatted
+ the string, appropriately. */
+ if (one_shell)
+ {
+ /* If the shell is Bourne compatible, we must remove and ignore
+ interior special chars [@+-] because they're meaningless to
+ the shell itself. If, however, we're in .ONESHELL mode and
+ have changed SHELL to something non-standard, we should
+ leave those alone because they could be part of the
+ script. In this case we must also leave in place
+ any leading [@+-] for the same reason. */
+
+ /* Remove and ignore interior prefix chars [@+-] because they're
+ meaningless given a single shell. */
+#if defined __MSDOS__ || defined (__EMX__)
+ if (unixy_shell) /* the test is complicated and we already did it */
+#else
+ if (is_bourne_compatible_shell (shell)
+#ifdef WINDOWS32
+ /* If we didn't find any sh.exe, don't behave is if we did! */
+ && !no_default_sh_exe
+#endif
+ )
+#endif
+ {
+ const char *f = line;
+ char *t = line;
+
+ /* Copy the recipe, removing and ignoring interior prefix chars
+ [@+-]: they're meaningless in .ONESHELL mode. */
+ while (f[0] != '\0')
+ {
+ int esc = 0;
+
+ /* This is the start of a new recipe line. Skip whitespace
+ and prefix characters but not newlines. */
+ while (ISBLANK (*f) || *f == '-' || *f == '@' || *f == '+')
+ ++f;
+
+ /* Copy until we get to the next logical recipe line. */
+ while (*f != '\0')
+ {
+ *(t++) = *(f++);
+ if (f[-1] == '\\')
+ esc = !esc;
+ else
+ {
+ /* On unescaped newline, we're done with this line. */
+ if (f[-1] == '\n' && ! esc)
+ break;
+
+ /* Something else: reset the escape sequence. */
+ esc = 0;
+ }
+ }
+ }
+ *t = '\0';
+ }
+#ifdef WINDOWS32
+ else /* non-Posix shell (cmd.exe etc.) */
+ {
+ const char *f = line;
+ char *t = line;
+ char *tstart = t;
+ int temp_fd;
+ FILE* batch = NULL;
+ int id = GetCurrentProcessId ();
+ PATH_VAR(fbuf);
+
+ /* Generate a file name for the temporary batch file. */
+ sprintf (fbuf, "make%d", id);
+ *batch_filename = create_batch_file (fbuf, 0, &temp_fd);
+ DB (DB_JOBS, (_("Creating temporary batch file %s\n"),
+ *batch_filename));
+
+ /* Create a FILE object for the batch file, and write to it the
+ commands to be executed. Put the batch file in TEXT mode. */
+ _setmode (temp_fd, _O_TEXT);
+ batch = _fdopen (temp_fd, "wt");
+ fputs ("@echo off\n", batch);
+ DB (DB_JOBS, (_("Batch file contents:\n\t@echo off\n")));
+
+ /* Copy the recipe, removing and ignoring interior prefix chars
+ [@+-]: they're meaningless in .ONESHELL mode. */
+ while (*f != '\0')
+ {
+ /* This is the start of a new recipe line. Skip whitespace
+ and prefix characters but not newlines. */
+ while (ISBLANK (*f) || *f == '-' || *f == '@' || *f == '+')
+ ++f;
+
+ /* Copy until we get to the next logical recipe line. */
+ while (*f != '\0')
+ {
+ /* Remove the escaped newlines in the command, and the
+ blanks that follow them. Windows shells cannot handle
+ escaped newlines. */
+ if (*f == '\\' && f[1] == '\n')
+ {
+ f += 2;
+ while (ISBLANK (*f))
+ ++f;
+ }
+ *(t++) = *(f++);
+ /* On an unescaped newline, we're done with this
+ line. */
+ if (f[-1] == '\n')
+ break;
+ }
+ /* Write another line into the batch file. */
+ if (t > tstart)
+ {
+ char c = *t;
+ *t = '\0';
+ fputs (tstart, batch);
+ DB (DB_JOBS, ("\t%s", tstart));
+ tstart = t;
+ *t = c;
+ }
+ }
+ DB (DB_JOBS, ("\n"));
+ fclose (batch);
+
+ /* Create an argv list for the shell command line that
+ will run the batch file. */
+ new_argv = xmalloc (2 * sizeof (char *));
+ new_argv[0] = xstrdup (*batch_filename);
+ new_argv[1] = NULL;
+ return new_argv;
+ }
+#endif /* WINDOWS32 */
+ /* Create an argv list for the shell command line. */
+ {
+ int n = 0;
+
+ new_argv = xmalloc ((4 + sflags_len/2) * sizeof (char *));
+ new_argv[n++] = xstrdup (shell);
+
+ /* Chop up the shellflags (if any) and assign them. */
+ if (! shellflags)
+ new_argv[n++] = xstrdup ("");
+ else
+ {
+ const char *s = shellflags;
+ char *t;
+ size_t len;
+ while ((t = find_next_token (&s, &len)) != 0)
+ new_argv[n++] = xstrndup (t, len);
+ }
+
+ /* Set the command to invoke. */
+ new_argv[n++] = line;
+ new_argv[n++] = NULL;
+ }
+ return new_argv;
+ }
+
+ new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1
+ + (line_len*2) + 1);
+ ap = new_line;
+ /* Copy SHELL, escaping any characters special to the shell. If
+ we don't escape them, construct_command_argv_internal will
+ recursively call itself ad nauseam, or until stack overflow,
+ whichever happens first. */
+ for (cp = shell; *cp != '\0'; ++cp)
+ {
+ if (strchr (sh_chars, *cp) != 0)
+ *(ap++) = '\\';
+ *(ap++) = *cp;
+ }
+ *(ap++) = ' ';
+ if (shellflags)
+ memcpy (ap, shellflags, sflags_len);
+ ap += sflags_len;
+ *(ap++) = ' ';
+#ifdef WINDOWS32
+ command_ptr = ap;
+#endif
+ for (p = line; *p != '\0'; ++p)
+ {
+ if (restp != NULL && *p == '\n')
+ {
+ *restp = p;
+ break;
+ }
+ else if (*p == '\\' && p[1] == '\n')
+ {
+ /* POSIX says we keep the backslash-newline. If we don't have a
+ POSIX shell on DOS/Windows/OS2, mimic the pre-POSIX behavior
+ and remove the backslash/newline. */
+#if defined (__MSDOS__) || defined (__EMX__) || defined (WINDOWS32)
+# define PRESERVE_BSNL unixy_shell
+#else
+# define PRESERVE_BSNL 1
+#endif
+ if (PRESERVE_BSNL)
+ {
+ *(ap++) = '\\';
+ /* Only non-batch execution needs another backslash,
+ because it will be passed through a recursive
+ invocation of this function. */
+ if (!batch_mode_shell)
+ *(ap++) = '\\';
+ *(ap++) = '\n';
+ }
+ ++p;
+ continue;
+ }
+
+ /* DOS shells don't know about backslash-escaping. */
+ if (unixy_shell && !batch_mode_shell &&
+ (*p == '\\' || *p == '\'' || *p == '"'
+ || ISSPACE (*p)
+ || strchr (sh_chars, *p) != 0))
+ *ap++ = '\\';
+#ifdef __MSDOS__
+ else if (unixy_shell && strneq (p, "...", 3))
+ {
+ /* The case of '...' wildcard again. */
+ strcpy (ap, "\\.\\.\\");
+ ap += 5;
+ p += 2;
+ }
+#endif
+ *ap++ = *p;
+ }
+ if (ap == new_line + shell_len + sflags_len + 2)
+ {
+ /* Line was empty. */
+ free (new_line);
+ return 0;
+ }
+ *ap = '\0';
+
+#ifdef WINDOWS32
+ /* Some shells do not work well when invoked as 'sh -c xxx' to run a
+ command line (e.g. Cygnus GNUWIN32 sh.exe on WIN32 systems). In these
+ cases, run commands via a script file. */
+ if (just_print_flag && !(flags & COMMANDS_RECURSE))
+ {
+ /* Need to allocate new_argv, although it's unused, because
+ start_job_command will want to free it and its 0'th element. */
+ new_argv = xmalloc (2 * sizeof (char *));
+ new_argv[0] = xstrdup ("");
+ new_argv[1] = NULL;
+ }
+ else if ((no_default_sh_exe || batch_mode_shell) && batch_filename)
+ {
+ int temp_fd;
+ FILE* batch = NULL;
+ int id = GetCurrentProcessId ();
+ PATH_VAR (fbuf);
+
+ /* create a file name */
+ sprintf (fbuf, "make%d", id);
+ *batch_filename = create_batch_file (fbuf, unixy_shell, &temp_fd);
+
+ DB (DB_JOBS, (_("Creating temporary batch file %s\n"),
+ *batch_filename));
+
+ /* Create a FILE object for the batch file, and write to it the
+ commands to be executed. Put the batch file in TEXT mode. */
+ _setmode (temp_fd, _O_TEXT);
+ batch = _fdopen (temp_fd, "wt");
+ if (!unixy_shell)
+ fputs ("@echo off\n", batch);
+ fputs (command_ptr, batch);
+ fputc ('\n', batch);
+ fclose (batch);
+ DB (DB_JOBS, (_("Batch file contents:%s\n\t%s\n"),
+ !unixy_shell ? "\n\t@echo off" : "", command_ptr));
+
+ /* create argv */
+ new_argv = xmalloc (3 * sizeof (char *));
+ if (unixy_shell)
+ {
+ new_argv[0] = xstrdup (shell);
+ new_argv[1] = *batch_filename; /* only argv[0] gets freed later */
+ }
+ else
+ {
+ new_argv[0] = xstrdup (*batch_filename);
+ new_argv[1] = NULL;
+ }
+ new_argv[2] = NULL;
+ }
+ else
+#endif /* WINDOWS32 */
+
+ if (unixy_shell)
+ new_argv = construct_command_argv_internal (new_line, 0, 0, 0, 0,
+ flags, 0);
+
+#ifdef __EMX__
+ else if (!unixy_shell)
+ {
+ /* new_line is local, must not be freed therefore
+ We use line here instead of new_line because we run the shell
+ manually. */
+ size_t line_len = strlen (line);
+ char *p = new_line;
+ char *q = new_line;
+ memcpy (new_line, line, line_len + 1);
+ /* Replace all backslash-newline combination and also following tabs.
+ Important: stop at the first '\n' because that's what the loop above
+ did. The next line starting at restp[0] will be executed during the
+ next call of this function. */
+ while (*q != '\0' && *q != '\n')
+ {
+ if (q[0] == '\\' && q[1] == '\n')
+ q += 2; /* remove '\\' and '\n' */
+ else
+ *p++ = *q++;
+ }
+ *p = '\0';
+
+# ifndef NO_CMD_DEFAULT
+ if (strnicmp (new_line, "echo", 4) == 0
+ && (new_line[4] == ' ' || new_line[4] == '\t'))
+ {
+ /* the builtin echo command: handle it separately */
+ size_t echo_len = line_len - 5;
+ char *echo_line = new_line + 5;
+
+ /* special case: echo 'x="y"'
+ cmd works this way: a string is printed as is, i.e., no quotes
+ are removed. But autoconf uses a command like echo 'x="y"' to
+ determine whether make works. autoconf expects the output x="y"
+ so we will do exactly that.
+ Note: if we do not allow cmd to be the default shell
+ we do not need this kind of voodoo */
+ if (echo_line[0] == '\''
+ && echo_line[echo_len - 1] == '\''
+ && strncmp (echo_line + 1, "ac_maketemp=",
+ strlen ("ac_maketemp=")) == 0)
+ {
+ /* remove the enclosing quotes */
+ memmove (echo_line, echo_line + 1, echo_len - 2);
+ echo_line[echo_len - 2] = '\0';
+ }
+ }
+# endif
+
+ {
+ /* Let the shell decide what to do. Put the command line into the
+ 2nd command line argument and hope for the best ;-) */
+ size_t sh_len = strlen (shell);
+
+ /* exactly 3 arguments + NULL */
+ new_argv = xmalloc (4 * sizeof (char *));
+ /* Exactly strlen(shell) + strlen("/c") + strlen(line) + 3 times
+ the trailing '\0' */
+ new_argv[0] = xmalloc (sh_len + line_len + 5);
+ memcpy (new_argv[0], shell, sh_len + 1);
+ new_argv[1] = new_argv[0] + sh_len + 1;
+ memcpy (new_argv[1], "/c", 3);
+ new_argv[2] = new_argv[1] + 3;
+ memcpy (new_argv[2], new_line, line_len + 1);
+ new_argv[3] = NULL;
+ }
+ }
+#elif defined(__MSDOS__)
+ else
+ {
+ /* With MSDOS shells, we must construct the command line here
+ instead of recursively calling ourselves, because we
+ cannot backslash-escape the special characters (see above). */
+ new_argv = xmalloc (sizeof (char *));
+ line_len = strlen (new_line) - shell_len - sflags_len - 2;
+ new_argv[0] = xmalloc (line_len + 1);
+ strncpy (new_argv[0],
+ new_line + shell_len + sflags_len + 2, line_len);
+ new_argv[0][line_len] = '\0';
+ }
+#else
+ else
+ fatal (NILF, CSTRLEN (__FILE__) + INTSTR_LENGTH,
+ _("%s (line %d) Bad shell context (!unixy && !batch_mode_shell)\n"),
+ __FILE__, __LINE__);
+#endif
+
+ free (new_line);
+ }
+#endif /* ! AMIGA */
+
+ return new_argv;
+}
+#endif /* !VMS */
+
+/* Figure out the argument list necessary to run LINE as a command. Try to
+ avoid using a shell. This routine handles only ' quoting, and " quoting
+ when no backslash, $ or ' characters are seen in the quotes. Starting
+ quotes may be escaped with a backslash. If any of the characters in
+ sh_chars is seen, or any of the builtin commands listed in sh_cmds
+ is the first word of a line, the shell is used.
+
+ If RESTP is not NULL, *RESTP is set to point to the first newline in LINE.
+ If *RESTP is NULL, newlines will be ignored.
+
+ FILE is the target whose commands these are. It is used for
+ variable expansion for $(SHELL) and $(IFS). */
+
+char **
+construct_command_argv (char *line, char **restp, struct file *file,
+ int cmd_flags, char **batch_filename)
+{
+ char *shell, *ifs, *shellflags;
+ char **argv;
+
+ {
+ /* Turn off --warn-undefined-variables while we expand SHELL and IFS. */
+ int save = warn_undefined_variables_flag;
+ warn_undefined_variables_flag = 0;
+
+ shell = allocated_variable_expand_for_file ("$(SHELL)", file);
+#ifdef WINDOWS32
+ /*
+ * Convert to forward slashes so that construct_command_argv_internal()
+ * is not confused.
+ */
+ if (shell)
+ {
+ char *p = w32ify (shell, 0);
+ strcpy (shell, p);
+ }
+#endif
+#ifdef __EMX__
+ {
+ static const char *unixroot = NULL;
+ static const char *last_shell = "";
+ static int init = 0;
+ if (init == 0)
+ {
+ unixroot = getenv ("UNIXROOT");
+ /* unixroot must be NULL or not empty */
+ if (unixroot && unixroot[0] == '\0') unixroot = NULL;
+ init = 1;
+ }
+
+ /* if we have an unixroot drive and if shell is not default_shell
+ (which means it's either cmd.exe or the test has already been
+ performed) and if shell is an absolute path without drive letter,
+ try whether it exists e.g.: if "/bin/sh" does not exist use
+ "$UNIXROOT/bin/sh" instead. */
+ if (unixroot && shell && strcmp (shell, last_shell) != 0
+ && (shell[0] == '/' || shell[0] == '\\'))
+ {
+ /* trying a new shell, check whether it exists */
+ size_t size = strlen (shell);
+ char *buf = xmalloc (size + 7);
+ memcpy (buf, shell, size);
+ memcpy (buf + size, ".exe", 5); /* including the trailing '\0' */
+ if (access (shell, F_OK) != 0 && access (buf, F_OK) != 0)
+ {
+ /* try the same for the unixroot drive */
+ memmove (buf + 2, buf, size + 5);
+ buf[0] = unixroot[0];
+ buf[1] = unixroot[1];
+ if (access (buf, F_OK) == 0)
+ /* we have found a shell! */
+ /* free(shell); */
+ shell = buf;
+ else
+ free (buf);
+ }
+ else
+ free (buf);
+ }
+ }
+#endif /* __EMX__ */
+
+ shellflags = allocated_variable_expand_for_file ("$(.SHELLFLAGS)", file);
+ ifs = allocated_variable_expand_for_file ("$(IFS)", file);
+
+ warn_undefined_variables_flag = save;
+ }
+
+ argv = construct_command_argv_internal (line, restp, shell, shellflags, ifs,
+ cmd_flags, batch_filename);
+
+ free (shell);
+ free (shellflags);
+ free (ifs);
+
+ return argv;
+}
+
+#if !defined(HAVE_DUP2) && !defined(_AMIGA)
+int
+dup2 (int old, int new)
+{
+ int fd;
+
+ (void) close (new);
+ EINTRLOOP (fd, dup (old));
+ if (fd != new)
+ {
+ (void) close (fd);
+ errno = EMFILE;
+ return -1;
+ }
+
+ return fd;
+}
+#endif /* !HAVE_DUP2 && !_AMIGA */
+
+/* On VMS systems, include special VMS functions. */
+
+#ifdef VMS
+#include "vmsjobs.c"
+#endif
Index: create-4.3.1-gnulib-patch/make-4.3.1-new/src
===================================================================
--- create-4.3.1-gnulib-patch/make-4.3.1-new/src (nonexistent)
+++ create-4.3.1-gnulib-patch/make-4.3.1-new/src (revision 5)
Property changes on: create-4.3.1-gnulib-patch/make-4.3.1-new/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-4.3.1-gnulib-patch/make-4.3.1-new
===================================================================
--- create-4.3.1-gnulib-patch/make-4.3.1-new (nonexistent)
+++ create-4.3.1-gnulib-patch/make-4.3.1-new (revision 5)
Property changes on: create-4.3.1-gnulib-patch/make-4.3.1-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-4.3.1-gnulib-patch
===================================================================
--- create-4.3.1-gnulib-patch (nonexistent)
+++ create-4.3.1-gnulib-patch (revision 5)
Property changes on: create-4.3.1-gnulib-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: patches/README
===================================================================
--- patches/README (nonexistent)
+++ patches/README (revision 5)
@@ -0,0 +1,6 @@
+
+/* begin *
+
+ TODO: Leave some comment here.
+
+ * end */
Index: patches
===================================================================
--- patches (nonexistent)
+++ patches (revision 5)
Property changes on: patches
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 5)
Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~