More Mac tweaks.
diff --git a/src/Makefile b/src/Makefile
index 1c8010d..7fe300b 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,4 +1,6 @@
 ../bin/mk: mkmk.sh
+	SYSNAME=`uname` export SYSNAME; \
+	OBJTYPE=`uname -m | sed 's;i.86;386;; s;/.*;;; s; ;;g'` export OBJTYPE; \
 	PATH=`pwd`/../bin:$$PATH export PATH; \
 	PLAN9=`pwd`/.. export PLAN9; \
 	sh -x mkmk.sh
diff --git a/src/cmd/mk/main.c b/src/cmd/mk/main.c
index 267ed73..fdd9477 100644
--- a/src/cmd/mk/main.c
+++ b/src/cmd/mk/main.c
@@ -226,6 +226,7 @@
 	if(uflag)
 		prusage();
 	exits(0);
+	return 0;
 }
 
 void
diff --git a/src/cmd/mk/mk.h b/src/cmd/mk/mk.h
index 9b3f627..33402de 100644
--- a/src/cmd/mk/mk.h
+++ b/src/cmd/mk/mk.h
@@ -1,38 +1,4 @@
-#include <utf.h>
-#include <fmt.h>
-#include <setjmp.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include	<bio.h>
-#include	<regexp9.h>
-#include <time.h>
-
-#define uchar _mkuchar
-#define ushort _mkushort
-#define uint _mkuint
-#define ulong _mkulong
-#define vlong _mkvlong
-#define uvlong _mkuvlong
-
-#define nil ((void*)0)
-
-typedef unsigned char		uchar;
-typedef unsigned short		ushort;
-typedef unsigned int		uint;
-typedef unsigned long		ulong;
-
-#define nelem(x) (sizeof(x)/sizeof((x)[0]))
-
-#define OREAD O_RDONLY
-#define OWRITE O_WRONLY
-#define ORDWR O_RDWR
-#define USED(x) if(x);else
-#define remove unlink
-#define seek lseek
-#define exits(s) exit((s) && ((char*)s)[0] ? 1 : 0)
-#define create(name, mode, perm) creat(name, perm)
-#define ERRMAX 256
+#include "sys.h"
 
 #undef assert
 #define	assert	mkassert
diff --git a/src/cmd/mk/shprint.c b/src/cmd/mk/shprint.c
index 9e15bce..7cfa5f4 100644
--- a/src/cmd/mk/shprint.c
+++ b/src/cmd/mk/shprint.c
@@ -2,6 +2,8 @@
 
 static char *vexpand(char*, Envy*, Bufblock*);
 
+#define getfields mkgetfields
+
 static int
 getfields(char *str, char **args, int max, int mflag, char *set)
 {
diff --git a/src/cmd/mk/unix.c b/src/cmd/mk/unix.c
index 6022278..8b7e9cb 100644
--- a/src/cmd/mk/unix.c
+++ b/src/cmd/mk/unix.c
@@ -1,3 +1,4 @@
+#define NOPLAN9DEFINES
 #include	"mk.h"
 #include	<sys/wait.h>
 #include	<signal.h>
diff --git a/src/lib9/sendfd.c b/src/lib9/sendfd.c
index b3a2448..4c4aa7f 100644
--- a/src/lib9/sendfd.c
+++ b/src/lib9/sendfd.c
@@ -34,7 +34,7 @@
 	sfd.cmsg.cmsg_type = SCM_RIGHTS;
 	sfd.fd = fd;
 
-	msg.msg_control = &sfd;
+	msg.msg_control = (caddr_t)&sfd;
 	msg.msg_controllen = sizeof sfd;
 
 	if((n=sendmsg(s, &msg, 0)) != iov.iov_len)
@@ -66,7 +66,7 @@
 	sfd.cmsg.cmsg_level = SOL_SOCKET;
 	sfd.cmsg.cmsg_type = SCM_RIGHTS;
 
-	msg.msg_control = &sfd;
+	msg.msg_control = (caddr_t)&sfd;
 	msg.msg_controllen = sizeof sfd;
 
 	if((n=recvmsg(s, &msg, 0)) < 0)
diff --git a/src/mkfile b/src/mkfile
index 18577d6..296978c 100644
--- a/src/mkfile
+++ b/src/mkfile
@@ -1,3 +1,5 @@
+<mkhdr
+
 DIRS=\
 	lib9\
 	libbin\
@@ -27,7 +29,7 @@
 mkmk.sh:VD:
 	(
 		echo cd lib9
-		(cd lib9; mk -n -a 'LIB9OFILES=' install)
+		(cd lib9; mk -n -a install)
 		echo cd ..
 		for i in libbio libregexp cmd/mk
 		do	
@@ -35,7 +37,7 @@
 			(cd $i; mk -n -a install)
 			echo cd ..
 		done
-	) >$target
+	) | sed 's/'$SYSNAME'/$SYSNAME/; s/'$OBJTYPE'/$OBJTYPE/' >$target
 
 testmkmk:V:
 	mk mkmk.sh
