commit 4de1ba7

shrub  ·  2026-05-12 17:40:33 +0000 UTC
parent 2589e57
curdir
1 files changed,  +6, -0
+6, -0
 1@@ -222,6 +222,7 @@ loadimprules(struct SufRules *rules, const char *src)
 2 void
 3 seedenv(struct Env *env, int posix, int envoverride)
 4 {
 5+	char *cwd;
 6 	size_t i;
 7 
 8 	envsetvar(env, "CC", xstrdup("cc"), 1, ORIGIN_DEFAULT, 0);
 9@@ -247,6 +248,11 @@ seedenv(struct Env *env, int posix, int envoverride)
10 	envsetvar(env, "SHELL", xstrdup("/bin/sh"), 1, ORIGIN_DEFAULT, 0);
11 	envsetvar(env, "MAKE", xstrdup("make"), 1, ORIGIN_DEFAULT, 0);
12 	envsetvar(env, "RM", xstrdup("rm -f"), 1, ORIGIN_DEFAULT, 0);
13+	cwd = getcwddup();
14+	/*TODO: do this properly, this only expands at evaluation time,
15+	 * unsure about behaviour under directory change condition or 
16+	 * in submakes. should work for most simple cases. */
17+	envsetvar(env, "CURDIR", cwd, 1, ORIGIN_FILE, 0);
18 	if (posix) {
19 		envsetvar(env, "CC", xstrdup("c99"), 1, ORIGIN_DEFAULT, 0);
20 		envsetvar(env, "CFLAGS", xstrdup("-O1"), 1, ORIGIN_DEFAULT, 0);