autolib
diff --git a/include/bin.h b/include/bin.h
index dc738f1..139e6bf 100644
--- a/include/bin.h
+++ b/include/bin.h
@@ -4,6 +4,8 @@
 extern "C" { 
 #endif
 
+AUTOLIB(bin)
+
 /*
 #pragma	lib	"libbin.a"
 #pragma	src	"/sys/src/libbin"
diff --git a/include/bio.h b/include/bio.h
index bd52901..2c2b956 100644
--- a/include/bio.h
+++ b/include/bio.h
@@ -4,6 +4,8 @@
 extern "C" { 
 #endif
 
+AUTOLIB(bio)
+
 #include <sys/types.h>	/* for off_t */
 #include <fcntl.h>	/* for O_RDONLY, O_WRONLY */
 
diff --git a/include/complete.h b/include/complete.h
index ae8003d..92ed147 100644
--- a/include/complete.h
+++ b/include/complete.h
@@ -1,3 +1,10 @@
+#ifndef _COMPLETE_H_
+#define _COMPLETE_H_ 1
+#if defined(__cplusplus)
+extern "C" { 
+#endif
+
+AUTOLIB(complete)
 /*
 #pragma	lib	"libcomplete.a"
 #pragma src "/sys/src/libcomplete"
@@ -16,3 +23,8 @@
 
 Completion* complete(char *dir, char *s);
 void freecompletion(Completion*);
+
+#if defined(__cplusplus)
+}
+#endif
+#endif
diff --git a/include/disk.h b/include/disk.h
index a887866..7e1d35a 100644
--- a/include/disk.h
+++ b/include/disk.h
@@ -1,6 +1,13 @@
-#pragma src "/sys/src/libdisk"
-#pragma lib "libdisk.a"
+#ifndef _DISK_H_
+#define _DISK_H_ 1
+#if defined(__cplusplus)
+extern "C" { 
+#endif
 
+
+AUTOLIB(disk)
+
+#if 0
 /* SCSI interface */
 typedef struct Scsi Scsi;
 struct Scsi {
@@ -58,8 +65,14 @@
 	Gdisk,
 	Gguess,
 };
+#endif
 
 /* proto file parsing */
 typedef void Protoenum(char *new, char *old, Dir *d, void *a);
 typedef void Protowarn(char *msg, void *a);
 int rdproto(char*, char*, Protoenum*, Protowarn*, void*);
+
+#if defined(__cplusplus)
+}
+#endif
+#endif
diff --git a/include/draw.h b/include/draw.h
index 4898e31..af58b31 100644
--- a/include/draw.h
+++ b/include/draw.h
@@ -4,6 +4,8 @@
 extern "C" { 
 #endif
 
+AUTOLIB(draw)
+
 typedef struct	Cachefont Cachefont;
 typedef struct	Cacheinfo Cacheinfo;
 typedef struct	Cachesubf Cachesubf;
@@ -338,7 +340,7 @@
 extern Image*	namedimage(Display*, char*);
 extern int	nameimage(Image*, char*, int);
 extern Image* allocimagemix(Display*, u32int, u32int);
-extern int	drawsetlabel(Display*, char*);
+extern int	drawsetlabel(char*);
 
 /*
  * Colors
diff --git a/include/flate.h b/include/flate.h
index bbd0b3d..8fcc173 100644
--- a/include/flate.h
+++ b/include/flate.h
@@ -3,6 +3,8 @@
 #if defined(__cplusplus)
 extern "C" { 
 #endif
+
+AUTOLIB(flate)
 /*
 #pragma	lib	"libflate.a"
 #pragma	src	"/sys/src/libflate"
diff --git a/include/frame.h b/include/frame.h
index 47d808c..a3291a7 100644
--- a/include/frame.h
+++ b/include/frame.h
@@ -4,6 +4,8 @@
 extern "C" { 
 #endif
 
+AUTOLIB(frame)
+
 typedef struct Frbox Frbox;
 typedef struct Frame Frame;
 
diff --git a/include/fs.h b/include/fs.h
deleted file mode 100644
index 3844270..0000000
--- a/include/fs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef _FS_H_
-#define _FS_H_ 1
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Simple user-level 9P client.
- */
-
-typedef struct Fsys Fsys;
-typedef struct Fid Fid;
-
-Fsys *fsinit(int);
-Fsys *fsmount(int, char*);
-
-int fsversion(Fsys*, int, char*, int);
-Fid *fsauth(Fsys*, char*);
-Fid *fsattach(Fsys*, Fid*, char*, char*);
-Fid *fsopen(Fsys*, char*, int);
-int fsopenfd(Fsys*, char*, int);
-long fsread(Fid*, void*, long);
-long fsreadn(Fid*, void*, long);
-long fswrite(Fid*, void*, long);
-void fsclose(Fid*);
-void fsunmount(Fsys*);
-int fsrpc(Fsys*, Fcall*, Fcall*, void**);
-Fid *fswalk(Fid*, char*);
-struct Dir;	/* in case there's no lib9.h */
-long fsdirread(Fid*, struct Dir**);
-long fsdirreadall(Fid*, struct Dir**);
-struct Dir *fsdirstat(Fsys*, char*);
-struct Dir *fsdirfstat(Fid*);
-int fsdirwstat(Fsys*, char*, struct Dir*);
-int fsdirfwstat(Fid*, struct Dir*);
-Fid *fsroot(Fsys*);
-Fsys *nsmount(char*, char*);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/include/html.h b/include/html.h
index 0bcf3b5..1d5dd6b 100644
--- a/include/html.h
+++ b/include/html.h
@@ -4,6 +4,7 @@
 extern "C" {
 #endif
 
+AUTOLIB(html)
 /*
  #pragma lib "libhtml.a"
  #pragma src "/sys/src/libhtml"
diff --git a/include/httpd.h b/include/httpd.h
index 7f33251..e968d5e 100644
--- a/include/httpd.h
+++ b/include/httpd.h
@@ -3,6 +3,8 @@
 #if defined(__cplusplus)
 extern "C" { 
 #endif
+
+AUTOLIB(httpd)
 /*
 #pragma	lib	"libhttpd.a"
 #pragma	src	"/sys/src/libhttpd"
diff --git a/include/ip.h b/include/ip.h
index 36b3635..b6843e7 100644
--- a/include/ip.h
+++ b/include/ip.h
@@ -4,6 +4,7 @@
 extern "C" { 
 #endif
 
+AUTOLIB(ip)
 /*
 #pragma	src	"/sys/src/libip"
 #pragma	lib	"libip.a"
diff --git a/include/libString.h b/include/libString.h
index 1a560b6..ad782b4 100644
--- a/include/libString.h
+++ b/include/libString.h
@@ -1,7 +1,14 @@
+#ifndef _LIBSTRING_H_
+#define _LIBSTRING_H_ 1
+#if defined(__cplusplus)
+extern "C" { 
+#endif
+
 /*
 #pragma	src	"/sys/src/libString"
 #pragma	lib	"libString.a"
 */
+AUTOLIB(String)
 
 /* extensible Strings */
 typedef struct String {
@@ -44,3 +51,7 @@
 extern Sinstack	*s_allocinstack(char*);
 extern void	s_freeinstack(Sinstack*);
 #endif /* BGETC */
+#if defined(__cplusplus)
+}
+#endif
+#endif
diff --git a/include/libsec.h b/include/libsec.h
index e598a78..008a283 100644
--- a/include/libsec.h
+++ b/include/libsec.h
@@ -8,6 +8,8 @@
 #pragma	src	"/sys/src/libsec"
 */
 
+AUTOLIB(sec)
+
 #ifndef _MPINT
 typedef struct mpint mpint;
 #endif
diff --git a/include/mach.h b/include/mach.h
index 23089e4..0f1a5ae 100644
--- a/include/mach.h
+++ b/include/mach.h
@@ -1,3 +1,11 @@
+#ifndef _MACH_H_
+#define _MACH_H_ 1
+#if defined(__cplusplus)
+extern "C" { 
+#endif
+
+AUTOLIB(mach)
+
 /*
  * Architecture-dependent application data.
  * 
@@ -351,8 +359,6 @@
 	uint		format;		/* print format: 'x', 'X', 'f', 'z', 'Z' */
 };
 
-Regdesc*	regdesc(char*);
-
 enum
 {
 	/* machine types */
@@ -498,7 +504,7 @@
 
 Symbol*	flookupsym(Fhdr*, char*);
 Symbol*	ffindsym(Fhdr*, Loc, uint);
-Symbol*	addsym(Fhdr*, Symbol*);
+Symbol*	_addsym(Fhdr*, Symbol*);
 
 /*
  * Stack frame walking.
@@ -525,3 +531,7 @@
 };
 
 extern int machdebug;
+#if defined(__cplusplus)
+}
+#endif
+#endif
diff --git a/include/mp.h b/include/mp.h
index 427544d..153fd03 100644
--- a/include/mp.h
+++ b/include/mp.h
@@ -4,6 +4,8 @@
 extern "C" {
 #endif
 
+AUTOLIB(mp)
+
 /*
 #pragma	src	"/sys/src/libmp"
 #pragma	lib	"libmp.a"
diff --git a/include/mux.h b/include/mux.h
index b8d242c..01d1779 100644
--- a/include/mux.h
+++ b/include/mux.h
@@ -1,3 +1,11 @@
+#ifndef _MUX_H_
+#define _MUX_H_ 1
+#if defined(__cplusplus)
+extern "C" { 
+#endif
+
+AUTOLIB(mux)
+
 typedef struct Mux Mux;
 typedef struct Muxrpc Muxrpc;
 typedef struct Muxqueue Muxqueue;
@@ -52,3 +60,7 @@
 void _muxqhangup(Muxqueue*);
 void *_muxnbqrecv(Muxqueue*);
 
+#if defined(__cplusplus)
+}
+#endif
+#endif
diff --git a/include/regexp9.h b/include/regexp9.h
index b241712..9e1c01b 100644
--- a/include/regexp9.h
+++ b/include/regexp9.h
@@ -4,6 +4,8 @@
 extern "C" { 
 #endif
 
+AUTOLIB(regexp9)
+
 #include <utf.h>
 
 typedef struct Resub		Resub;
diff --git a/include/thread.h b/include/thread.h
index bbcbba5..23c4a52 100644
--- a/include/thread.h
+++ b/include/thread.h
@@ -4,6 +4,8 @@
 extern "C" { 
 #endif
 
+AUTOLIB(thread)
+
 /*
  * basic procs and threads
  */
@@ -23,8 +25,9 @@
 
 /*
  * daemonize
- */
+ *
 void	threaddaemonize(void);
+ */
 
 /*
  * clumsy linker hack
diff --git a/include/u.h b/include/u.h
index ba93696..d062a9d 100644
--- a/include/u.h
+++ b/include/u.h
@@ -111,6 +111,11 @@
 #undef _NEEDUINT
 #undef _NEEDULONG
 
+/*
+ * Funny-named symbols to tip off 9l to autolink.
+ */
+#define AUTOLIB(x)	static int __p9l_autolib_ ## x = 1;
+
 #if defined(__cplusplus)
 }
 #endif
diff --git a/include/venti.h b/include/venti.h
index 889f86d..7b14c1a 100644
--- a/include/venti.h
+++ b/include/venti.h
@@ -3,6 +3,9 @@
 #ifdef __cplusplus
 extern "C" { 
 #endif
+
+AUTOLIB(venti)
+
 /* XXX should be own library? */
 /*
  * Packets