]> git.pld-linux.org Git - packages/uClibc.git/blob - uClibc-toolchain-wrapper.patch
- new
[packages/uClibc.git] / uClibc-toolchain-wrapper.patch
1 diff -urN uClibc-0.9.26.org/extra/gcc-uClibc/.cvsignore uClibc-0.9.26/extra/gcc-uClibc/.cvsignore
2 --- uClibc-0.9.26.org/extra/gcc-uClibc/.cvsignore       1970-01-01 01:00:00.000000000 +0100
3 +++ uClibc-0.9.26/extra/gcc-uClibc/.cvsignore   2002-01-29 10:02:51.000000000 +0100
4 @@ -0,0 +1,2 @@
5 +gcc-uClibc.h
6 +*-uclibc-*
7 diff -urN uClibc-0.9.26.org/extra/gcc-uClibc/gcc-uClibc.c uClibc-0.9.26/extra/gcc-uClibc/gcc-uClibc.c
8 --- uClibc-0.9.26.org/extra/gcc-uClibc/gcc-uClibc.c     1970-01-01 01:00:00.000000000 +0100
9 +++ uClibc-0.9.26/extra/gcc-uClibc/gcc-uClibc.c 2003-08-28 07:51:04.000000000 +0200
10 @@ -0,0 +1,660 @@
11 +/* vi: set sw=4 ts=4: */
12 +/*
13 + * Copyright (C) 2000 Manuel Novoa III
14 + * Copyright (C) 2002-2003 Erik Andersen
15 + *
16 + * This is a crude wrapper to use uClibc with gcc.
17 + * It was originally written to work around ./configure for ext2fs-utils.
18 + * It certainly can be improved, but it works for me in the normal cases.
19 + *
20 + * April 7, 2001
21 + *
22 + * A bug was fixed in building the gcc command line when dynamic linking.
23 + * The functions dlopen, etc. now work.  At this time, you must make sure
24 + * the correct libdl.so is included however.  It is safest to, for example,
25 + * add /lib/libdl.so.1 if using ld-linux.so.1 rather than adding -ldl to the
26 + * command line.
27 + *
28 + * Note: This is only a problem if devel and target archs are the same.  To
29 + * avoid the problem, you can use a customized dynamic linker.
30 + *
31 + *
32 + * April 18, 2001
33 + *
34 + * The wrapper now works with either installed and uninstalled uClibc versions.
35 + * If you want to use the uninstalled header files and libs, either include
36 + * the string "build" in the invocation name such as
37 + *       'ln -s <ARCH>-uclibc-gcc <ARCH>-uclibc-gcc-build'
38 + * or include it in the environment variable setting of UCLIBC_ENV.
39 + * Note: This automatically enables the "rpath" behavior described below.
40 + *
41 + * The wrapper will now pass the location of the uClibc shared libs used to
42 + * the linker with the "-rpath" option if the invocation name includes the
43 + * string "rpath" or if the environment variable UCLIBC_ENV include it (as
44 + * with "build" above).  This is primarily intended to be used on devel
45 + * platforms of the same arch as the target.  A good place to use this feature
46 + * would be in the uClibc/test directory.
47 + *
48 + * The wrapper now displays the command line passed to gcc when '-v' is used.
49 + *
50 + * May 31, 2001
51 + *
52 + * "rpath" and "build" behavior are now decoupled.  You can of course get
53 + * the old "build" behavior by setting UCLIBC_ENV="rpath-build".  Order
54 + * isn't important here, as only the substrings are searched for.
55 + *
56 + * Added environment variable check for UCLIBC_GCC_DLOPT to let user specify
57 + * an alternative dynamic linker at runtime without using command line args.
58 + * Since this wouldn't commonly be used, I made it easy on myself.  You have
59 + * to match the option you would have passed to the gcc wrapper.  As an
60 + * example,
61 + *
62 + *   export UCLIBC_GCC_DLOPT="-Wl,--dynamic-linker,/lib/ld-alt-linker.so.3"
63 + *
64 + * This is really only useful if target arch == devel arch and DEVEL_PREFIX
65 + * isn't empty.  It involves a recompile, but you can at least test apps
66 + * on your devel system if combined with the "rpath" behavor if by using
67 + * LD_LIBRARY_PATH, etc.
68 + *
69 + * Also added check for "-Wl,--dynamic-linker" on the command line.  The
70 + * use default dynamic linker or the envirnment-specified dynamic linker
71 + * is disabled in that case.
72 + *
73 + * Added options --uclibc-use-build-dir and --uclibc-use-rpath so that those
74 + * behaviors can be invoked from the command line.
75 + *
76 + */
77 +
78 +/*
79 + *
80 + * TODO:
81 + * Check/modify gcc-specific environment variables?
82 + */
83 +
84 +#include <stdio.h>
85 +#include <stdlib.h>
86 +#include <stdarg.h>
87 +#include <string.h>
88 +#include <unistd.h>
89 +#include <errno.h>
90 +#include <sys/stat.h>
91 +#include <sys/wait.h>
92 +
93 +#include "gcc-uClibc.h"
94 +
95 +static char *our_usr_lib_path = "-L"UCLIBC_DEVEL_PREFIX"/lib";
96 +
97 +static char static_linking[] = "-static";
98 +static char nostdinc[] = "-nostdinc";
99 +static char nostartfiles[] = "-nostartfiles";
100 +static char nodefaultlibs[] = "-nodefaultlibs";
101 +static char nostdlib[] = "-nostdlib";
102 +#ifdef __UCLIBC_CTOR_DTOR__
103 +static char nostdinc_plus[] = "-nostdinc++";
104 +#endif
105 +
106 +/* Include a local implementation of basename, since this
107 + * uses the host system's C lib, and CYGWIN apparently
108 + * doesn't provide an implementation of basename(). */
109 +char *basename(const char *path)
110 +{
111 +       register const char *s;
112 +       register const char *p;
113 +       p = s = path;
114 +       while (*s) {
115 +               if (*s++ == '/') {
116 +                       p = s;
117 +               }
118 +       }
119 +       return (char *) p;
120 +}
121 +
122 +char *dirname(char *path)
123 +{
124 +       static const char null_or_empty_or_noslash[] = ".";
125 +       register char *s;
126 +       register char *last;
127 +       char *first;
128 +
129 +       last = s = path;
130 +
131 +       if (s != NULL) {
132 +
133 +LOOP:
134 +               while (*s && (*s != '/')) ++s;
135 +               first = s;
136 +               while (*s == '/') ++s;
137 +               if (*s) {
138 +                       last = first;
139 +                       goto LOOP;
140 +               }
141 +
142 +               if (last == path) {
143 +                       if (*last != '/') {
144 +                               goto DOT;
145 +                       }
146 +                       if ((*++last == '/') && (last[1] == 0)) {
147 +                               ++last;
148 +                       }
149 +               }
150 +               *last = 0;
151 +               return path;
152 +       }
153 +DOT:
154 +       return (char *) null_or_empty_or_noslash;
155 +}
156 +
157 +
158 +extern void *xmalloc(size_t size)
159 +{
160 +       void *ptr = malloc(size);
161 +
162 +       if (!ptr) {
163 +               fprintf(stderr, "memory exhausted");
164 +               exit(EXIT_FAILURE);
165 +       }
166 +       return ptr;
167 +}
168 +
169 +void xstrcat(char **string, ...)
170 +{
171 +       const char *c;
172 +       va_list p; 
173 +       /* Don't bother to calculate how big exerything 
174 +        * will be, just be careful to not overflow...  */
175 +       va_start(p, string);
176 +       *string = xmalloc(BUFSIZ);
177 +       **string = '\0';
178 +       while(1) {
179 +               if (!(c = va_arg(p, const char *)))
180 +                       break;
181 +               strcat(*string, c); 
182 +       }
183 +       va_end(p);
184 +}
185 +
186 +int main(int argc, char **argv)
187 +{
188 +       int use_build_dir = 0, linking = 1, use_static_linking = 0;
189 +       int use_stdinc = 1, use_start = 1, use_stdlib = 1, use_pic = 0;
190 +       int source_count = 0, use_rpath = 0, verbose = 0;
191 +       int i, j, k, l, m, n;
192 +       char ** gcc_argv;
193 +       char ** gcc_argument;
194 +       char ** libraries;
195 +       char ** libpath;
196 +       char *dlstr;
197 +       char *incstr;
198 +       char *devprefix;
199 +       char *builddir;
200 +       char *libstr;
201 +       char *build_dlstr = 0;
202 +       char *cc;
203 +       char *ep;
204 +       char *rpath_link[2];
205 +       char *rpath[2];
206 +       char *uClibc_inc[2];
207 +       char *our_lib_path[2];
208 +       char *crt0_path[2];
209 +       char *crtbegin_path[2];
210 +       char *crtend_path[2];
211 +       const char *application_name;
212 +#ifdef __UCLIBC_CTOR_DTOR__
213 +       char *crti_path[2];
214 +       char *crtn_path[2];
215 +       int len;
216 +       int ctor_dtor = 1, cplusplus = 0, use_nostdinc_plus = 0;
217 +       int findlibgcc = 1;
218 +       char *cpp = NULL;
219 +#endif
220 +#ifdef __UCLIBC_PROFILING__
221 +       int profile = 0;
222 +       char *gcrt1_path[2];
223 +#endif
224 +
225 +       cc     = getenv("UCLIBC_CC");
226 +       if (cc==NULL) {
227 +               cc = GCC_BIN;
228 +#ifdef __UCLIBC_CTOR_DTOR__
229 +               findlibgcc = 0;
230 +#endif
231 +       }
232 +
233 +       application_name = basename(argv[0]);
234 +       if (application_name[0] == '-')
235 +               application_name++;
236 +
237 +#ifdef __UCLIBC_CTOR_DTOR__
238 +       /* We must use strstr since g++ might be named like a
239 +        * cross compiler (i.e. arm-linux-g++).   We must also
240 +        * search carefully, in case we are searching something 
241 +        * like /opt/c++/gcc-3.1/bin/arm-linux-g++ or some similar 
242 +        * perversion...  */
243 +       len = strlen(application_name);
244 +       if ((strcmp(application_name+len-3, "g++")==0) ||
245 +                       (strcmp(application_name+len-3, "c++")==0)) {
246 +               len = strlen(cc);
247 +               if (strcmp(cc+len-3, "gcc")==0) {
248 +                       cpp = strdup(cc);
249 +                       cpp[len-1]='+';
250 +                       cpp[len-2]='+';
251 +               }
252 +               cplusplus = 1;
253 +               use_nostdinc_plus = 1;
254 +       }
255 +#endif
256 +
257 +       devprefix = getenv("UCLIBC_DEVEL_PREFIX");
258 +       if (!devprefix) {
259 +               devprefix = UCLIBC_DEVEL_PREFIX;
260 +       }
261 +
262 +       builddir = getenv("UCLIBC_BUILD_DIR");
263 +       if (!builddir) {
264 +               builddir = UCLIBC_BUILD_DIR;
265 +       }
266 +
267 +       incstr = getenv("UCLIBC_GCC_INC");
268 +       libstr = getenv("UCLIBC_GCC_LIB");
269 +
270 +       ep     = getenv("UCLIBC_ENV");
271 +       if (!ep) {
272 +               ep = "";
273 +       }
274 +
275 +       if (strstr(ep,"build") != 0) {
276 +               use_build_dir = 1;
277 +       }
278 +
279 +       if (strstr(ep,"rpath") != 0) {
280 +               use_rpath = 1;
281 +       }
282 +
283 +
284 +       xstrcat(&(rpath_link[0]), "-Wl,-rpath-link,", devprefix, "/lib", NULL);
285 +       xstrcat(&(rpath_link[1]), "-Wl,-rpath-link,", builddir, "/lib", NULL);
286 +
287 +       xstrcat(&(rpath[0]), "-Wl,-rpath,", devprefix, "/lib", NULL);
288 +       xstrcat(&(rpath[1]), "-Wl,-rpath,", builddir, "/lib", NULL);
289 +
290 +       xstrcat(&(uClibc_inc[0]), devprefix, "/include/", NULL);
291 +       xstrcat(&(uClibc_inc[1]), builddir, "/include/", NULL);
292 +
293 +#ifdef __UCLIBC_CTOR_DTOR__
294 +       xstrcat(&(crt0_path[0]), devprefix, "/lib/crt1.o", NULL);
295 +       xstrcat(&(crt0_path[1]), builddir, "/lib/crt1.o", NULL);
296 +       xstrcat(&(crti_path[0]), devprefix, "/lib/crti.o", NULL);
297 +       xstrcat(&(crti_path[1]), builddir, "/lib/crti.o", NULL);
298 +       xstrcat(&(crtn_path[0]), devprefix, "/lib/crtn.o", NULL);
299 +       xstrcat(&(crtn_path[1]), builddir, "/lib/crtn.o", NULL);
300 +#else
301 +       xstrcat(&(crt0_path[0]), devprefix, "/lib/crt0.o", NULL);
302 +       xstrcat(&(crt0_path[1]), builddir, "/lib/crt0.o", NULL);
303 +#endif
304 +#ifdef __UCLIBC_PROFILING__
305 +       xstrcat(&(gcrt1_path[0]), devprefix, "/lib/gcrt1.o", NULL);
306 +       xstrcat(&(gcrt1_path[1]), builddir, "/lib/gcrt1.o", NULL);
307 +#endif
308 +
309 +       xstrcat(&(our_lib_path[0]), "-L", devprefix, "/lib", NULL);
310 +       xstrcat(&(our_lib_path[1]), "-L", builddir, "/lib", NULL);
311 +
312 +#ifdef __UCLIBC_HAS_SHARED__
313 +       build_dlstr = "-Wl,--dynamic-linker," BUILD_DYNAMIC_LINKER;
314 +       dlstr = getenv("UCLIBC_GCC_DLOPT");
315 +       if (!dlstr) {
316 +               dlstr = "-Wl,--dynamic-linker," DYNAMIC_LINKER;
317 +       }
318 +#endif
319 +
320 +       m = 0;
321 +       libraries = __builtin_alloca(sizeof(char*) * (argc));
322 +       libraries[m] = '\0';
323 +
324 +       n = 0;
325 +       libpath = __builtin_alloca(sizeof(char*) * (argc));
326 +       libpath[n] = '\0';
327 +
328 +       for ( i = 1 ; i < argc ; i++ ) {
329 +               if (argv[i][0] == '-') { /* option */
330 +                       switch (argv[i][1]) {
331 +                               case 'c':               /* compile or assemble */
332 +                               case 'S':               /* generate assembler code */
333 +                               case 'E':               /* preprocess only */
334 +                               case 'M':           /* generate dependencies */
335 +                                       linking = 0;
336 +                                       break;
337 +                               case 'L':               /* library */
338 +                                       libpath[n++] = argv[i];
339 +                                       libpath[n] = '\0';
340 +                                       if (argv[i][2] == 0) {
341 +                                               argv[i] = '\0';
342 +                                               libpath[n++] = argv[++i];
343 +                                               libpath[n] = '\0';
344 +                                       }
345 +                                       argv[i] = '\0';
346 +                                       break;
347 +                               case 'l':               /* library */
348 +                                       libraries[m++] = argv[i];
349 +                                       libraries[m] = '\0';
350 +                                       argv[i] = '\0';
351 +                                       break;
352 +                               case 'v':               /* verbose */
353 +                                       if (argv[i][2] == 0) verbose = 1;
354 +                                       printf("Invoked as %s\n", argv[0]);
355 +                                       break;
356 +                               case 'n':
357 +                                       if (strcmp(nostdinc,argv[i]) == 0) {
358 +                                               use_stdinc = 0;
359 +                                       } else if (strcmp(nostartfiles,argv[i]) == 0) {
360 +#ifdef __UCLIBC_CTOR_DTOR__
361 +                                               ctor_dtor = 0;
362 +#endif
363 +                                               use_start = 0;
364 +                                       } else if (strcmp(nodefaultlibs,argv[i]) == 0) {
365 +                                               use_stdlib = 0;
366 +                                               argv[i] = '\0';
367 +                                       } else if (strcmp(nostdlib,argv[i]) == 0) {
368 +#ifdef __UCLIBC_CTOR_DTOR__
369 +                                               ctor_dtor = 0;
370 +#endif
371 +                                               use_start = 0;
372 +                                               use_stdlib = 0;
373 +                                       } 
374 +#ifdef __UCLIBC_CTOR_DTOR__
375 +                                       else if (strcmp(nostdinc_plus,argv[i]) == 0) {
376 +                                               if (cplusplus==1) {
377 +                                                       use_nostdinc_plus = 0;
378 +                                               }
379 +                                       }
380 +#endif
381 +                                       break;
382 +                               case 's':
383 +                                       if (strstr(argv[i],static_linking) != NULL) {
384 +                                               use_static_linking = 1;
385 +                                       }
386 +                                       if (strcmp("-shared",argv[i]) == 0) {
387 +                                               use_start = 0;
388 +                                               use_pic = 1;
389 +                                       }
390 +                                       break;
391 +                               case 'W':               /* -static could be passed directly to ld */
392 +                                       if (strncmp("-Wl,",argv[i],4) == 0) {
393 +                                               if (strstr(argv[i],static_linking) != 0) {
394 +                                                       use_static_linking = 1;
395 +                                               }
396 +                                               if (strstr(argv[i],"--dynamic-linker") != 0) {
397 +                                                       dlstr = 0;
398 +                                               }
399 +                                       }
400 +                                       break;
401 +#ifdef __UCLIBC_PROFILING__
402 +                               case 'p':
403 +                                       if (strcmp("-pg",argv[i]) == 0) {
404 +                                               profile = 1;
405 +                                       }
406 +                                       break;
407 +#endif
408 +                               case 'f':
409 +                                       /* Check if we are doing PIC */
410 +                                       if (strcmp("-fPIC",argv[i]) == 0) {
411 +                                               use_pic = 1;
412 +                                       } else if (strcmp("-fpic",argv[i]) == 0) {
413 +                                               use_pic = 1;
414 +                                       } 
415 +#ifdef __UCLIBC_PROFILING__
416 +                                       else if (strcmp("-fprofile-arcs",argv[i]) == 0) {
417 +                                               profile = 1;
418 +                                       }
419 +#endif
420 +                                       break;
421 +
422 +                               case '-':
423 +                                       if (strstr(argv[i]+1,static_linking) != NULL) {
424 +                                               use_static_linking = 1;
425 +                                               argv[i]='\0';
426 +                                       } else if (strcmp("--uclibc-use-build-dir",argv[i]) == 0) {
427 +                                               use_build_dir = 1;
428 +                                               argv[i]='\0';
429 +                                       } else if (strcmp("--uclibc-use-rpath",argv[i]) == 0) {
430 +                                               use_rpath = 1;
431 +                                               argv[i]='\0';
432 +                                       } else if (strcmp ("--uclibc-cc", argv[i]) == 0 && argv[i + 1]) {
433 +                                               cc = argv[i + 1];
434 +                                               argv[i] = 0;
435 +                                               argv[i + 1] = 0;
436 +                                       } else if (strncmp ("--uclibc-cc=", argv[i], 12) == 0) {
437 +                                               cc = argv[i] + 12;
438 +                                               argv[i] = 0;
439 +                                       }
440 +#ifdef __UCLIBC_CTOR_DTOR__
441 +                                       else if (strcmp("--uclibc-no-ctors",argv[i]) == 0) {
442 +                                               ctor_dtor = 0;
443 +                                               argv[i]='\0';
444 +                                       }
445 +#endif
446 +                                       break;
447 +                       }
448 +               } else {                                /* assume it is an existing source file */
449 +                       ++source_count;
450 +               }
451 +       }
452 +
453 +       gcc_argv = __builtin_alloca(sizeof(char*) * (argc + 64));
454 +       gcc_argument = __builtin_alloca(sizeof(char*) * (argc + 20));
455 +
456 +       i = 0; k = 0;
457 +#ifdef __UCLIBC_CTOR_DTOR__
458 +       if (ctor_dtor) {
459 +               struct stat statbuf;
460 +               if (findlibgcc==1 || stat(LIBGCC_DIR, &statbuf)!=0 || 
461 +                               !S_ISDIR(statbuf.st_mode))
462 +               {
463 +                       /* Bummer, gcc is hiding from us. This is going
464 +                        * to really slow things down... bummer.  */
465 +                       int status, gcc_pipe[2];
466 +                       pid_t pid, wpid;
467 +
468 +                       pipe(gcc_pipe);
469 +                       if (!(pid = fork())) {
470 +                               char *argv[4];
471 +                               close(gcc_pipe[0]);
472 +                               close(1);
473 +                               close(2);
474 +                               dup2(gcc_pipe[1], 1);
475 +                               dup2(gcc_pipe[1], 2);
476 +                               argv[0] = cc;
477 +                               argv[1] = "-print-libgcc-file-name";
478 +                               argv[2] = NULL;
479 +                               execvp(cc, argv);
480 +                               close(gcc_pipe[1]);
481 +                               _exit(EXIT_FAILURE);
482 +                       }
483 +                       wpid=0;
484 +                       while (wpid != pid) {
485 +                               wpid = wait(&status);
486 +                       }
487 +                       close(gcc_pipe[1]);
488 +                       if (WIFEXITED(status) && WEXITSTATUS(status)) {
489 +crash_n_burn:
490 +                               fprintf(stderr, "Unable to locale crtbegin.o provided by gcc");
491 +                               exit(EXIT_FAILURE);
492 +                       }
493 +                       if (WIFSIGNALED(status)) {
494 +                               fprintf(stderr, "%s exited because of uncaught signal %d", cc, WTERMSIG(status));
495 +                               exit(EXIT_FAILURE);
496 +                       }
497 +
498 +                       {
499 +                               char buf[1024], *dir;
500 +                               status = read(gcc_pipe[0], buf, sizeof(buf));
501 +                               close(gcc_pipe[0]);
502 +                               if (status < 0) {
503 +                                       goto crash_n_burn;
504 +                               }
505 +                               dir = dirname(buf);
506 +                               xstrcat(&(crtbegin_path[0]), dir, "/crtbegin.o", NULL);
507 +                               xstrcat(&(crtbegin_path[1]), dir, "/crtbeginS.o", NULL);
508 +                               xstrcat(&(crtend_path[0]), dir, "/crtend.o", NULL);
509 +                               xstrcat(&(crtend_path[1]), dir, "/crtendS.o", NULL);
510 +                       }
511 +
512 +               } else {
513 +                       xstrcat(&(crtbegin_path[0]), LIBGCC_DIR, "crtbegin.o", NULL);
514 +                       xstrcat(&(crtbegin_path[1]), LIBGCC_DIR, "crtbeginS.o", NULL);
515 +                       xstrcat(&(crtend_path[0]), LIBGCC_DIR, "crtend.o", NULL);
516 +                       xstrcat(&(crtend_path[1]), LIBGCC_DIR, "crtendS.o", NULL);
517 +               }
518 +       }
519 +
520 +       if (cplusplus && cpp)
521 +               gcc_argv[i++] = cpp;
522 +       else
523 +#endif
524 +               gcc_argv[i++] = cc;
525 +
526 +       for ( j = 1 ; j < argc ; j++ ) {
527 +               if (argv[j]=='\0') {
528 +                       continue;
529 +               } else {
530 +                       gcc_argument[k++] = argv[j];
531 +                       gcc_argument[k] = '\0';
532 +               }
533 +       }
534 +
535 +       if (linking && source_count) {
536 +#if defined __HAVE_ELF__ && ! defined __UCLIBC_HAS_MMU__
537 +               gcc_argv[i++] = "-Wl,-elf2flt";
538 +#endif
539 +               gcc_argv[i++] = nostdlib;
540 +               if (use_static_linking) {
541 +                       gcc_argv[i++] = static_linking;
542 +               }
543 +               if (!use_static_linking) {
544 +                       if (dlstr && use_build_dir) {
545 +                               gcc_argv[i++] = build_dlstr;
546 +                       } else if (dlstr) {
547 +                               gcc_argv[i++] = dlstr;
548 +                       }
549 +                       if (use_rpath) {
550 +                               gcc_argv[i++] = rpath[use_build_dir];
551 +                       }
552 +               }
553 +               for ( l = 0 ; l < n ; l++ ) {
554 +                       if (libpath[l]) gcc_argv[i++] = libpath[l];
555 +               }
556 +               gcc_argv[i++] = rpath_link[use_build_dir]; /* just to be safe */
557 +               if( libstr )
558 +                       gcc_argv[i++] = libstr;
559 +               gcc_argv[i++] = our_lib_path[use_build_dir];
560 +               if (!use_build_dir) {
561 +                       gcc_argv[i++] = our_usr_lib_path;
562 +               }
563 +       }
564 +       if (use_stdinc && source_count) {
565 +               gcc_argv[i++] = nostdinc;
566 +#ifdef __UCLIBC_CTOR_DTOR__
567 +               if (cplusplus) {
568 +                       char *cppinc;
569 +                       if (use_nostdinc_plus) {
570 +                               gcc_argv[i++] = nostdinc_plus;
571 +                       }
572 +                       xstrcat(&cppinc, uClibc_inc[use_build_dir], "g++/", NULL);
573 +                       gcc_argv[i++] = "-isystem";
574 +                       gcc_argv[i++] = cppinc;
575 +                       xstrcat(&cppinc, uClibc_inc[use_build_dir], "g++-v3/", NULL);
576 +                       gcc_argv[i++] = "-isystem";
577 +                       gcc_argv[i++] = cppinc;
578 +               }
579 +#endif
580 +               gcc_argv[i++] = "-isystem";
581 +               gcc_argv[i++] = uClibc_inc[use_build_dir];
582 +               gcc_argv[i++] = "-iwithprefix";
583 +               gcc_argv[i++] = "include";
584 +               if( incstr )
585 +                       gcc_argv[i++] = incstr;
586 +       }
587 +
588 +       if (linking && source_count) {
589 +
590 +#ifdef __UCLIBC_PROFILING__
591 +               if (profile) {
592 +                       gcc_argv[i++] = gcrt1_path[use_build_dir];
593 +               }
594 +#endif
595 +#ifdef __UCLIBC_CTOR_DTOR__
596 +               if (ctor_dtor) {
597 +                       gcc_argv[i++] = crti_path[use_build_dir];
598 +                       if (use_pic) {
599 +                               gcc_argv[i++] = crtbegin_path[1];
600 +                       } else {
601 +                               gcc_argv[i++] = crtbegin_path[0];
602 +                       }
603 +               }
604 +#endif
605 +               if (use_start) {
606 +#ifdef __UCLIBC_PROFILING__
607 +                       if (!profile)
608 +#endif
609 +                       {
610 +                               gcc_argv[i++] = crt0_path[use_build_dir];
611 +                       }
612 +               }
613 +               for ( l = 0 ; l < k ; l++ ) {
614 +                       if (gcc_argument[l]) gcc_argv[i++] = gcc_argument[l];
615 +               }
616 +               if (use_stdlib) {
617 +                       //gcc_argv[i++] = "-Wl,--start-group";
618 +                       gcc_argv[i++] = "-lgcc";
619 +               }
620 +               for ( l = 0 ; l < m ; l++ ) {
621 +                       if (libraries[l]) gcc_argv[i++] = libraries[l];
622 +               }
623 +               if (use_stdlib) {
624 +#ifdef __UCLIBC_CTOR_DTOR__
625 +                       if (cplusplus) {
626 +                               gcc_argv[ i++ ] = "-lstdc++";
627 +                               gcc_argv[ i++ ] = "-lm";
628 +                       }
629 +#endif
630 +                       gcc_argv[i++] = "-lc";
631 +                       gcc_argv[i++] = "-lgcc";
632 +                       //gcc_argv[i++] = "-Wl,--end-group";
633 +               }
634 +#ifdef __UCLIBC_CTOR_DTOR__
635 +               if (ctor_dtor) {
636 +                       if (use_pic) {
637 +                               gcc_argv[i++] = crtend_path[1];
638 +                       } else {
639 +                               gcc_argv[i++] = crtend_path[0];
640 +                       }
641 +
642 +                       gcc_argv[i++] = crtn_path[use_build_dir];
643 +               }
644 +#endif
645 +       } else {
646 +               for ( l = 0 ; l < k ; l++ ) {
647 +                       if (gcc_argument[l]) gcc_argv[i++] = gcc_argument[l];
648 +               }
649 +       }
650 +       gcc_argv[i++] = NULL;
651 +
652 +       if (verbose) {
653 +               for ( j = 0 ; gcc_argv[j] ; j++ ) {
654 +                       printf("arg[%2i] = %s\n", j, gcc_argv[j]);
655 +               }
656 +               fflush(stdout);
657 +       }
658 +       //no need to free memory from xstrcat because we never return... 
659 +#ifdef __UCLIBC_CTOR_DTOR__
660 +       if (cplusplus && cpp) {
661 +               execvp(cpp, gcc_argv);
662 +               fprintf(stderr, "%s: %s\n", cpp, strerror(errno));
663 +       } else
664 +#endif
665 +       {
666 +               execvp(cc, gcc_argv);
667 +               fprintf(stderr, "%s: %s\n", cc, strerror(errno));
668 +       }
669 +       exit(EXIT_FAILURE);
670 +}
671 diff -urN uClibc-0.9.26.org/extra/gcc-uClibc/Makefile uClibc-0.9.26/extra/gcc-uClibc/Makefile
672 --- uClibc-0.9.26.org/extra/gcc-uClibc/Makefile 1970-01-01 01:00:00.000000000 +0100
673 +++ uClibc-0.9.26/extra/gcc-uClibc/Makefile     2004-01-25 16:06:22.372828491 +0100
674 @@ -0,0 +1,90 @@
675 +# Makefile for building a fake gcc/binutils toolchain
676 +# that simply spoofs the location of the C library
677 +#
678 +# Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
679 +#
680 +
681 +TOPDIR = ../../
682 +include $(TOPDIR)Rules.mak
683 +
684 +UCLIBC_DIR = $(shell (cd ../.. ; /bin/pwd))
685 +GCC_BIN = $(shell which $(CC))
686 +LD_BIN = $(shell which $(LD))
687 +GCCINCDIR:= ${shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp"}
688 +
689 +all: gcc-uClibc ld-uClibc
690 +
691 +gcc-uClibc.h: Makefile $(TOPDIR)/.config
692 +       @echo "/* this file was autogenerated by make */" > gcc-uClibc.h
693 +       @echo "#define UCLIBC_TARGET_PREFIX " \"$(TARGET_PREFIX)\" >> gcc-uClibc.h
694 +       @echo "#define UCLIBC_DEVEL_PREFIX " \"$(DEVEL_PREFIX)\" >> gcc-uClibc.h
695 +       @echo "#define UCLIBC_BUILD_DIR " \"$(UCLIBC_DIR)\" >> gcc-uClibc.h
696 +       @echo "#define GCC_BIN " \"$(GCC_BIN)\" >> gcc-uClibc.h
697 +       @echo "#define LIBGCC_DIR " \"$(LIBGCC_DIR)\" >> gcc-uClibc.h
698 +       @echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> gcc-uClibc.h
699 +       @echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> gcc-uClibc.h
700 +       @echo "#define BUILD_DYNAMIC_LINKER " \"$(UCLIBC_DIR)/lib/$(UCLIBC_LDSO)\" >> gcc-uClibc.h
701 +ifeq ($(strip $(HAVE_SHARED)),y)
702 +       @echo "#define __UCLIBC_HAS_SHARED__ 1" >> gcc-uClibc.h
703 +else
704 +       @echo "#undef __UCLIBC_HAS_SHARED__" >> gcc-uClibc.h
705 +endif
706 +ifeq ($(strip $(UCLIBC_HAS_MMU)),y)
707 +       @echo "#define __UCLIBC_HAS_MMU__ 1" >> gcc-uClibc.h
708 +else
709 +       @echo "#undef __UCLIBC_HAS_MMU__" >> gcc-uClibc.h
710 +endif
711 +ifeq ($(strip $(HAS_ELF)),y)
712 +       @echo "#define __HAS_ELF__ 1" >> gcc-uClibc.h
713 +else
714 +       @echo "#undef __HAS_ELF__" >> gcc-uClibc.h
715 +endif
716 +ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
717 +       @echo "#define __UCLIBC_CTOR_DTOR__ 1" >> gcc-uClibc.h
718 +ifeq ($(strip $(UCLIBC_PROFILING)),y)
719 +       @echo "#define __UCLIBC_PROFILING__ 1" >> gcc-uClibc.h
720 +else
721 +       @echo "#undef __UCLIBC_PROFILING__" >> gcc-uClibc.h
722 +endif
723 +else
724 +       @echo "#undef __UCLIBC_CTOR_DTOR__" >> gcc-uClibc.h
725 +endif
726 +
727 +gcc-uClibc: gcc-uClibc.h gcc-uClibc.c
728 +       $(HOSTCC) $(HOSTCFLAGS) -s gcc-uClibc.c -o $(TARGET_ARCH)-uclibc-gcc
729 +
730 +ld-uClibc:
731 +       @echo "#!/bin/sh" > $(TARGET_ARCH)-uclibc-ld
732 +       @echo "# This file was autogenerated by make" >> $(TARGET_ARCH)-uclibc-ld
733 +       @echo "$(LD_BIN) \$$@ -L$(DEVEL_PREFIX)/usr/lib -L$(DEVEL_PREFIX)/lib "\
734 +               "-L$(UCLIBC_DIR)" >> $(TARGET_ARCH)-uclibc-ld
735 +       chmod a+x $(TARGET_ARCH)-uclibc-ld
736 +
737 +install: all
738 +       install -d $(PREFIX)$(DEVEL_PREFIX)/bin;
739 +       install -d $(PREFIX)$(RUNTIME_PREFIX)/bin;
740 +       install -m 755 $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(RUNTIME_PREFIX)/bin/
741 +       install -m 755 $(TARGET_ARCH)-uclibc-ld $(PREFIX)$(RUNTIME_PREFIX)/bin/
742 +       ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(RUNTIME_PREFIX)/bin/$(TARGET_ARCH)-uclibc-cc
743 +       ln -fs $(RUNTIME_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/gcc
744 +       ln -fs $(RUNTIME_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/cc
745 +       ln -fs $(RUNTIME_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ld  $(PREFIX)$(DEVEL_PREFIX)/bin/ld
746 +ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
747 +       ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(RUNTIME_PREFIX)/bin/$(TARGET_ARCH)-uclibc-g++
748 +       ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(RUNTIME_PREFIX)/bin/$(TARGET_ARCH)-uclibc-c++
749 +       ln -fs $(RUNTIME_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/c++
750 +       ln -fs $(RUNTIME_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_PREFIX)/bin/g++
751 +endif
752 +       for app in addr2line ar as cpp gasp nm objcopy \
753 +           objdump ranlib size strings strip; do \
754 +         APPNAME=`which $(CROSS)$${app}`; \
755 +         if [ -x "$$APPNAME" ] ; then \
756 +         ln -fs "$$APPNAME" $(PREFIX)$(DEVEL_PREFIX)/bin/$${app}; \
757 +         ln -fs "$$APPNAME" $(PREFIX)$(RUNTIME_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
758 +         fi; \
759 +       done
760 +
761 +clean:
762 +       rm -f gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core
763 +
764 +
765 diff -urN uClibc-0.9.26.org/extra/Makefile uClibc-0.9.26/extra/Makefile
766 --- uClibc-0.9.26.org/extra/Makefile    2004-01-25 15:20:33.050030242 +0100
767 +++ uClibc-0.9.26/extra/Makefile        2004-01-25 16:02:02.133944484 +0100
768 @@ -26,7 +26,7 @@
769  LIBC=$(TOPDIR)libc.a
770  
771  
772 -DIRS = 
773 +DIRS = gcc-uClibc
774  EXTRA_DIRS_TO_CLEAN = config
775  
776  all: subdirs
777 diff -urN uClibc-0.9.26.org/Makefile uClibc-0.9.26/Makefile
778 --- uClibc-0.9.26.org/Makefile  2004-01-25 15:20:32.825077096 +0100
779 +++ uClibc-0.9.26/Makefile      2004-01-25 16:45:25.616652058 +0100
780 @@ -28,7 +28,7 @@
781  TOPDIR=./
782  include Rules.mak
783  
784 -DIRS = ldso libc libcrypt libresolv libnsl libutil libm libpthread
785 +DIRS = extra ldso libc libcrypt libresolv libnsl libutil libm libpthread
786  ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
787         DIRS += libintl
788  endif
789 @@ -183,7 +183,7 @@
790  tags:
791         ctags -R
792  
793 -install: install_runtime install_dev finished2
794 +install: install_runtime install_dev install_toolchain finished2
795  
796  
797  # Installs header files and development library links.
798 @@ -302,6 +302,9 @@
799  #      $(INSTALL) -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(RUNTIME_PREFIX)/usr/bin/iconv
800  #endif
801  
802 +install_toolchain:
803 +       $(MAKE) -C extra/gcc-uClibc install
804 +
805  finished2:
806         @echo
807         @echo Finished installing...
This page took 0.125208 seconds and 4 git commands to generate.