5 /* find the real compiler */
6 find_compiler(argc, argv);
8 + /* use the real compiler if HOME is not set */
10 + cc_log("Unable to determine home directory\n");
11 + cc_log("ccache is disabled\n");
15 /* we might be disabled */
16 if (getenv("CCACHE_DISABLE")) {
18 printf("-V print version number\n");
21 +static void check_cache_dir(void)
24 + fatal("Unable to determine home directory");
28 /* the main program when not doing a compile */
29 static int ccache_main(int argc, char *argv[])
41 cleanup_all(cache_dir);
42 printf("Cleaned cache\n");
48 printf("Cleared cache\n");
54 printf("Statistics cleared\n");
60 stats_set_limits(v, -1);
61 printf("Set cache file limit to %u\n", (unsigned)v);
66 v = value_units(optarg);
67 stats_set_limits(-1, v);
68 printf("Set cache size limit to %uk\n", (unsigned)v);
71 cache_dir = getenv("CCACHE_DIR");
73 - x_asprintf(&cache_dir, "%s/.ccache", get_home_directory());
74 + const char *home_directory = get_home_directory();
75 + if (home_directory) {
76 + x_asprintf(&cache_dir, "%s/.ccache", home_directory);
80 temp_dir = getenv("CCACHE_TEMPDIR");
84 /* make sure the cache dir exists */
85 - if (create_dir(cache_dir) != 0) {
86 + if (cache_dir && (create_dir(cache_dir) != 0)) {
87 fprintf(stderr,"ccache: failed to create %s (%s)\n",
88 cache_dir, strerror(errno));
96 - fatal("Unable to determine home directory");
97 + cc_log("Unable to determine home directory");