diff --git a/Makefile b/Makefile index 536f36b6..d5ed50d7 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,8 @@ MANPATH?=$(PREFIX)/share/man/man1/ DEBUGGER=gdb CFLAGS=-std=c99 -Wall -Wextra -Isrc/include -fpic -O2 -fvisibility=hidden \ - -DJANET_BUILD=$(JANET_BUILD) + -DJANET_BUILD=$(JANET_BUILD) \ + -DJANET_DEFAULT_PATH="\"$(JANET_PATH)\"" UNAME:=$(shell uname -s) ifeq ($(UNAME), Darwin) diff --git a/src/core/core.janet b/src/core/core.janet index 30dd0c3a..a8d4d02f 100644 --- a/src/core/core.janet +++ b/src/core/core.janet @@ -1605,7 +1605,9 @@ value, one key will be ignored." and if that is not set /usr/local/lib/janet on linux/posix, and on Windows the default is the empty string." (or (os/getenv "JANET_PATH") - (if (= :windows (os/which)) "" "/usr/local/lib/janet"))) + (if (= :windows (os/which)) "" JANET_DEFAULT_PATH))) + +(put _env 'JANET_DEFAULT_PATH nil) (defn- fexists [path] (def f (file/open path)) diff --git a/src/core/corelib.c b/src/core/corelib.c index 546d2a32..bce59665 100644 --- a/src/core/corelib.c +++ b/src/core/corelib.c @@ -761,6 +761,8 @@ JanetTable *janet_core_env(void) { #endif #ifdef JANET_BOOTSTRAP + /* Let the bootstrap program know where to set the default path */ + janet_core_def(env, "JANET_DEFAULT_PATH", janet_cstringv(JANET_DEFAULT_PATH), NULL); /* Run bootstrap source */ janet_dobytes(env, janet_gen_core, janet_gen_core_size, "core.janet", NULL); #else