Update Makefile to include FCI and CMM

Add rules to Makefile to build FCI and CMM.
Add a ./configure script that recurses into the subdirectories fci/lib
and cmm.

Change-Id: I8a50ea87b4666eeffe20ae4a5b58e6b066e2ef77
diff --git a/Makefile b/Makefile
index 8a10fbe..f411ac9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,19 @@
-default: all
+default: install
 
-DIRS=pfe_ctrl pfe_firmware
+AUTOTOOLS_DIRS:=fci/lib cmm
+KMOD_DIRS:=fci pfe_ctrl
+DIRS:=$(AUTOTOOLS_DIRS) $(KMOD_DIRS) pfe_firmware
+
+show-AUTOTOOLS_DIRS:
+	@echo $(AUTOTOOLS_DIRS)
 
 all:     $(addsuffix /all,$(DIRS))
 clean:   $(addsuffix /clean,$(DIRS))
 install: $(addsuffix /install,$(DIRS))
-install-libs: $(addsuffix /install-libs,$(DIRS))
 
 install:
 	$(INSTALL) -m 0755 -D $(@D)/hotplug-script \
-		$(DESTDIR)/sbin/hotplug
+		$(TARGET_DIR)/sbin/hotplug
 
 pfe_ctrl/all:
 	$(MAKE) -C pfe_ctrl $(LINUX_MAKE_FLAGS) KERNELDIR=$(LINUX_DIR) PFE_DIR=../pfe WIFI_ENABLE=y
@@ -17,14 +21,35 @@
 pfe_ctrl/install:
 	$(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M="$(shell /bin/pwd)/pfe_ctrl" modules_install
 
+fci/all:
+	$(MAKE) -C fci $(LINUX_MAKE_FLAGS) KERNEL_SOURCE=$(LINUX_DIR)
+
+fci/install:
+	$(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M="$(shell /bin/pwd)/fci" modules_install
+
+$(addsuffix /install,$(KMOD_DIRS)): %/install: %/all
+
+cmm/all: fci/lib/install
+	@
+
 %/all:
 	$(MAKE) -C $* all
 
-%/test:
-	$(MAKE) -C $* test
-
 %/clean:
 	$(MAKE) -C $* clean
 
 %/install:
-	$(MAKE) -C $* install
+	$(MAKE) -C $* DESTDIR=$(TARGET_DIR) install
+
+$(addsuffix /install,$(AUTOTOOLS_DIRS)): %/install: %/install-staging %/install-target
+	@
+
+fci/lib/install-staging: fci/lib/all
+	$(MAKE) -C $(@D) DESTDIR=$(STAGING_DIR) install
+	cp $(@D)/include/*.h $(STAGING_DIR)/usr/include/
+
+%/install-staging: %/all
+	$(MAKE) -C $* DESTDIR=$(STAGING_DIR) install
+
+%/install-target: %/all
+	$(MAKE) -C $* DESTDIR=$(TARGET_DIR) install
diff --git a/configure b/configure
new file mode 100755
index 0000000..b7ae40b
--- /dev/null
+++ b/configure
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -e
+AUTOTOOLS_DIRS="$(make show-AUTOTOOLS_DIRS)"
+
+for i in $AUTOTOOLS_DIRS; do
+  echo Running ./configure in $i
+  (cd "$i" && rm -rf config.cache && ./configure "$@")
+done