[uClibc-cvs] uClibc/extra/gcc-uClibc gcc-uClibc.c,1.57,1.58

Erik Andersen andersen at uclibc.org
Tue Jun 24 07:40:08 UTC 2003


Update of /var/cvs/uClibc/extra/gcc-uClibc
In directory winder:/tmp/cvs-serv21826

Modified Files:
	gcc-uClibc.c 
Log Message:
Rename the very badly named 'UCLIBC_GCC' to 'UCLIBC_ENV' and
implement 'UCLIBC_CC', which does this:

$ UCLIBC_CC=gcc-2.95 /usr/i386-linux-uclibc/bin/i386-uclibc-gcc --version
2.95.4

$ UCLIBC_CC=gcc-3.3 /usr/i386-linux-uclibc/bin/i386-uclibc-gcc --version
gcc-3.3 (GCC) 3.3 (Debian)
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



Index: gcc-uClibc.c
===================================================================
RCS file: /var/cvs/uClibc/extra/gcc-uClibc/gcc-uClibc.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- gcc-uClibc.c	28 May 2003 07:47:51 -0000	1.57
+++ gcc-uClibc.c	24 Jun 2003 07:40:05 -0000	1.58
@@ -24,12 +24,12 @@
  * If you want to use the uninstalled header files and libs, either include
  * the string "build" in the invocation name such as
  *       'ln -s <ARCH>-uclibc-gcc <ARCH>-uclibc-gcc-build'
- * or include it in the environment variable setting of UCLIBC_GCC.
+ * or include it in the environment variable setting of UCLIBC_ENV.
  * Note: This automatically enables the "rpath" behavior described below.
  *
  * The wrapper will now pass the location of the uClibc shared libs used to
  * the linker with the "-rpath" option if the invocation name includes the
- * string "rpath" or if the environment variable UCLIBC_GCC include it (as
+ * string "rpath" or if the environment variable UCLIBC_ENV include it (as
  * with "build" above).  This is primarily intended to be used on devel
  * platforms of the same arch as the target.  A good place to use this feature
  * would be in the uClibc/test directory.
@@ -39,7 +39,7 @@
  * May 31, 2001
  *
  * "rpath" and "build" behavior are now decoupled.  You can of course get
- * the old "build" behavior by setting UCLIBC_GCC="rpath-build".  Order
+ * the old "build" behavior by setting UCLIBC_ENV="rpath-build".  Order
  * isn't important here, as only the substrings are searched for.
  *
  * Added environment variable check for UCLIBC_GCC_DLOPT to let user specify
@@ -187,6 +187,7 @@
 	char *builddir;
 	char *libstr;
 	char *build_dlstr = 0;
+	char *cc;
 	char *ep;
 	char *rpath_link[2];
 	char *rpath[2];
@@ -208,6 +209,11 @@
 	char *gcrt1_path[2];
 #endif
 
+	cc     = getenv("UCLIBC_CC");
+	if (!cc) {
+		cc = GCC_BIN;
+	}
+
 	application_name = basename(argv[0]);
 	if (application_name[0] == '-')
 		application_name++;
@@ -221,10 +227,9 @@
 	len = strlen(application_name);
 	if ((strcmp(application_name+len-3, "g++")==0) ||
 		(strcmp(application_name+len-3, "c++")==0)) {
-	    char *gcc_bin = GCC_BIN;
-	    len = strlen(gcc_bin);
-	    if (strcmp(gcc_bin+len-3, "gcc")==0) {
-		GPLUSPLUS_BIN = strdup(gcc_bin);
+	    len = strlen(cc);
+	    if (strcmp(cc+len-3, "gcc")==0) {
+		GPLUSPLUS_BIN = strdup(cc);
 		GPLUSPLUS_BIN[len-1]='+';
 		GPLUSPLUS_BIN[len-2]='+';
 	    }
@@ -246,6 +251,20 @@
 	incstr = getenv("UCLIBC_GCC_INC");
 	libstr = getenv("UCLIBC_GCC_LIB");
 
+	ep     = getenv("UCLIBC_ENV");
+	if (!ep) {
+		ep = "";
+	}
+
+	if (strstr(ep,"build") != 0) {
+		use_build_dir = 1;
+	}
+
+	if (strstr(ep,"rpath") != 0) {
+		use_rpath = 1;
+	}
+
+
 	xstrcat(&(rpath_link[0]), "-Wl,-rpath-link,", devprefix, "/lib", NULL);
 	xstrcat(&(rpath_link[1]), "-Wl,-rpath-link,", builddir, "/lib", NULL);
 
@@ -282,19 +301,6 @@
 	}
 #endif
 
-	ep = getenv("UCLIBC_GCC");
-	if (!ep) {
-		ep = "";
-	}
-
-	if (strstr(ep,"build") != 0) {
-		use_build_dir = 1;
-	}
-
-	if (strstr(ep,"rpath") != 0) {
-		use_rpath = 1;
-	}
-
 	m = 0;
 	libraries = __builtin_alloca(sizeof(char*) * (argc));
 	libraries[m] = '\0';
@@ -443,7 +449,7 @@
 		    close(2);
 		    dup2(gcc_pipe[1], 1);
 		    dup2(gcc_pipe[1], 2);
-		    argv[0] = GCC_BIN; 
+		    argv[0] = cc; 
 		    argv[2] = "-print-libgcc-file-name";
 		    argv[3] = NULL;
 		    execvp(argv[0], argv);
@@ -485,7 +491,7 @@
 	    gcc_argv[i++] = GPLUSPLUS_BIN;
 	else
 #endif
-	    gcc_argv[i++] = GCC_BIN;
+	    gcc_argv[i++] = cc;
 	
 	for ( j = 1 ; j < argc ; j++ ) {
 		if (argv[j]=='\0') {
@@ -625,5 +631,5 @@
 	    return execvp(GPLUSPLUS_BIN, gcc_argv);
 	else
 #endif
-	    return execvp(GCC_BIN, gcc_argv);
+	    return execvp(cc, gcc_argv);
 }



More information about the uClibc-cvs mailing list