make applypatch into a static library

Turn the bulk of applypatch into a static library so it can be used
from the updater.  Also build it as a standalone executable for use by
the existing OTA mechanism.
diff --git a/tools/applypatch/applypatch.h b/tools/applypatch/applypatch.h
index e0320fb..ccd8424 100644
--- a/tools/applypatch/applypatch.h
+++ b/tools/applypatch/applypatch.h
@@ -17,6 +17,7 @@
 #ifndef _APPLYPATCH_H
 #define _APPLYPATCH_H
 
+#include <sys/stat.h>
 #include "mincrypt/sha.h"
 
 typedef struct _Patch {
@@ -45,6 +46,7 @@
 
 // applypatch.c
 size_t FreeSpaceForFile(const char* filename);
+int applypatch(int argc, char** argv);
 
 // bsdiff.c
 void ShowBSDiffLicense();