From a1593ad8e4bdbd5f821cf9006587f2ff97dd965f Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 24 Feb 2024 15:31:26 -0500 Subject: Make CC an environment variable that's read from --- nextlang.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'nextlang.c') diff --git a/nextlang.c b/nextlang.c index 62a3feec..0e52a790 100644 --- a/nextlang.c +++ b/nextlang.c @@ -79,11 +79,13 @@ int main(int argc, char *argv[]) const char *ldflags = "-Wl,-rpath '-Wl,$ORIGIN'"; - // const char *run = heap_strf("tcc -run %s %s %s -", cflags, ldflags, ldlibs); - const char *run = heap_strf("gcc -x c %s %s %s - -o program && ./program", cflags, ldflags, ldlibs); - FILE *cc = popen(run, "w"); - CORD_put(program, cc); - fclose(cc); + const char *cc = getenv("CC"); + if (!cc) cc = "tcc"; + const char *run = streq(cc, "tcc") ? heap_strf("tcc -run %s %s %s -", cflags, ldflags, ldlibs) + : heap_strf("gcc -x c %s %s %s - -o program && ./program", cflags, ldflags, ldlibs); + FILE *runner = popen(run, "w"); + CORD_put(program, runner); + fclose(runner); return 0; } -- cgit v1.2.3