summaryrefslogtreecommitdiff
blob: 94c6a41b3af6d671a4e28f4089d8c3bb883928f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Index: services/job.h
===================================================================
--- services/job.h	(revision 843731)
+++ services/job.h	(working copy)
@@ -57,6 +57,10 @@
 
     unsigned int argumentFlags() const;
 
+	const ArgumentsList getFlags() {
+		return m_flags;
+	}
+
     void setFlags( const ArgumentsList &flags ) {
         m_flags = flags;
     }
Index: client/main.cpp
===================================================================
--- client/main.cpp	(revision 843731)
+++ client/main.cpp	(working copy)
@@ -218,6 +218,39 @@
 
     local |= analyse_argv( argv, job );
 
+	/* honour Gentoo's ${CFLAGS_${ABI}} environment variable */
+	if (getenv("ABI") != NULL) {
+		char* envar = (char*) malloc(sizeof(char) * 
+										(strlen("CFLAGS_") + strlen(getenv("ABI")) + 1));
+		
+		if (!envar)
+			return 1;
+
+		/* We use CFLAGS_${ABI} for gcc, g++, g77, etc as they are
+		 * the same no matter which compiler we are using.
+		 */
+		sprintf(envar, "CFLAGS_%s", getenv("ABI"));
+
+		if (getenv(envar)) {
+			ArgumentsList args = job.getFlags();
+
+			char* pch = strtok(getenv(envar)," \t");
+			while (pch != NULL) {
+				#if CLIENT_DEBUG
+			    	log_info() << "adding CFLAG '" << pch << "' as specified in environment variable ${CFLAGS_${ABI}}" << endl;
+				#endif
+				args.append(pch, Arg_Remote);
+				pch = strtok(NULL, " \t");
+			}
+
+			job.setFlags(args);
+
+			free(pch);
+		}
+
+		free(envar);
+	}
+
     /* if ICECC is set to no, then run job locally */
     char* icecc = getenv("ICECC");
     if ( icecc && !strcasecmp(icecc, "no") )