PageRenderTime 28ms CodeModel.GetById 21ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/CCache/debian/patches/06_md.diff

#
Unknown | 77 lines | 73 code | 4 blank | 0 comment | 0 complexity | 931e3f89290ddb668d787db3a9e985c4 MD5 | raw file
 1--- ccache.c	Mon Sep 13 11:38:30 2004
 2+++ ccache.c	Thu Jun 21 22:17:32 2007
 3@@ -627,6 +627,13 @@ static void process_args(int argc, char 
 4 	int found_S_opt = 0;
 5 	struct stat st;
 6 	char *e;
 7+	/* is gcc being asked to output dependencies? */
 8+	int generating_dependencies = 0;
 9+	/* is the dependency makefile name overridden with -MF? */
10+	int dependency_filename_specified = 0;
11+	/* is the dependency makefile target name specified with -MQ or -MF? */
12+	int dependency_target_specified = 0;
13+
14 
15 	stripped_args = args_init(0, NULL);
16 
17@@ -702,6 +709,18 @@ static void process_args(int argc, char 
18 			continue;
19 		}
20 
21+		/* These options require special handling, because they
22+		   behave differently with gcc -E, when the output
23+		   file is not specified. */
24+
25+		if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) {
26+			generating_dependencies = 1;
27+		} else if (strcmp(argv[i], "-MF") == 0) {
28+			dependency_filename_specified = 1;
29+		} else if (strcmp(argv[i], "-MQ") == 0 || strcmp(argv[i], "-MT") == 0) {
30+			dependency_target_specified = 1;
31+		}
32+
33 		/* options that take an argument */
34 		{
35 			const char *opts[] = {"-I", "-include", "-imacros", "-iprefix",
36@@ -812,6 +831,41 @@ static void process_args(int argc, char 
37 		}
38 		p[1] = found_S_opt ? 's' : 'o';
39 		p[2] = 0;
40+	}
41+
42+	/* If dependencies are generated, configure the preprocessor */
43+
44+	if (generating_dependencies && output_file) {
45+		if (!dependency_filename_specified) {
46+			char *default_depfile_name = x_strdup(output_file);
47+			char *p = strrchr(default_depfile_name, '.');
48+
49+			if (p) {
50+				if (strlen(p) < 2) {
51+					stats_update(STATS_ARGS);
52+					failed();
53+					return;
54+				}
55+				*p = 0;
56+			}
57+			else  {
58+				int len = p - default_depfile_name;
59+				
60+				p = x_malloc(len + 3);
61+				strncpy(default_depfile_name, p, len - 1);
62+				free(default_depfile_name);
63+				default_depfile_name = p;
64+			}
65+
66+			strcat(default_depfile_name, ".d");
67+			args_add(stripped_args, "-MF");
68+			args_add(stripped_args, default_depfile_name);
69+		}
70+
71+		if (!dependency_target_specified) {
72+			args_add(stripped_args, "-MT");
73+			args_add(stripped_args, output_file);
74+		}
75 	}
76 
77 	/* cope with -o /dev/null */