diff --git a/src/mkmk.sh b/src/mkmk.sh
index 7710f69..f1126c8 100644
--- a/src/mkmk.sh
+++ b/src/mkmk.sh
@@ -1,6 +1,81 @@
 cd lib9
+9c  _exits.c
+9c  _p9dialparse.c
+9c  _p9dir.c
+9c  _p9proc.c
+9c  _p9translate.c
+9c  access.c
+9c  announce.c
+9c  argv0.c
+9c  atexit.c
+9c  atnotify.c
+9c  await.c
+9c  cistrcmp.c
+9c  cistrncmp.c
+9c  cistrstr.c
+9c  cleanname.c
+9c  convD2M.c
+9c  convM2D.c
+9c  convM2S.c
+9c  convS2M.c
+9c  create.c
+9c  ctime.c
+9c  date.c
+9c  dial.c
+9c  dirfstat.c
+9c  dirfwstat.c
+9c  dirmodefmt.c
+9c  dirread.c
+9c  dirstat.c
+9c  dirwstat.c
+9c  dup.c
+9c  encodefmt.c
+9c  errstr.c
+9c  exec.c
+9c  fcallfmt.c
+9c  ffork-$SYSNAME.c
+9a  getcallerpc-$OBJTYPE.s
+9c  getenv.c
+9c  getfields.c
+9c  getns.c
+9c  getuser.c
+9c  getwd.c
+9c  jmp.c
+9c  lock.c
+9c  main.c
+9c  malloc.c
+9c  malloctag.c
+9c  mallocz.c
+9c  nan.c
+9c  needsrcquote.c
+9c  netmkaddr.c
+9c  notify.c
+9c  nrand.c
+9c  nulldir.c
+9c  open.c
+9c  pipe.c
+9c  post9p.c
+9c  postnote.c
+9c  qlock.c
+9c  quote.c
+9c  read9pmsg.c
+9c  readn.c
+9c  rendez-$SYSNAME.c
+9c  rfork.c
+9c  seek.c
+9c  sendfd.c
+9c  sleep.c
+9c  strecpy.c
+9c  sysfatal.c
+9c  tas-$OBJTYPE.c
+9c  time.c
+9c  tokenize.c
+9c  u16.c
+9c  u32.c
+9c  u64.c
+9c  wait.c
+9c  waitpid.c
 9c  -Ifmt fmt/dofmt.c
-9c  -Ifmt fmt/errfmt.c
 9c  -Ifmt fmt/fltfmt.c
 9c  -Ifmt fmt/fmt.c
 9c  -Ifmt fmt/fmtfd.c
@@ -53,7 +128,7 @@
 9c  utf/utfrrune.c
 9c  utf/utfrune.c
 9c  utf/utfutf.c
-9ar rvc ../../lib/lib9.a dofmt.o errfmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlock.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o
+9ar rvc ../../lib/lib9.a _exits.o _p9dialparse.o _p9dir.o _p9proc.o _p9translate.o access.o announce.o argv0.o atexit.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o create.o ctime.o date.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirread.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o fcallfmt.o ffork-$SYSNAME.o getcallerpc-$OBJTYPE.o getenv.o getfields.o getns.o getuser.o getwd.o jmp.o lock.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o netmkaddr.o notify.o nrand.o nulldir.o open.o pipe.o post9p.o postnote.o qlock.o quote.o read9pmsg.o readn.o rendez-Darwin.o rfork.o seek.o sendfd.o sleep.o strecpy.o sysfatal.o tas-PowerMacintosh.o time.o tokenize.o u16.o u32.o u64.o wait.o waitpid.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlock.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o
 cd ..
 cd libbio
 9c  bbuffered.c
@@ -109,6 +184,6 @@
 9c  varsub.c
 9c  word.c
 9c  unix.c
-9l -o o.mk arc.o archive.o bufblock.o env.o file.o graph.o job.o lex.o main.o match.o mk.o parse.o recipe.o rule.o run.o sh.o shprint.o symtab.o var.o varsub.o word.o unix.o -lregexp9 -lbio -l9
+9l -o o.mk arc.o archive.o bufblock.o env.o file.o graph.o job.o lex.o main.o match.o mk.o parse.o recipe.o rule.o run.o sh.o shprint.o symtab.o var.o varsub.o word.o unix.o ../../../lib/libregexp9.a ../../../lib/libbio.a ../../../lib/lib9.a 
 install -c o.mk ../../../bin/mk
 cd ..