1 http://bugs.gentoo.org/301116
2 http://bugs.gentoo.org/300867
4 tweaked a little to avoid regenerating autotools, then rebased onto make-3.82
6 2009-07-29 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
8 * configure.in: Check for sys/user.h and linux/binfmts.h
10 * job.c: Include them if available.
11 (construct_command_argv_internal): When constructing the command
12 line with 'sh -c', use multiple arguments together with eval
13 expansion to evade the Linux per-argument length limit
14 MAX_ARG_STRLEN if it is defined.
15 Problem reported against Automake by Xan Lopez <xan@gnome.org>.
17 --- job.c.orig 2012-10-10 15:23:11.000000000 +0300
18 +++ job.c 2012-10-10 15:27:10.000000000 +0300
23 +#if defined(__linux__) /* defined (HAVE_LINUX_BINFMTS_H) && defined (HAVE_SYS_USER_H) */
24 +#include <sys/user.h>
27 +#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
29 +#include <linux/binfmts.h>
32 /* Default shell to use. */
35 @@ -2791,6 +2800,15 @@
38 unsigned int shell_len = strlen (shell);
39 +#ifdef MAX_ARG_STRLEN
40 + static char eval_line[] = "eval\\ \\\"set\\ x\\;\\ shift\\;\\ ";
41 +#define ARG_NUMBER_DIGITS 5
42 +#define EVAL_LEN (sizeof(eval_line)-1 + shell_len + 4 \
43 + + (7 + ARG_NUMBER_DIGITS) * 2 * line_len / (MAX_ARG_STRLEN - 2))
48 unsigned int line_len = strlen (line);
49 unsigned int sflags_len = shellflags ? strlen (shellflags) : 0;
50 char *command_ptr = NULL; /* used for batch_mode_shell mode */
54 new_line = xmalloc ((shell_len*2) + 1 + sflags_len + 1
55 - + (line_len*2) + 1);
56 + + (line_len*2) + 1 + EVAL_LEN);
58 /* Copy SHELL, escaping any characters special to the shell. If
59 we don't escape them, construct_command_argv_internal will
60 @@ -2884,6 +2902,30 @@
65 +#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN)
66 + if (unixy_shell && line_len > MAX_ARG_STRLEN)
69 + memcpy (ap, eval_line, sizeof (eval_line) - 1);
70 + ap += sizeof (eval_line) - 1;
71 + for (j = 1; j <= 2 * line_len / (MAX_ARG_STRLEN - 2); j++)
72 + ap += sprintf (ap, "\\$\\{%u\\}", j);
76 + /* Copy only the first word of SHELL to $0. */
77 + for (p = shell; *p != '\0'; ++p)
79 + if (isspace ((unsigned char)*p))
88 for (p = line; *p != '\0'; ++p)
90 if (restp != NULL && *p == '\n')
91 @@ -2931,6 +2973,14 @@
96 +#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN)
97 + if (unixy_shell && line_len > MAX_ARG_STRLEN && (ap - args_ptr > MAX_ARG_STRLEN - 2))
104 if (ap == new_line + shell_len + sflags_len + 2)