/* Front-end to compile .tlcc program. Works like gcc so one can do cctlcc toto.tlcc -o toto or cctlcc -c toto.tlcc -o toto.o .tlcc are converted to .cpp files and then deleted */ #include #include #include #include #include #include #include #include static void check_exist (const char *path) { struct stat st; if (lstat(path,&st)!=-1){ fprintf (stderr,"file %s exist, won't overwrite, aborting\n",path); exit (-1); } } static bool debug = false; static int cctlcc_execvp (const char *argv0, const char *argv[]) { if (debug){ fprintf (stderr,"execvp %s:",argv0); for (int i=0; argv[i] != NULL; i++) fprintf (stderr," %s",argv[i]); fprintf (stderr,"\n"); } return execvp (argv0,(char**)argv); } static int cctlcc_exec ( const char *cmd, const char *arg1, const char *arg2, const char *opts[]) { int ret = 0; pid_t pid = fork(); if (pid == 0){ int nb=0; if (opts != NULL) for (; opts[nb] != NULL; nb++); const char *argv[nb+4]; argv[0] = cmd; for (int i=0; i