source $PLAN9/config
diff --git a/bin/9c b/bin/9c
index 6ff417a..fcdae6f 100755
--- a/bin/9c
+++ b/bin/9c
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+test -f $PLAN9/config && . $PLAN9/config
 usegcc()
 {
 	cc=gcc
diff --git a/bin/9l b/bin/9l
index cd3d0ac..7ea689d 100755
--- a/bin/9l
+++ b/bin/9l
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+test -f $PLAN9/config && . $PLAN9/config
 libsl=""
 
 doautolib=true
@@ -173,7 +174,7 @@
 *Linux*)
 	ld=gcc
 	extralibs="$extralibs -lutil"
-	case "`uname -r`" in
+	case "${SYSVERSION:-`uname -r`}" in
 	2.6.*)
 		extralibs="$extralibs -lpthread"
 		;;