standalone kinit/resume

Factor out resume in a subdirectory - no functional changes.
mv resume.c resume/resumelib.c
Add an standalone minimal resume.c, which calls resume() from resumelib.

resulting resume bin is small:
ls -l /usr/lib/klibc/bin/resume
-rwxr-xr-x 1 root root 2904 2006-07-11 09:18 /usr/lib/klibc/bin/resume

tested with several resume/suspend cycles.

as a bonus alphabetically sort the include and the clean dir

Signed-off-by: maximilian attems <maks@sternwelten.at>
diff --git a/usr/kinit/Kbuild b/usr/kinit/Kbuild
index 0000e89..37b35cf 100644
--- a/usr/kinit/Kbuild
+++ b/usr/kinit/Kbuild
@@ -6,25 +6,27 @@
 kinit-y  := kinit.o do_mounts.o ramdisk_load.o initrd.o
 kinit-y	 += name_to_dev.o devname.o
 kinit-y  += getarg.o getintfile.o open.o readfile.o xpio.o
-kinit-y  += do_mounts_md.o do_mounts_mtd.o nfsroot.o resume.o
+kinit-y  += do_mounts_md.o do_mounts_mtd.o nfsroot.o
 
 kinit-y  += ipconfig/
 kinit-y  += nfsmount/
 kinit-y  += run-init/
 kinit-y  += fstype/
+kinit-y  += resume/
 
 shared-y := kinit.shared
 kinit.shared-y := $(kinit-y)
 
 # Additional include paths files
-KLIBCCFLAGS += -I$(srctree)/$(src)/ipconfig \
+KLIBCCFLAGS += -I$(srctree)/$(src)/fstype \
+	       -I$(srctree)/$(src)/ipconfig \
   	       -I$(srctree)/$(src)/nfsmount \
- 	       -I$(srctree)/$(src)/run-init \
- 	       -I$(srctree)/$(src)/fstype
+  	       -I$(srctree)/$(src)/resume \
+ 	       -I$(srctree)/$(src)/run-init
 
 # Cleaning
 targets := kinit kinit.g kinit.shared kinit.shared.g
-subdir- := ipconfig nfsmount run-init fstype
+subdir- := fstype ipconfig nfsmount resume run-init
 
 
 # install binary
diff --git a/usr/kinit/resume/Kbuild b/usr/kinit/resume/Kbuild
new file mode 100644
index 0000000..ce6d0ce
--- /dev/null
+++ b/usr/kinit/resume/Kbuild
@@ -0,0 +1,28 @@
+#
+# Kbuild file for resume
+#
+
+static-y := static/resume
+shared-y := shared/resume
+
+# common .o files
+objs := resume.o resumelib.o ../getarg.o ../name_to_dev.o ../devname.o
+
+# TODO - do we want a stripped version
+# TODO - do we want the static.g + shared.g directories?
+
+# Create built-in.o with all object files (used by kinit)
+lib-y := $(objs)
+
+# Additional include paths files
+KLIBCCFLAGS += -I$(srctree)/$(src)/..
+
+# .o files used to built executables
+static/resume-y := $(objs)
+shared/resume-y := $(objs)
+
+# Cleaning
+clean-dirs := static shared
+
+# install binary
+install-y := $(shared-y)
diff --git a/usr/kinit/resume/resume.c b/usr/kinit/resume/resume.c
new file mode 100644
index 0000000..00e5405
--- /dev/null
+++ b/usr/kinit/resume/resume.c
@@ -0,0 +1,27 @@
+/*
+ * resume.c
+ *
+ * Handle resume from suspend-to-disk
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "resume.h"
+
+char *progname;
+
+static __noreturn usage(void)
+{
+	fprintf(stderr, "Usage: %s /dev/<resumedevice>\n", progname);
+	exit(1);
+}
+
+int main(int argc, char *argv[], char *envp[])
+{
+	progname = argv[0];
+	if (argc != 2)
+		usage();
+
+	return resume(argv[1]);
+}
diff --git a/usr/kinit/resume.h b/usr/kinit/resume/resume.h
similarity index 100%
rename from usr/kinit/resume.h
rename to usr/kinit/resume/resume.h
diff --git a/usr/kinit/resume.c b/usr/kinit/resume/resumelib.c
similarity index 100%
rename from usr/kinit/resume.c
rename to usr/kinit/resume/resumelib.c