#include #include #include #include #include #include #include extern const char *__progname; int main (int ac, char **argv) { char *suffix = "", *target_name, *bin_name, *path; const char *call_name = __progname; const char *version = getenv ("GCC_VERSION"); const char *use_ccache = getenv ("GCC_USE_CCACHE"); if (!strcmp (__progname, "gcc_wrapper")) error (EXIT_FAILURE, 0, "try gcc instead"); if (!strcmp (__progname, "cc")) call_name = "gcc"; else if (!strcmp (__progname, "c++")) call_name = "g++"; else if (!strcmp (__progname, "f77")) call_name = "g77"; else if (strlen (__progname) > 4 && !strncmp (__progname, "gcj-", 4)) call_name = __progname + 4; while (version && *version && isspace (*version)) version++; while (use_ccache && *use_ccache && isspace (*use_ccache)) use_ccache++; if (version && *version) { if (asprintf (&suffix, "-%s", version) < 0) error (EXIT_FAILURE, errno, "asprintf"); } if (asprintf (&target_name, "%s-%s%s", TARGET, call_name, suffix) < 0) error (EXIT_FAILURE, errno, "asprintf"); if (use_ccache && *use_ccache) bin_name = "ccache"; else bin_name = target_name; if (asprintf (&path, "%s/%s", BINDIR, bin_name) < 0) error (EXIT_FAILURE, errno, "asprintf"); argv[0] = target_name; execv (path, argv); perror (path); return EXIT_FAILURE; }