lib9: pass $PLAN9_TARGET via CPP for get9root fallback value

Allows this function to always return the proper path in situations
where the $PLAN9 environment variable is not set, i.e. a rc login shell.
This commit is contained in:
Sören Tempel 2021-10-31 06:01:30 +01:00 committed by Dan Cross
parent f7b572818c
commit 521fc08180
3 changed files with 5 additions and 3 deletions

View file

@ -11,7 +11,6 @@ get9root(void)
if((s = getenv("PLAN9")) != 0)
return s;
/* could do better - search $PATH */
s = "/usr/local/plan9";
s = PLAN9_TARGET;
return s;
}

View file

@ -175,6 +175,9 @@ HFILES=\
%.$O: utf/%.c
$CC $CFLAGS utf/$stem.c
get9root.$O: get9root.c
$CC $CFLAGS -DPLAN9_TARGET=\"$PLAN9_TARGET\" get9root.c
XLIB=$PLAN9/lib/$LIB
testfmt: testfmt.$O $XLIB

View file

@ -36,7 +36,7 @@ echo cd `pwd`
9c exitcode.c
9c fcallfmt.c
9c frand.c
9c get9root.c
9c -DPLAN9_TARGET=\"$PLAN9_TARGET\" get9root.c
9c getcallerpc.c
9c getenv.c
9c getfields.c