Add sleep utility (from Olaf); build both shared and static versions
of the utilities.

diff --git a/MCONFIG b/MCONFIG
index ec455c3..a57071a 100644
--- a/MCONFIG
+++ b/MCONFIG
@@ -25,9 +25,14 @@
 HOST_LDFLAGS = 
 HOST_LIBS    =
 
-CRT0    = $(KLIBSRC)/crt0.o
-KLIBC   = $(KLIBSRC)/libc.a
-LIBGCC  = $(shell $(CC) --print-libgcc)
+# Static library paths
+CRT0      = $(KLIBSRC)/crt0.o
+KLIBC     = $(KLIBSRC)/libc.a
+LIBGCC    = $(shell $(CC) --print-libgcc)
+
+# Shared library paths
+CRTSHARED = $(KLIBSRC)/interp.o
+LIBSHARED = $(KLIBSRC)/libc.so
 
 #
 # This indicates the location of the final version of the shared library.
diff --git a/MRULES b/MRULES
index 8a8831c..41fdd07 100644
--- a/MRULES
+++ b/MRULES
@@ -5,6 +5,10 @@
 
 .SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss
 
+% : %.c	# Cancel default rule
+
+% : %.S
+
 .c.o:
 	$(CC) $(CFLAGS) -c -o $@ $<
 
diff --git a/ash/Makefile b/ash/Makefile
index 4f25b00..9c47738 100644
--- a/ash/Makefile
+++ b/ash/Makefile
@@ -37,8 +37,8 @@
 	$(LD) $(LDFLAGS) -o $(PROG) $(CRT0) $(OBJS) $(LIBS)
 	$(STRIP) $(PROG)
 
-$(PROG).shared: $(OBJS) $(LIBS) $(KLIBSRC)/interp.o $(KLIBSRC)/libc.so
-	$(LD) $(LDFLAGS) -o $(PROG).shared -e main $(KLIBSRC)/interp.o $(OBJS) -R $(KLIBSRC)/libc.so $(LIBGCC)
+$(PROG).shared: $(OBJS) $(CRTSHARED) $(LIBSHARED) $(LIBGCC)
+	$(LD) $(LDFLAGS) -o $(PROG).shared -e main $(CRTSHARED) $(OBJS) -R $(LIBSHARED) $(LIBGCC)
 	$(STRIP) $(PROG).shared
 
 $(CRT0) $(LIBS):
diff --git a/klibc/__static_init.c b/klibc/__static_init.c
index dcb8d01..5a90b5c 100644
--- a/klibc/__static_init.c
+++ b/klibc/__static_init.c
@@ -36,5 +36,3 @@
   environ = envp;
   exit(main(argc, argv, envp));
 }
-
-  
diff --git a/klibc/arch/i386/MCONFIG b/klibc/arch/i386/MCONFIG
index 367ee89..516b1b6 100644
--- a/klibc/arch/i386/MCONFIG
+++ b/klibc/arch/i386/MCONFIG
@@ -7,17 +7,16 @@
 # accordingly.
 #
 
-# Comment this out to compile with register parameter passing
-# This doesn't work right now because gcc 3.2 (at least) calls
-# libgcc with the default calling convention instead of forcing
-# them to be cdecl
-# REGPARM = -mregparm=3 -DREGPARM
+# Enable this to compile with register parameters; only safe for
+# gcc > 3
+REGPARM_OPT := -mregparm=3 -DREGPARM
 
 gcc_major := $(shell $(CC) -v 2>&1 | awk '/gcc version/{print int($$3)}')
 
 OPTFLAGS = $(REGPARM) -march=i386 -Os
 
 ifeq ($(gcc_major),3)
+REGPARM  := $(REGPARM_OPT)
 OPTFLAGS += -falign-functions=0 -falign-jumps=0 -falign-loops=0
 else
 OPTFLAGS += -malign-functions=0 -malign-jumps=0 -malign-loops=0
