PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 1ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  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. stripped_args = args_init(0, NULL);
  15. @@ -702,6 +709,18 @@ static void process_args(int argc, char
  16. continue;
  17. }
  18. + /* These options require special handling, because they
  19. + behave differently with gcc -E, when the output
  20. + file is not specified. */
  21. +
  22. + if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) {
  23. + generating_dependencies = 1;
  24. + } else if (strcmp(argv[i], "-MF") == 0) {
  25. + dependency_filename_specified = 1;
  26. + } else if (strcmp(argv[i], "-MQ") == 0 || strcmp(argv[i], "-MT") == 0) {
  27. + dependency_target_specified = 1;
  28. + }
  29. +
  30. /* options that take an argument */
  31. {
  32. const char *opts[] = {"-I", "-include", "-imacros", "-iprefix",
  33. @@ -812,6 +831,41 @@ static void process_args(int argc, char
  34. }
  35. p[1] = found_S_opt ? 's' : 'o';
  36. p[2] = 0;
  37. + }
  38. +
  39. + /* If dependencies are generated, configure the preprocessor */
  40. +
  41. + if (generating_dependencies && output_file) {
  42. + if (!dependency_filename_specified) {
  43. + char *default_depfile_name = x_strdup(output_file);
  44. + char *p = strrchr(default_depfile_name, '.');
  45. +
  46. + if (p) {
  47. + if (strlen(p) < 2) {
  48. + stats_update(STATS_ARGS);
  49. + failed();
  50. + return;
  51. + }
  52. + *p = 0;
  53. + }
  54. + else {
  55. + int len = p - default_depfile_name;
  56. +
  57. + p = x_malloc(len + 3);
  58. + strncpy(default_depfile_name, p, len - 1);
  59. + free(default_depfile_name);
  60. + default_depfile_name = p;
  61. + }
  62. +
  63. + strcat(default_depfile_name, ".d");
  64. + args_add(stripped_args, "-MF");
  65. + args_add(stripped_args, default_depfile_name);
  66. + }
  67. +
  68. + if (!dependency_target_specified) {
  69. + args_add(stripped_args, "-MT");
  70. + args_add(stripped_args, output_file);
  71. + }
  72. }
  73. /* cope with -o /dev/null */