annotate sources/toys/gcc-uClibc.c @ 14:8b4600334a3d

Replace the path finding logic with the stuff from toybox.
author Rob Landley <rob@landley.net>
date Sat, 02 Dec 2006 18:41:17 -0500
parents d34028ce8602
children 7946bc54424b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
1 /* vi: set ts=4 :*/
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
2
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
3 #define TARGET_DIR "gcc/armv4l-unknown-linux/gnu/4.1.1"
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
4
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
5 /*
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
6 * Copyright (C) 2000 Manuel Novoa III
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
7 * Copyright (C) 2002-2003 Erik Andersen
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
8 *
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
9 * Wrapper to use uClibc with gcc, and make gcc relocatable.
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
10 */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
11
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
12 #include <stdio.h>
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
13 #include <stdlib.h>
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
14 #include <stdarg.h>
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
15 #include <string.h>
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
16 #include <unistd.h>
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
17 #include <errno.h>
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
18 #include <sys/stat.h>
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
19 #include <sys/wait.h>
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
20
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
21 static char *topdir;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
22 const char *mypath;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
23 static char static_linking[] = "-static";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
24 static char nostdinc[] = "-nostdinc";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
25 static char nostartfiles[] = "-nostartfiles";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
26 static char nodefaultlibs[] = "-nodefaultlibs";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
27 static char nostdlib[] = "-nostdlib";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
28
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
29 // For C++
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
30 static char nostdinc_plus[] = "-nostdinc++";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
31
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
32
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
33 // Confirm that a regular file exists, and (optionally) has the executable bit.
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
34 int is_file(char *filename, int has_exe)
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
35 {
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
36 // Confirm it has the executable bit set, if necessary.
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
37 if (!has_exe || !access(filename, X_OK)) {
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
38 struct stat st;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
39
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
40 // Confirm it exists and is not a directory.
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
41 if (!stat(filename, &st) && S_ISREG(st.st_mode)) return 1;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
42 }
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
43 return 0;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
44 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
45
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
46 // Find an executable in a colon-separated path
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
47
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
48 char *find_in_path(char *path, char *filename, int has_exe)
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
49 {
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
50 char *cwd = getcwd(NULL, 0);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
51
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
52 if (index(filename, '/') && is_file(filename, has_exe))
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
53 return strdup(filename);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
54
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
55 for (;;) {
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
56 char *str, *next = path ? index(path, ':') : NULL;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
57 int len = next ? next-path : strlen(path);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
58 struct string_list *rnext;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
59 struct stat st;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
60
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
61 str = malloc(strlen(filename) + (len ? len : strlen(cwd)) + 2);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
62 if (!len) sprintf(str, "%s/%s", cwd, filename);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
63 else {
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
64 strncpy(str, path, len);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
65 str += len;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
66 *(str++) = '/';
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
67 strcpy(str, filename);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
68 }
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
69
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
70 // If it's not a directory, return it.
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
71 if (is_file(str, has_exe)) return str;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
72 else free(str);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
73
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
74 if (!next) break;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
75 path += len;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
76 path++;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
77 }
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
78 free(cwd);
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
79
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
80 return NULL;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
81 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
82
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
83 void xstrcat(char **string, ...)
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
84 {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
85 const char *c;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
86 va_list p;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
87 /* Don't bother to calculate how big exerything
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
88 * will be, just be careful to not overflow... */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
89 va_start(p, string);
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
90 *string = malloc(BUFSIZ);
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
91 **string = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
92 while(1) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
93 if (!(c = va_arg(p, const char *)))
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
94 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
95 strcat(*string, c);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
96 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
97 va_end(p);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
98 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
99
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
100 int main(int argc, char **argv)
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
101 {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
102 int use_build_dir = 0, linking = 1, use_static_linking = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
103 int use_stdinc = 1, use_start = 1, use_stdlib = 1, use_pic = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
104 int source_count = 0, use_rpath = 0, verbose = 0;
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
105 int i, j, k, l, m, n, sawM = 0, sawdotoa = 0, sawcES = 0;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
106 char **gcc_argv, **gcc_argument, **libraries, **libpath;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
107 char *dlstr, *incstr, *devprefix, *libstr, *build_dlstr = 0;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
108 char *cc, *ep, *rpath_link[2], *rpath[2], *uClibc_inc[2], *our_lib_path[2];
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
109 char *crt0_path[2], *crtbegin_path[2], *crtend_path[2];
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
110
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
111 // For C++
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
112
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
113 char *crti_path[2], *crtn_path[2], *cpp = NULL;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
114 int len, ctor_dtor = 1, cplusplus = 0, use_nostdinc_plus = 0;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
115
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
116 // For profiling
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
117 int profile = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
118 char *gcrt1_path[2];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
119
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
120 // What directory is the wrapper script in?
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
121 if(!(mypath = find_in_path(getenv("PATH"), argv[0], 1))) {
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
122 fprintf(stderr, "can't find %s in $PATH\n", argv[0]);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
123 exit(1);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
124 // Add that directory to the start of $PATH. (Better safe than sorry.)
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
125 } else {
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
126 char *path = getenv("PATH"), *temp;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
127
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
128 *rindex(mypath,'/') = 0;
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
129 temp = malloc(strlen(mypath)+strlen(path)+7);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
130 sprintf(temp,"PATH=%s:%s",mypath,path);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
131 putenv(temp);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
132 }
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
133
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
134 // What's the name of the C compiler we're wrapping? (It may have a
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
135 // cross-prefix.)
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
136 cc = getenv("UCLIBC_CC");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
137 if (!cc) cc = GCC_BIN;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
138
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
139 topdir = find_in_path("../"TARGET_DIR"/lib:../lib", "ld-uClibc.so.0", 0);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
140 if (!topdir) {
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
141 fprintf(stderr, "unable to find ld-uClibc.so.0 near '%s'\n", mypath);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
142 exit(1);
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
143 }
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
144 *rindex(topdir,'/') = 0;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
145
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
146 // Check end of name, since there could be a cross-prefix on the thing
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
147 len = strlen(argv[0]);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
148 if (!strcmp(argv[0]+len-3, "g++") || !strcmp(argv[0]+len-3, "c++")) {
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
149 len = strlen(cc);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
150 if (strcmp(cc+len-3, "gcc")==0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
151 cpp = strdup(cc);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
152 cpp[len-1]='+';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
153 cpp[len-2]='+';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
154 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
155 cplusplus = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
156 use_nostdinc_plus = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
157 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
158
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
159 devprefix = getenv("UCLIBC_DEVEL_PREFIX");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
160 if (!devprefix) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
161 devprefix = topdir;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
162 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
163
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
164 incstr = getenv("UCLIBC_GCC_INC");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
165 libstr = getenv("UCLIBC_GCC_LIB");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
166
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
167 ep = getenv("UCLIBC_ENV");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
168 if (!ep) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
169 ep = "";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
170 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
171
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
172 if (strstr(ep,"build") != 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
173 use_build_dir = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
174 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
175
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
176 if (strstr(ep,"rpath") != 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
177 use_rpath = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
178 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
179
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
180
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
181 xstrcat(&(rpath_link[0]), "-Wl,-rpath-link,", devprefix, "/lib", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
182
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
183 xstrcat(&(rpath[0]), "-Wl,-rpath,", devprefix, "/lib", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
184
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
185 xstrcat(&(uClibc_inc[0]), devprefix, "/include/", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
186
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
187 //#ifdef CTOR_DTOR
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
188 xstrcat(&(crt0_path[0]), devprefix, "/lib/crt1.o", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
189 xstrcat(&(crti_path[0]), devprefix, "/lib/crti.o", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
190 xstrcat(&(crtn_path[0]), devprefix, "/lib/crtn.o", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
191 //#else
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
192 // xstrcat(&(crt0_path[0]), devprefix, "/lib/crt0.o", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
193 //#endif
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
194
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
195 // profiling
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
196 xstrcat(&(gcrt1_path[0]), devprefix, "/lib/gcrt1.o", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
197
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
198 xstrcat(&(our_lib_path[0]), "-L", devprefix, "/lib", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
199
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
200 // Figure out where the dynamic linker is.
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
201 dlstr = getenv("UCLIBC_GCC_DLOPT");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
202 if (!dlstr) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
203 dlstr = "-Wl,--dynamic-linker," DYNAMIC_LINKER;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
204 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
205
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
206 m = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
207 libraries = __builtin_alloca(sizeof(char*) * (argc));
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
208 libraries[m] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
209
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
210 n = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
211 libpath = __builtin_alloca(sizeof(char*) * (argc));
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
212 libpath[n] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
213
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
214 for ( i = 1 ; i < argc ; i++ ) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
215 if (argv[i][0] == '-' && argv[i][1]) { /* option */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
216 switch (argv[i][1]) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
217 case 'c': /* compile or assemble */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
218 case 'S': /* generate assembler code */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
219 case 'E': /* preprocess only */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
220 case 'M': /* generate dependencies */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
221 linking = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
222 if (argv[i][1] == 'M')
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
223 sawM = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
224 else
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
225 sawcES = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
226 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
227 case 'L': /* library */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
228 libpath[n++] = argv[i];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
229 libpath[n] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
230 if (argv[i][2] == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
231 argv[i] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
232 libpath[n++] = argv[++i];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
233 libpath[n] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
234 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
235 argv[i] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
236 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
237 case 'l': /* library */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
238 libraries[m++] = argv[i];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
239 libraries[m] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
240 argv[i] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
241 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
242 case 'v': /* verbose */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
243 if (argv[i][2] == 0) verbose = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
244 printf("Invoked as %s\n", argv[0]);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
245 printf("Reference path: %s\n", mypath);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
246 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
247 case 'n':
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
248 if (strcmp(nostdinc,argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
249 use_stdinc = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
250 } else if (strcmp(nostartfiles,argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
251 ctor_dtor = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
252 use_start = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
253 } else if (strcmp(nodefaultlibs,argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
254 use_stdlib = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
255 argv[i] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
256 } else if (strcmp(nostdlib,argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
257 ctor_dtor = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
258 use_start = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
259 use_stdlib = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
260 } else if (strcmp(nostdinc_plus,argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
261 if (cplusplus==1) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
262 use_nostdinc_plus = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
263 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
264 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
265 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
266 case 's':
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
267 if (strstr(argv[i],static_linking) != NULL) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
268 use_static_linking = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
269 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
270 if (strcmp("-shared",argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
271 use_start = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
272 use_pic = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
273 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
274 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
275 case 'W': /* -static could be passed directly to ld */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
276 if (strncmp("-Wl,",argv[i],4) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
277 if (strstr(argv[i],static_linking) != 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
278 use_static_linking = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
279 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
280 if (strstr(argv[i],"--dynamic-linker") != 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
281 dlstr = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
282 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
283 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
284 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
285
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
286 // Profiling.
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
287
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
288 case 'p':
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
289 if (strcmp("-pg",argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
290 profile = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
291 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
292 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
293 case 'f':
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
294 /* Check if we are doing PIC */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
295 if (strcmp("-fPIC",argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
296 use_pic = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
297 } else if (strcmp("-fpic",argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
298 use_pic = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
299
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
300 // profiling
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
301 } else if (strcmp("-fprofile-arcs",argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
302 profile = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
303 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
304 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
305
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
306 case '-':
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
307 if (strstr(argv[i]+1,static_linking) != NULL) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
308 use_static_linking = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
309 argv[i]='\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
310 } else if (strcmp("--version",argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
311 printf("uClibc ");
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
312 fflush(stdout);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
313 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
314 } else if (strcmp("--uclibc-use-build-dir",argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
315 use_build_dir = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
316 argv[i]='\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
317 } else if (strcmp("--uclibc-use-rpath",argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
318 use_rpath = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
319 argv[i]='\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
320 } else if (strcmp ("--uclibc-cc", argv[i]) == 0 && argv[i + 1]) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
321 cc = argv[i + 1];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
322 argv[i] = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
323 argv[i + 1] = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
324 } else if (strncmp ("--uclibc-cc=", argv[i], 12) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
325 cc = argv[i] + 12;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
326 argv[i] = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
327 } else if (strcmp("--uclibc-no-ctors",argv[i]) == 0) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
328 ctor_dtor = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
329 argv[i]='\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
330 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
331 break;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
332 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
333 } else { /* assume it is an existing source file */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
334 char *p = strchr (argv[i], '\0') - 2;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
335 if (p > argv[i] && sawM && (strcmp (p, ".o") == 0 || strcmp (p, ".a") == 0))
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
336 sawdotoa = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
337 ++source_count;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
338 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
339 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
340
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
341 if (sawdotoa && sawM && !sawcES)
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
342 linking = 1;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
343
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
344 gcc_argv = __builtin_alloca(sizeof(char*) * (argc + 128));
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
345 gcc_argument = __builtin_alloca(sizeof(char*) * (argc + 20));
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
346
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
347 i = 0; k = 0;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
348 if (ctor_dtor) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
349 xstrcat(&(crtbegin_path[0]), devprefix, "/lib/crtbegin.o", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
350 xstrcat(&(crtbegin_path[1]), devprefix, "/lib/crtbeginS.o", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
351 xstrcat(&(crtend_path[0]), devprefix, "/lib/crtend.o", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
352 xstrcat(&(crtend_path[1]), devprefix, "/lib/crtendS.o", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
353 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
354
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
355 gcc_argv[i++] = cpp ? cpp : cc;
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
356
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
357 if (EXTRAGCCFLAGS) gcc_argv[i++] = EXTRAGCCFLAGS;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
358
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
359 for ( j = 1 ; j < argc ; j++ ) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
360 if (argv[j]=='\0') {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
361 continue;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
362 } else {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
363 gcc_argument[k++] = argv[j];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
364 gcc_argument[k] = '\0';
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
365 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
366 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
367
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
368 if (cplusplus)
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
369 gcc_argv[i++] = "-fno-use-cxa-atexit";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
370
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
371 if (linking && source_count) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
372 //#if defined HAS_ELF && ! defined HAS_MMU
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
373 // gcc_argv[i++] = "-Wl,-elf2flt";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
374 //#endif
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
375 gcc_argv[i++] = nostdlib;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
376 if (use_static_linking) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
377 gcc_argv[i++] = static_linking;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
378 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
379 if (!use_static_linking) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
380 if (dlstr && use_build_dir) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
381 gcc_argv[i++] = build_dlstr;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
382 } else if (dlstr) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
383 gcc_argv[i++] = dlstr;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
384 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
385 if (use_rpath) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
386 gcc_argv[i++] = rpath[use_build_dir];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
387 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
388 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
389 for ( l = 0 ; l < n ; l++ ) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
390 if (libpath[l]) gcc_argv[i++] = libpath[l];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
391 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
392 gcc_argv[i++] = rpath_link[use_build_dir]; /* just to be safe */
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
393 if( libstr )
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
394 gcc_argv[i++] = libstr;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
395 gcc_argv[i++] = our_lib_path[use_build_dir];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
396 if (!use_build_dir) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
397 xstrcat(&(gcc_argv[i++]), "-L", devprefix, "/lib", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
398 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
399 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
400 if (use_stdinc && source_count) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
401 gcc_argv[i++] = nostdinc;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
402
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
403 if (cplusplus) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
404 char *cppinc;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
405 if (use_nostdinc_plus) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
406 gcc_argv[i++] = nostdinc_plus;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
407 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
408 xstrcat(&cppinc, uClibc_inc[use_build_dir], "c++/4.1.1", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
409 gcc_argv[i++] = "-isystem";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
410 gcc_argv[i++] = cppinc;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
411 xstrcat(&cppinc, uClibc_inc[use_build_dir], "c++/4.1.1/" TARGET_DIR, NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
412 gcc_argv[i++] = "-isystem";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
413 gcc_argv[i++] = cppinc;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
414 xstrcat(&cppinc, uClibc_inc[use_build_dir], "c++/4.1.1", NULL);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
415 gcc_argv[i++] = "-isystem";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
416 gcc_argv[i++] = cppinc;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
417 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
418
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
419 gcc_argv[i++] = "-isystem";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
420 gcc_argv[i++] = uClibc_inc[use_build_dir];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
421 gcc_argv[i++] = "-iwithprefix";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
422 gcc_argv[i++] = "include";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
423 if( incstr )
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
424 gcc_argv[i++] = incstr;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
425 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
426
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
427 gcc_argv[i++] = "-U__nptl__";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
428
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
429 if (linking && source_count) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
430
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
431 if (profile) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
432 gcc_argv[i++] = gcrt1_path[use_build_dir];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
433 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
434 if (ctor_dtor) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
435 gcc_argv[i++] = crti_path[use_build_dir];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
436 if (use_pic) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
437 gcc_argv[i++] = crtbegin_path[1];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
438 } else {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
439 gcc_argv[i++] = crtbegin_path[0];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
440 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
441 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
442 if (use_start) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
443 if (!profile) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
444 gcc_argv[i++] = crt0_path[use_build_dir];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
445 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
446 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
447 for ( l = 0 ; l < k ; l++ ) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
448 if (gcc_argument[l]) gcc_argv[i++] = gcc_argument[l];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
449 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
450 if (use_stdlib) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
451 //gcc_argv[i++] = "-Wl,--start-group";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
452 gcc_argv[i++] = "-lgcc";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
453 gcc_argv[i++] = "-lgcc_eh";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
454 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
455 for ( l = 0 ; l < m ; l++ ) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
456 if (libraries[l]) gcc_argv[i++] = libraries[l];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
457 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
458 if (use_stdlib) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
459 if (cplusplus) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
460 gcc_argv[ i++ ] = "-lstdc++";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
461 gcc_argv[ i++ ] = "-lm";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
462 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
463 gcc_argv[i++] = "-lc";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
464 gcc_argv[i++] = "-lgcc";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
465 gcc_argv[i++] = "-lgcc_eh";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
466 //gcc_argv[i++] = "-Wl,--end-group";
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
467 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
468 if (ctor_dtor) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
469 if (use_pic) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
470 gcc_argv[i++] = crtend_path[1];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
471 } else {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
472 gcc_argv[i++] = crtend_path[0];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
473 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
474
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
475 gcc_argv[i++] = crtn_path[use_build_dir];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
476 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
477 } else {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
478 for ( l = 0 ; l < k ; l++ ) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
479 if (gcc_argument[l]) gcc_argv[i++] = gcc_argument[l];
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
480 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
481 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
482 gcc_argv[i++] = NULL;
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
483
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
484 if (verbose) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
485 for ( j = 0 ; gcc_argv[j] ; j++ ) {
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
486 printf("arg[%2i] = %s\n", j, gcc_argv[j]);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
487 }
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
488 fflush(stdout);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
489 }
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
490
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
491 //no need to free memory from xstrcat because we never return...
14
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
492 execvp(cpp ? cpp : cc, gcc_argv);
8b4600334a3d Replace the path finding logic with the stuff from toybox.
Rob Landley <rob@landley.net>
parents: 13
diff changeset
493 fprintf(stderr, "%s: %s\n", cpp ? cpp : cc, strerror(errno));
13
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
494 exit(EXIT_FAILURE);
d34028ce8602 A version of the old uClibc wrapper script, which Chris Faylor maintained for
Rob Landley <rob@landley.net>
parents:
diff changeset
495 }