From 7d6af5f4c7663bddf4dad4a58c770dbdd299e022 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 11 Feb 2024 22:12:21 -0500 Subject: [PATCH] Handle LDLIBS as a separate thing --- nextlang.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nextlang.c b/nextlang.c index aa0a42b..aa1c1e9 100644 --- a/nextlang.c +++ b/nextlang.c @@ -112,9 +112,17 @@ int main(int argc, char *argv[]) fclose(out); } - const char *flags = getenv("CFLAGS"); - if (!flags) flags = "-std=c11 -lm -lgc -lcord"; - const char *run = heap_strf(verbose ? "tcc %s -run - | bat --file-name=output.txt" : "tcc %s -run -", flags); + const char *cflags = getenv("CFLAGS"); + if (!cflags) + cflags = "-std=c11"; + + const char *ldlibs = "-lgc -lcord -lm"; + if (getenv("LDLIBS")) + ldlibs = heap_strf("%s %s", ldlibs, getenv("LDLIBS")); + + const char *run = heap_strf("tcc %s %s -run -", cflags, ldlibs); + if (verbose) + run = heap_strf("%s | bat --file-name=STDOUT", run); FILE *cc = popen(run, "w"); CORD_put(program, cc); fclose(cc);