Add a convenient libflashrom interface

This adds a minimal libflashrom interface based on the draft in the
wiki. While the glue code in libflashrom.c is build on top of the
existing code instead on overhauling it, the interface in libflashrom.h
is supposed to be stable. So we can keep the interface and adapt
internals later if favoured, without breaking clients.

A new make target, libinstall, is also added. It installs libflashrom.a
and libflashrom.h in lib/ and include/ dirs respectively.

Hooking this into the build would break linking of the CLI and is post-
poned until that got fixed.

v2: Rebase and fixes by Anton Kochkov.

v3: o fl_image_*() rewritten with layout support (touch only included regions).
    o Moved read/erase/write/verify operations to flashrom.c.
    o Added layout pointer and flags to the flash context.

v4: Removed libflashrom.o from LIB_OBJS until CLI is adapted.

v5: o Incorporated David's comments.
    o Added `fl_flashprog_t` as dummy parameter to hide the fact that
      we have global state all around, and for future-proofness ofc.

v6: o Change namespace prefix to flashrom_.
    o Remove typedefs.

Change-Id: I00f169990830aa17b7dfae5eb74010d40c476181
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/17946
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: David Hendricks <david.hendricks@gmail.com>
diff --git a/Makefile b/Makefile
index 4ebde1e..88130c8 100644
--- a/Makefile
+++ b/Makefile
@@ -1357,6 +1357,12 @@
 	$(INSTALL) -m 0755 $(PROGRAM)$(EXEC_SUFFIX) $(DESTDIR)$(PREFIX)/sbin
 	$(INSTALL) -m 0644 $(PROGRAM).8 $(DESTDIR)$(MANDIR)/man8
 
+libinstall: libflashrom.a libflashrom.h
+	mkdir -p $(DESTDIR)$(PREFIX)/lib
+	$(INSTALL) -m 0644 libflashrom.a $(DESTDIR)$(PREFIX)/lib
+	mkdir -p $(DESTDIR)$(PREFIX)/include
+	$(INSTALL) -m 0644 libflashrom.h $(DESTDIR)$(PREFIX)/include
+
 export: $(PROGRAM).8
 	@rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)
 	@svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)