Conditionally use system provided libopenbmc_intf

This patch structures the make rules such that building from the top
will build the in-tree libopenbmc_intf and link to that.  For example:
 $make
 $make bmcctl
would both result in ../libopenbmc_intf being built and the applications
will link to that.

Alternatively when building applications directly like:
 $make -C bmcctl
the default compiler/linker search paths will be used.

The latter facilitates package managers and the former retains a level
of flexibility for developers working from the repository.

Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/Makefile b/Makefile
index 9bbd042..b79675d 100644
--- a/Makefile
+++ b/Makefile
@@ -9,8 +9,7 @@
 	     pwrbutton \
 	     rstbutton
 
-SUBDIRS = $(GDBUS_APPS) \
-	  hacks \
+SUBDIRS = hacks \
 	  ledctl \
 	  libopenbmc_intf \
 	  pychassisctl \
@@ -25,19 +24,20 @@
 	  pysystemmgr \
 	  pytools
 
-REVERSE_SUBDIRS = $(shell echo $(SUBDIRS) | tr ' ' '\n' | tac |tr '\n' ' ')
+REVERSE_SUBDIRS = $(shell echo $(SUBDIRS) $(GDBUS_APPS) | tr ' ' '\n' | tac |tr '\n' ' ')
 
-.PHONY: subdirs $(SUBDIRS)
+.PHONY: subdirs $(SUBDIRS) $(GDBUS_APPS)
 
-subdirs: $(SUBDIRS)
+subdirs: $(SUBDIRS) $(GDBUS_APPS)
 
 $(SUBDIRS):
 	$(MAKE) -C $@
 
 $(GDBUS_APPS): libopenbmc_intf
+	$(MAKE) -C $@ CFLAGS="-I ../$^" LDFLAGS="-L ../$^"
 
 install: subdirs
-	@for d in $(SUBDIRS); do \
+	@for d in $(SUBDIRS) $(GDBUS_APPS); do \
 		$(MAKE) -C $$d $@ DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) || exit 1; \
 	done
 clean: