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
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;
15 stripped_args = args_init(0, NULL);
17 @@ -702,6 +709,18 @@ static void process_args(int argc, char
21 + /* These options require special handling, because they
22 + behave differently with gcc -E, when the output
23 + file is not specified. */
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;
33 /* options that take an argument */
35 const char *opts[] = {"-I", "-include", "-imacros", "-iprefix",
36 @@ -812,6 +831,41 @@ static void process_args(int argc, char
38 p[1] = found_S_opt ? 's' : 'o';
42 + /* If dependencies are generated, configure the preprocessor */
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, '.');
50 + if (strlen(p) < 2) {
51 + stats_update(STATS_ARGS);
58 + int len = p - default_depfile_name;
60 + p = x_malloc(len + 3);
61 + strncpy(default_depfile_name, p, len - 1);
62 + free(default_depfile_name);
63 + default_depfile_name = p;
66 + strcat(default_depfile_name, ".d");
67 + args_add(stripped_args, "-MF");
68 + args_add(stripped_args, default_depfile_name);
71 + if (!dependency_target_specified) {
72 + args_add(stripped_args, "-MT");
73 + args_add(stripped_args, output_file);
77 /* cope with -o /dev/null */