Create a static library of libdm-bht

This pulls in the C sources into a library as well as the kernel
implementations of the hashes, so that the installer can statically
link them in.  We have to do a few non-obvious things in order to get
libdm-bht.a instead of libdm-bht.pic.a due to the double invocation of
that rule -- added TODO(wad) to fix that.

BUG=chromium-os:25377
TEST=manual: build verity, ensure libdm-bht.a is created (won't be
installed)

Change-Id: I4037c68d3fc2c1dfdcfed4a603b49b57dd06562b
Reviewed-on: https://gerrit.chromium.org/gerrit/15838
Tested-by: Sonny Rao <sonnyrao@chromium.org>
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Ready: Sonny Rao <sonnyrao@chromium.org>
diff --git a/Makefile b/Makefile
index d926da8..6c9f6f0 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,21 @@
 all: CXX_LIBRARY(libdm-bht.so)
 clean: CLEAN(libdm-bht.so)
 
+CXX_STATIC_LIBRARY(libdm-bht.pic.a): $(C_OBJECTS) \
+				     $(kernel_C_OBJECTS)
+
+clean: CLEAN(libdm-bht.pic.a)
+
+# Give libdm-bht.pic.a a slightly cleaner name
+# But, we have to do some odd stuff like use $(OUT) and use "cp"
+# rather than mv because it gets called twice and can ace with the
+# actual build of libdm-bht.pic.a
+# TODO(wad) fix the double invocation problem and clean this up
+libdm-bht.a: CXX_STATIC_LIBRARY(libdm-bht.pic.a)
+	cp $(OUT)libdm-bht.pic.a $(OUT)libdm-bht.a || true
+
+all: libdm-bht.a
+
 # For this project, only the unittests are CXX
 CXX_BINARY(verity_testrunner): $(filter-out %_main.o,$(CXX_OBJECTS)) \
                           $(filter %dm-bht-userspace.o,$(C_OBJECTS)) \