Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlassert / repo / third_party / nlbuild-autotools / repo / tools / packages / make / make.patches / make-00.patch
1 --- make-dfsg-4.1.orig/ar.c
2 +++ make-dfsg-4.1/ar.c
3 @@ -68,25 +68,39 @@
4  
5  /* This function is called by 'ar_scan' to find which member to look at.  */
6  
7 +struct member_date_lookup
8 +{
9 +  const char *name;
10 +  time_t *member_date;
11 +};
12 +
13  /* ARGSUSED */
14  static long int
15  ar_member_date_1 (int desc UNUSED, const char *mem, int truncated,
16                    long int hdrpos UNUSED, long int datapos UNUSED,
17                    long int size UNUSED, long int date,
18                    int uid UNUSED, int gid UNUSED, int mode UNUSED,
19 -                  const void *name)
20 +                  const void *data)
21  {
22 -  return ar_name_equal (name, mem, truncated) ? date : 0;
23 +  const struct member_date_lookup *lookup_data = data;
24 +  if (ar_name_equal (lookup_data->name, mem, truncated))
25 +    {
26 +      *lookup_data->member_date = date;
27 +      return 1;
28 +    }
29 +  return 0;
30  }
31  
32 -/* Return the modtime of NAME.  */
33 +/* Read the modtime of NAME in MEMBER_DATE.
34 +   Returns 1 if NAME exists, 0 otherwise.  */
35  
36 -time_t
37 -ar_member_date (const char *name)
38 +int
39 +ar_member_date (const char *name, time_t *member_date)
40  {
41    char *arname;
42    char *memname;
43 -  long int val;
44 +  int found;
45 +  struct member_date_lookup lookup_data;
46  
47    ar_parse_name (name, &arname, &memname);
48  
49 @@ -107,11 +121,14 @@
50        (void) f_mtime (arfile, 0);
51    }
52  
53 -  val = ar_scan (arname, ar_member_date_1, memname);
54 +  lookup_data.name = memname;
55 +  lookup_data.member_date = member_date;
56 +  found = ar_scan (arname, ar_member_date_1, &lookup_data);
57  
58    free (arname);
59  
60 -  return (val <= 0 ? (time_t) -1 : (time_t) val);
61 +  /* return 0 (not found) if the archive does not exist or has invalid format. */
62 +  return (found == 1) ? 1 : 0;
63  }
64  \f
65  /* Set the archive-member NAME's modtime to now.  */
66 --- make-dfsg-4.1.orig/commands.c
67 +++ make-dfsg-4.1/commands.c
68 @@ -622,7 +622,10 @@
69        time_t file_date = (file->last_mtime == NONEXISTENT_MTIME
70                            ? (time_t) -1
71                            : (time_t) FILE_TIMESTAMP_S (file->last_mtime));
72 -      if (ar_member_date (file->name) != file_date)
73 +      time_t member_date = NONEXISTENT_MTIME;
74 +      int found;
75 +      found = ar_member_date (file->name, &member_date);
76 +      if (found && member_date != file_date)
77          {
78            if (on_behalf_of)
79              OSS (error, NILF,
80 --- make-dfsg-4.1.orig/configure
81 +++ make-dfsg-4.1/configure
82 @@ -11060,10 +11061,9 @@
83  #include <glob.h>
84  #include <fnmatch.h>
85  
86 -#define GLOB_INTERFACE_VERSION 1
87  #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
88  # include <gnu-versions.h>
89 -# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
90 +# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
91     gnu glob
92  # endif
93  #endif],
94 --- make-dfsg-4.1.orig/dir.c
95 +++ make-dfsg-4.1/dir.c
96 @@ -748,8 +748,11 @@
97    const char *slash;
98  
99  #ifndef NO_ARCHIVES
100 -  if (ar_name (name))
101 -    return ar_member_date (name) != (time_t) -1;
102 +  {
103 +    time_t member_date;
104 +    if (ar_name (name))
105 +      return ar_member_date (name, &member_date);
106 +  }
107  #endif
108  
109  #ifdef VMS
110 @@ -1212,15 +1215,40 @@
111  }
112  #endif
113  
114 +/* Similarly for lstat.  */
115 +#if !defined(lstat) && !defined(WINDOWS32) || defined(VMS)
116 +# ifndef VMS
117 +#  ifndef HAVE_SYS_STAT_H
118 +int lstat (const char *path, struct stat *sbuf);
119 +#  endif
120 +# else
121 +    /* We are done with the fake lstat.  Go back to the real lstat */
122 +#   ifdef lstat
123 +#     undef lstat
124 +#   endif
125 +# endif
126 +# define local_lstat lstat
127 +#elif defined(WINDOWS32)
128 +/* Windows doesn't support lstat().  */
129 +# define local_lstat local_stat
130 +#else
131 +static int
132 +local_lstat (const char *path, struct stat *buf)
133 +{
134 +  int e;
135 +  EINTRLOOP (e, lstat (path, buf));
136 +  return e;
137 +}
138 +#endif
139 +
140  void
141  dir_setup_glob (glob_t *gl)
142  {
143    gl->gl_opendir = open_dirstream;
144    gl->gl_readdir = read_dirstream;
145    gl->gl_closedir = free;
146 +  gl->gl_lstat = local_lstat;
147    gl->gl_stat = local_stat;
148 -  /* We don't bother setting gl_lstat, since glob never calls it.
149 -     The slot is only there for compatibility with 4.4 BSD.  */
150  }
151  
152  void
153 --- make-dfsg-4.1.orig/job.c
154 +++ make-dfsg-4.1/job.c
155 @@ -27,6 +27,14 @@
156  
157  #include <string.h>
158  
159 +#if defined (HAVE_LINUX_BINFMTS_H) && defined (HAVE_SYS_USER_H)
160 +#include <sys/user.h>
161 +#include <linux/binfmts.h>
162 +#endif
163 +#ifndef PAGE_SIZE
164 +# define PAGE_SIZE (sysconf(_SC_PAGESIZE))
165 +#endif
166 +
167  /* Default shell to use.  */
168  #ifdef WINDOWS32
169  #include <windows.h>
170 @@ -824,8 +832,6 @@
171            break;
172          }
173  
174 -      child_failed = exit_sig != 0 || exit_code != 0;
175 -
176        /* Search for a child matching the deceased one.  */
177        lastc = 0;
178        for (c = children; c != 0; lastc = c, c = c->next)
179 @@ -837,6 +843,15 @@
180             Ignore it; it was inherited from our invoker.  */
181          continue;
182  
183 +      /* Determine the failure status: 0 for success, 1 for updating target in
184 +         question mode, 2 for anything else.  */
185 +      if (exit_sig == 0 && exit_code == 0)
186 +        child_failed = MAKE_SUCCESS;
187 +      else if (exit_sig == 0 && exit_code == 1 && question_flag && c->recursive)
188 +        child_failed = MAKE_TROUBLE;
189 +      else
190 +        child_failed = MAKE_FAILURE;
191 +
192        DB (DB_JOBS, (child_failed
193                      ? _("Reaping losing child %p PID %s %s\n")
194                      : _("Reaping winning child %p PID %s %s\n"),
195 @@ -872,10 +887,10 @@
196               delete non-precious targets, and abort.  */
197            static int delete_on_error = -1;
198  
199 -          if (!dontcare)
200 +          if (!dontcare && child_failed == MAKE_FAILURE)
201              child_error (c, exit_code, exit_sig, coredump, 0);
202  
203 -          c->file->update_status = us_failed;
204 +          c->file->update_status = child_failed == MAKE_FAILURE ? us_failed : us_question;
205            if (delete_on_error == -1)
206              {
207                struct file *f = lookup_file (".DELETE_ON_ERROR");
208 @@ -987,7 +1002,7 @@
209        if (!err && child_failed && !dontcare && !keep_going_flag &&
210            /* fatal_error_signal will die with the right signal.  */
211            !handling_fatal_signal)
212 -        die (MAKE_FAILURE);
213 +        die (child_failed);
214  
215        /* Only block for one child.  */
216        block = 0;
217 @@ -1189,14 +1204,15 @@
218        ++p;
219      }
220  
221 +  child->recursive = ((flags & COMMANDS_RECURSE) != 0);
222 +
223    /* Update the file's command flags with any new ones we found.  We only
224       keep the COMMANDS_RECURSE setting.  Even this isn't 100% correct; we are
225       now marking more commands recursive than should be in the case of
226       multiline define/endef scripts where only one line is marked "+".  In
227       order to really fix this, we'll have to keep a lines_flags for every
228       actual line, after expansion.  */
229 -  child->file->cmds->lines_flags[child->command_line - 1]
230 -    |= flags & COMMANDS_RECURSE;
231 +  child->file->cmds->lines_flags[child->command_line - 1] |= flags & COMMANDS_RECURSE;
232  
233    /* POSIX requires that a recipe prefix after a backslash-newline should
234       be ignored.  Remove it now so the output is correct.  */
235 @@ -3115,6 +3131,7 @@
236  #ifdef WINDOWS32
237      char *command_ptr = NULL; /* used for batch_mode_shell mode */
238  #endif
239 +    char *args_ptr;
240  
241  # ifdef __EMX__ /* is this necessary? */
242      if (!unixy_shell && shellflags)
243 @@ -3280,8 +3297,17 @@
244          return new_argv;
245        }
246  
247 +#ifdef MAX_ARG_STRLEN
248 +    static char eval_line[] = "eval\\ \\\"set\\ x\\;\\ shift\\;\\ ";
249 +#define ARG_NUMBER_DIGITS 5
250 +#define EVAL_LEN (sizeof(eval_line)-1 + shell_len + 4                   \
251 +                  + (7 + ARG_NUMBER_DIGITS) * 2 * line_len / (MAX_ARG_STRLEN - 2))
252 +#else
253 +#define EVAL_LEN 0
254 +#endif
255 +
256      new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1
257 -                        + (line_len*2) + 1);
258 +                        + (line_len*2) + 1 + EVAL_LEN);
259      ap = new_line;
260      /* Copy SHELL, escaping any characters special to the shell.  If
261         we don't escape them, construct_command_argv_internal will
262 @@ -3301,6 +3327,30 @@
263  #ifdef WINDOWS32
264      command_ptr = ap;
265  #endif
266 +
267 +#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN)
268 +    if (unixy_shell && line_len > MAX_ARG_STRLEN)
269 +      {
270 +       unsigned j;
271 +       memcpy (ap, eval_line, sizeof (eval_line) - 1);
272 +       ap += sizeof (eval_line) - 1;
273 +       for (j = 1; j <= 2 * line_len / (MAX_ARG_STRLEN - 2); j++)
274 +         ap += sprintf (ap, "\\$\\{%u\\}", j);
275 +       *ap++ = '\\';
276 +       *ap++ = '"';
277 +       *ap++ = ' ';
278 +       /* Copy only the first word of SHELL to $0.  */
279 +       for (p = shell; *p != '\0'; ++p)
280 +         {
281 +           if (isspace ((unsigned char)*p))
282 +             break;
283 +           *ap++ = *p;
284 +         }
285 +       *ap++ = ' ';
286 +      }
287 +#endif
288 +    args_ptr = ap;
289 +
290      for (p = line; *p != '\0'; ++p)
291        {
292          if (restp != NULL && *p == '\n')
293 @@ -3348,6 +3398,13 @@
294            }
295  #endif
296          *ap++ = *p;
297 +#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN)
298 +       if (unixy_shell && line_len > MAX_ARG_STRLEN && (ap - args_ptr > MAX_ARG_STRLEN - 2))
299 +         {
300 +           *ap++ = ' ';
301 +           args_ptr = ap;
302 +         }
303 +#endif
304        }
305      if (ap == new_line + shell_len + sflags_len + 2)
306        {
307 --- make-dfsg-4.1.orig/job.h
308 +++ make-dfsg-4.1/job.h
309 @@ -108,6 +108,7 @@
310      unsigned int  noerror:1;    /* Nonzero if commands contained a '-'.  */
311      unsigned int  good_stdin:1; /* Nonzero if this child has a good stdin.  */
312      unsigned int  deleted:1;    /* Nonzero if targets have been deleted.  */
313 +    unsigned int  recursive:1;  /* Nonzero for recursive command ('+' etc.)  */
314      unsigned int  dontcare:1;   /* Saved dontcare flag.  */
315    };
316  
317 --- make-dfsg-4.1.orig/main.c
318 +++ make-dfsg-4.1/main.c
319 @@ -1401,13 +1401,18 @@
320  #ifdef HAVE_ISATTY
321      if (isatty (fileno (stdout)))
322        if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMOUT")))
323 -        define_variable_cname ("MAKE_TERMOUT", TTYNAME (fileno (stdout)),
324 -                               o_default, 0)->export = v_export;
325 -
326 +        {
327 +          const char *tty = TTYNAME (fileno (stdout));
328 +          define_variable_cname ("MAKE_TERMOUT", tty ? tty : DEFAULT_TTYNAME,
329 +                                 o_default, 0)->export = v_export;
330 +        }
331      if (isatty (fileno (stderr)))
332        if (! lookup_variable (STRING_SIZE_TUPLE ("MAKE_TERMERR")))
333 -        define_variable_cname ("MAKE_TERMERR", TTYNAME (fileno (stderr)),
334 -                               o_default, 0)->export = v_export;
335 +        {
336 +          const char *tty = TTYNAME (fileno (stderr));
337 +          define_variable_cname ("MAKE_TERMERR", tty ? tty : DEFAULT_TTYNAME,
338 +                                 o_default, 0)->export = v_export;
339 +        }
340  #endif
341  
342    /* Reset in case the switches changed our minds.  */
343 @@ -2418,6 +2423,11 @@
344              exit (WIFEXITED(r) ? WEXITSTATUS(r) : EXIT_FAILURE);
345            }
346  #else
347 +#ifdef SET_STACK_SIZE
348 +          /* Reset limits, if necessary.  */
349 +          if (stack_limit.rlim_cur)
350 +            setrlimit (RLIMIT_STACK, &stack_limit);
351 +#endif
352            exec_command ((char **)nargv, environ);
353  #endif
354            free (aargv);
355 --- make-dfsg-4.1.orig/makeint.h
356 +++ make-dfsg-4.1/makeint.h
357 @@ -424,10 +424,11 @@
358  /* The number of bytes needed to represent the largest integer as a string.  */
359  #define INTSTR_LENGTH         CSTRLEN ("18446744073709551616")
360  
361 +#define DEFAULT_TTYNAME "true"
362  #ifdef HAVE_TTYNAME
363  # define TTYNAME(_f) ttyname (_f)
364  #else
365 -# define TTYNAME(_f) "true"
366 +# define TTYNAME(_f) DEFAULT_TTYNAME
367  #endif
368  
369  \f
370 @@ -478,7 +479,7 @@
371  int ar_name (const char *);
372  void ar_parse_name (const char *, char **, char **);
373  int ar_touch (const char *);
374 -time_t ar_member_date (const char *);
375 +int ar_member_date (const char *, time_t *);
376  
377  typedef long int (*ar_member_func_t) (int desc, const char *mem, int truncated,
378                                        long int hdrpos, long int datapos,
379 --- make-dfsg-4.1.orig/remake.c
380 +++ make-dfsg-4.1/remake.c
381 @@ -1259,6 +1259,7 @@
382  
383        char *arname, *memname;
384        struct file *arfile;
385 +      int found;
386        time_t member_date;
387  
388        /* Find the archive's name.  */
389 @@ -1306,10 +1307,15 @@
390          /* The archive doesn't exist, so its members don't exist either.  */
391          return NONEXISTENT_MTIME;
392  
393 -      member_date = ar_member_date (file->hname);
394 -      mtime = (member_date == (time_t) -1
395 -               ? NONEXISTENT_MTIME
396 -               : file_timestamp_cons (file->hname, member_date, 0));
397 +      found = ar_member_date (file->hname, &member_date);
398 +      if (found && member_date == (time_t) 0)
399 +        {
400 +              OSS (error, NILF,
401 +                   _("Warning: Archive '%s' seems to have been created in deterministic mode. '%s' will always be updated. Please consider passing the U flag to ar to avoid the problem."),
402 +                   arfile->name, memname);
403 +
404 +        }
405 +      mtime = found ? file_timestamp_cons (file->hname, member_date, 0) : NONEXISTENT_MTIME;
406      }
407    else
408  #endif
409 @@ -1548,9 +1554,11 @@
410  {
411    static const char *dirs[] =
412      {
413 +#ifdef MULTIARCH_DIRS
414 +      MULTIARCH_DIRS
415 +#endif
416  #ifndef _AMIGA
417        "/lib",
418 -      "/usr/lib",
419  #endif
420  #if defined(WINDOWS32) && !defined(LIBDIR)
421  /*
422 @@ -1559,7 +1567,19 @@
423   */
424  #define LIBDIR "."
425  #endif
426 -      LIBDIR,                   /* Defined by configuration.  */
427 +      LIBDIR,                  /* Defined by configuration.  */
428 +#ifndef _AMIGA
429 +/*
430 + * In the Debian binaries, PREFIX is /usr and thus this searches /lib,
431 + * /usr/lib and /usr/lib again and therefore misses any libraries that
432 + * are not packaged and were installed by the site admin.  The ideal
433 + * behaviour would be to have the search path set by a Makefile
434 + * variable (other than the VPATH blunt object) but even absent that,
435 + * it would be more useful if it looked in /usr/local/lib even though
436 + * make itself hasn't been installed in the /usr/local tree -- manoj
437 + */
438 +      "/usr/local/lib",
439 +#endif
440        0
441      };
442