vboot_reference: Install vboot_host.pc file

Since we are going to pull in libmtdutils, it would be nice to let
downstream packages automatically query for appropriate linking flags.

BUG=chromium:459338
BRANCH=None
CQ-DEPEND=CL:250836
TEST=See the depending CL.

Change-Id: I9ff8046b95e1d7e909a483fe87a69d460777e192
Reviewed-on: https://chromium-review.googlesource.com/250530
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Trybot-Ready: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
Reviewed-by: Nam Nguyen <namnguyen@chromium.org>
diff --git a/Makefile b/Makefile
index 12a27c7..574e961 100644
--- a/Makefile
+++ b/Makefile
@@ -44,22 +44,26 @@
 # Stuff for 'make install'
 INSTALL = install
 DESTDIR = /usr/local
+LIBDIR ?= lib
 
 # Default values
 DEV_DEBUG_FORCE=
 
 # Where exactly do the pieces go?
 #  UB_DIR = utility binary directory
+#  ULP_DIR = pkgconfig directory, usually /usr/lib/pkgconfig
 #  DF_DIR = utility defaults directory
 #  VB_DIR = vboot binary directory for dev-mode-only scripts
 ifeq (${MINIMAL},)
 # Host install just puts everything where it's told
 UB_DIR=${DESTDIR}/bin
+ULP_DIR=${DESTDIR}/${LIBDIR}/pkgconfig
 DF_DIR=${DESTDIR}/default
 VB_DIR=${DESTDIR}/bin
 else
 # Target install puts things into different places
 UB_DIR=${DESTDIR}/usr/bin
+ULP_DIR=${DESTDIR}/usr/${LIBDIR}/pkgconfig
 DF_DIR=${DESTDIR}/etc/default
 VB_DIR=${DESTDIR}/usr/share/vboot/bin
 endif
@@ -160,6 +164,10 @@
 CFLAGS += -DPD_SYNC
 endif
 
+# NOTE: We don't use these files but they are useful for other packages to
+# query about required compiling/linking flags.
+PC_IN_FILES = vboot_host.pc.in
+
 # Create / use dependency files
 CFLAGS += -MMD -MF $@.d
 
@@ -754,7 +762,8 @@
 	${Q}/bin/rm -rf ${BUILD}
 
 .PHONY: install
-install: cgpt_install utils_install signing_install futil_install
+install: cgpt_install utils_install signing_install futil_install \
+	pc_files_install
 
 .PHONY: install_mtd
 install_mtd: install cgpt_wrapper_install
@@ -1403,3 +1412,15 @@
 	${Q}\rm -f ${BUILD}/tags ${BUILD}/TAGS
 	${Q}$(call run_if_prog,etags,${cmd_etags})
 	${Q}$(call run_if_prog,ctags,${cmd_ctags})
+
+PC_FILES = ${PC_IN_FILES:%.pc.in=%.pc}
+${PC_FILES}: ${PC_IN_FILES}
+	${Q}sed \
+		-e 's:@LDLIBS@:${LDLIBS}:' \
+		-e 's:@LIBDIR@:${LIBDIR}:' \
+		$< > $@
+
+.PHONY: pc_files_install
+pc_files_install: ${PC_FILES}
+	${Q}mkdir -p ${ULP_DIR}
+	${Q}${INSTALL} -D -m 0644 $< ${ULP_DIR}/$<
diff --git a/vboot_host.pc.in b/vboot_host.pc.in
new file mode 100644
index 0000000..46243db
--- /dev/null
+++ b/vboot_host.pc.in
@@ -0,0 +1,10 @@
+prefix=/usr
+exec_prefix=${prefix}
+includedir=${prefix}/include
+libdir=${prefix}/@LIBDIR@
+
+Name: libvboot_host
+Version: 2
+Description: Static library of functions related to vboot and cgpt.
+Cflags: -I${includedir}
+Libs: -L${libdir} -lvboot_host @LDLIBS@