integrate bsdiff into imgdiff, instead of using subprocess

Integrate the bsdiff code into imgdiff so we can just call it rather
than writing temp files and invoking bsdiff as a subprocess.  When
computing multiple patches from the same source file, we can also save
time by doing some bsdiff preprocessing on the source file only once.

(Note this renames the existing 'bsdiff.c' -- which actually does
patching in applypatch -- to 'bspatch.c', and introduces a new
bsdiff.c linked into imgdiff.)
diff --git a/tools/applypatch/Android.mk b/tools/applypatch/Android.mk
index 5796cef..bb1519e 100644
--- a/tools/applypatch/Android.mk
+++ b/tools/applypatch/Android.mk
@@ -17,7 +17,7 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := applypatch.c bsdiff.c freecache.c imgpatch.c utils.c
+LOCAL_SRC_FILES := applypatch.c bspatch.c freecache.c imgpatch.c utils.c
 LOCAL_MODULE := libapplypatch
 LOCAL_MODULE_TAGS := eng
 LOCAL_C_INCLUDES += external/bzip2 external/zlib bootable/recovery
@@ -47,12 +47,12 @@
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := imgdiff.c utils.c
+LOCAL_SRC_FILES := imgdiff.c utils.c bsdiff.c
 LOCAL_MODULE := imgdiff
 LOCAL_FORCE_STATIC_EXECUTABLE := true
 LOCAL_MODULE_TAGS := eng
 LOCAL_C_INCLUDES += external/zlib
-LOCAL_STATIC_LIBRARIES += libz
+LOCAL_STATIC_LIBRARIES += libz libbz
 
 include $(BUILD_HOST_EXECUTABLE)