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