diff --git a/utils/Makefile b/utils/Makefile
index c92e766..ea49ad2 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -2,48 +2,43 @@
 include ../MCONFIG
 include ../MRULES
 
-MAKEDEPS = -Wp,-MD,.$(subst /,-,$*).d
-CFLAGS   = $(MAKEDEPS) $(OPTFLAGS) $(REQFLAGS) -W -Wall
-LIBS     = $(KLIBC) $(LIBGCC)
-PROGS    = chroot dd fstype mkdir mkfifo mount pivot_root umount true false
+MAKEDEPS     = -Wp,-MD,.$(subst /,-,$*).d
+CFLAGS       = $(MAKEDEPS) $(OPTFLAGS) $(REQFLAGS) -W -Wall
+LIBS         = $(KLIBC) $(LIBGCC)
+PROGS       := chroot dd fstype mkdir mkfifo mount pivot_root umount \
+	       true false sleep
+STATICPROGS := $(patsubst %,static/%,$(PROGS))
+SHAREDPROGS := $(patsubst %,shared/%,$(PROGS))
+LIBOBJS	     = file_mode.o
+LIBUTILS     = libutils.a
 
-all:	$(PROGS)
+all:	$(STATICPROGS) $(SHAREDPROGS)
 
-chroot:	chroot.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) chroot.o $(LIBS)
+static/%: %.o $(CRT0) $(LIBS) $(LIBUTILS)
+	mkdir -p static
+	$(LD) $(LDFLAGS) -o $@ $(CRT0) $< $(LIBUTILS) $(LIBS)
+	$(STRIP) $@
 
-dd:	dd.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) dd.o $(LIBS)
+shared/%: %.o $(CRTSHARED) $(LIBSHARED) $(LIBUTILS)
+	mkdir -p shared
+	$(LD) $(LDFLAGS) -o $@ -e main $(CRTSHARED) $< $(LIBUTILS) \
+		-R $(LIBSHARED) $(LIBGCC)
+	$(STRIP) $@
 
-fstype:	fstype.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) fstype.o $(LIBS)
+# Programs that consist of more than one file
+mount.o: mount_main.o mount_opts.o
+	$(LD) -r -o $@ $^
 
-mkdir:	mkdir.o file_mode.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) mkdir.o file_mode.o $(LIBS)
-
-mkfifo:	mkfifo.o file_mode.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) mkfifo.o file_mode.o $(LIBS)
-
-mount:	mount.o mount_opts.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) mount.o mount_opts.o $(LIBS)
-
-pivot_root: pivot_root.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) pivot_root.o $(LIBS)
-
-umount: umount.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) umount.o $(LIBS)
-
-true: true.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) true.o $(LIBS)
-
-false: false.o $(CRT0) $(LIBS)
-	$(LD) $(LDFLAGS) -o $@ $(CRT0) false.o $(LIBS)
+$(LIBUTILS): $(LIBOBJS)
+	-rm -f $@
+	$(AR) cq $@ $^
+	$(RANLIB) $@
 
 $(CRT0) $(LIBS):
 	@echo '*** error: $@ not up to date' || exit 1
 
 clean:
-	$(RM) *.o $(PROGS) core .*.d
+	$(RM) *.o core $(PROGS) .*.d shared/* static/*
 
 spotless: clean
 	$(RM) *~
diff --git a/utils/mount.c b/utils/mount_main.c
similarity index 100%
rename from utils/mount.c
rename to utils/mount_main.c
diff --git a/utils/sleep.c b/utils/sleep.c
new file mode 100644
index 0000000..769b456
--- /dev/null
+++ b/utils/sleep.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+	unsigned long s;
+	char *p;
+
+	if (argc != 2)
+		goto err;
+
+	s = strtoul(argv[1], &p, 10);
+	if ( *p )
+		goto err;
+
+	sleep(s);
+
+	return 0;
+
+err:
+	fprintf(stderr, "Usage: %s seconds\n", argv[0]);
+	return 1; 
+}