/[gentoo-alt]/trunk/overlay/sys-devel/distcc/files/distcc-gentoo-multilib-r1.patch
Gentoo

Contents of /trunk/overlay/sys-devel/distcc/files/distcc-gentoo-multilib-r1.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 832 - (show annotations) (download)
Sat Oct 15 14:32:27 2005 UTC (8 years, 10 months ago) by flameeyes
File size: 4245 byte(s)
Added distcc that does not check for useradd to work on Gentoo/FreeBSD. Also remove shadow dependency.
1 diff -Naurp distcc-2.18.3.orig/src/distcc.c distcc-2.18.3/src/distcc.c
2 --- distcc-2.18.3.orig/src/distcc.c 2004-10-01 17:47:07.000000000 -0700
3 +++ distcc-2.18.3/src/distcc.c 2005-01-30 22:15:43.883870942 -0800
4 @@ -135,7 +135,106 @@ static void dcc_client_catch_signals(voi
5 signal(SIGHUP, &dcc_client_signalled);
6 }
7
8 +#define MAXNEWFLAGS 32
9 +#define MAXFLAGLEN 127
10
11 +static char **getNewArgv(char **argv, const char *newflagsStr) {
12 + char **newargv;
13 + char newflags[MAXNEWFLAGS][MAXFLAGLEN + 1];
14 + unsigned newflagsCount = 0;
15 + unsigned argc;
16 + unsigned i;
17 + char **p;
18 +
19 + unsigned s, f; /* start/finish of each flag. f points to
20 + * the char AFTER the end (ie the space/\0
21 + */
22 +
23 + /* Tokenize the flag list */
24 + for(s=0; s < strlen(newflagsStr); s=f+1) {
25 + /* Put s at the start of the next flag */
26 + while(newflagsStr[s] == ' ' ||
27 + newflagsStr[s] == '\t')
28 + s++;
29 + if(s == strlen(newflagsStr))
30 + break;
31 +
32 + f = s + 1;
33 + while(newflagsStr[f] != ' ' &&
34 + newflagsStr[f] != '\t' &&
35 + newflagsStr[f] != '\0')
36 + f++;
37 +
38 + /* Detect overrun */
39 + if(MAXFLAGLEN < f - s || MAXNEWFLAGS == newflagsCount)
40 + return NULL;
41 +
42 + strncpy(newflags[newflagsCount], newflagsStr + s, f - s);
43 + newflags[newflagsCount][f - s]='\0';
44 + newflagsCount++;
45 + }
46 +
47 + /* Calculate original argc and see if it contains -m{abi,32,64} */
48 + for(argc=0, p=argv; *p; p++, argc++) {
49 + if(newflagsCount && (strncmp(*p, "-m32", 4) == 0 ||
50 + strncmp(*p, "-m64", 4) == 0 ||
51 + strncmp(*p, "-mabi", 5) == 0)) {
52 + /* Our command line sets the ABI, warn the user about this and ignore
53 + newArgs by setting newflagsCount to 0.
54 + */
55 + newflagsCount = 0;
56 + fprintf(stderr, "%s: %s detected on the command line overrides implicit %s added by the wrapper.\n", argv[0], *p, newflagsStr);
57 + }
58 + }
59 +
60 + /* Allocate our array */
61 + newargv = (char **)malloc(sizeof(char *) * (argc + newflagsCount + 1));
62 +
63 + /* Make room for the original, new ones, and the NULL terminator */
64 + if(!newargv)
65 + return NULL;
66 +
67 + /* Build argv */
68 + newargv[0] = argv[0];
69 +
70 + /* The newFlags come first since we want the environment to override them. */
71 + for(i=1; i - 1 < newflagsCount; i++) {
72 + newargv[i] = newflags[i - 1];
73 + }
74 +
75 + /* We just use the existing argv[i] as the start. */
76 + for(; i - newflagsCount < argc; i++) {
77 + newargv[i] = argv[i - newflagsCount];
78 + }
79 +
80 + /* And now cap it off... */
81 + newargv[i] = NULL;
82 +
83 + return newargv;
84 +}
85 +
86 +static char **getNewArgvFromEnv(char **argv) {
87 + char **newargv = argv;
88 +
89 + if(getenv("ABI")) {
90 + char *envar = (char *)malloc(sizeof(char) * (strlen("CFLAGS_") + strlen(getenv("ABI")) + 1 ));
91 +
92 + if(!envar)
93 + return NULL;
94 +
95 + /* We use CFLAGS_${ABI} for gcc, g++, g77, etc as they are
96 + * the same no matter which compiler we are using.
97 + */
98 + sprintf(envar, "CFLAGS_%s", getenv("ABI"));
99 +
100 + if(getenv(envar))
101 + newargv = getNewArgv(argv, getenv(envar));
102 +
103 + free(envar);
104 + }
105 +
106 + return newargv;
107 +}
108
109 /**
110 * distcc client entry point.
111 @@ -150,6 +249,7 @@ int main(int argc, char **argv)
112 int status, sg_level, tweaked_path = 0;
113 char **compiler_args;
114 char *compiler_name;
115 + char **newargv;
116 int ret;
117
118 dcc_client_catch_signals();
119 @@ -183,7 +283,12 @@ int main(int argc, char **argv)
120 goto out;
121 }
122
123 - dcc_find_compiler(argv, &compiler_args);
124 + if(!(newargv = getNewArgvFromEnv(argv))) {
125 + ret = EXIT_OUT_OF_MEMORY;
126 + goto out;
127 + }
128 + dcc_find_compiler(newargv, &compiler_args);
129 + if (newargv != argv) free(newargv);
130 /* compiler_args is now respectively either "cc -c hello.c" or
131 * "gcc -c hello.c" */
132
133 @@ -200,7 +305,12 @@ int main(int argc, char **argv)
134 &tweaked_path)) != 0)
135 goto out;
136
137 - dcc_copy_argv(argv, &compiler_args, 0);
138 + if(!(newargv = getNewArgvFromEnv(argv))) {
139 + ret = EXIT_OUT_OF_MEMORY;
140 + goto out;
141 + }
142 + dcc_copy_argv(newargv, &compiler_args, 0);
143 + if (newargv != argv) free(newargv);
144 compiler_args[0] = compiler_name;
145 }
146

  ViewVC Help
Powered by ViewVC 1.1.20