Build partition tables for all eMMC sizes.

Change-Id: I32a12e1067fc72fced26ff8fc0d32134530105b9
diff --git a/kokoro/continuous.cfg b/kokoro/continuous.cfg
index 8d2c703..8b398b5 100644
--- a/kokoro/continuous.cfg
+++ b/kokoro/continuous.cfg
@@ -13,7 +13,7 @@
     regex: "flash.sh"
     regex: "manifest.xml"
     regex: "sdcard.img"
-    regex: "partition-table.img"
+    regex: "partition-table-*.img"
     regex: "rootfs.img"
     regex: "u-boot.imx"
   }
diff --git a/kokoro/continuous.sh b/kokoro/continuous.sh
index 3acd28c..9fa5bbe 100644
--- a/kokoro/continuous.sh
+++ b/kokoro/continuous.sh
@@ -32,6 +32,6 @@
 chmod -x ${KOKORO_ARTIFACTS_DIR}/flash.sh
 cp ${PRODUCT_OUT}/u-boot.imx ${KOKORO_ARTIFACTS_DIR}
 cp ${PRODUCT_OUT}/boot.img ${KOKORO_ARTIFACTS_DIR}
-cp ${PRODUCT_OUT}/partition-table.img ${KOKORO_ARTIFACTS_DIR}
+cp ${PRODUCT_OUT}/partition-table-*.img ${KOKORO_ARTIFACTS_DIR}
 cp ${PRODUCT_OUT}/rootfs.img ${KOKORO_ARTIFACTS_DIR}
 cp ${PRODUCT_OUT}/sdcard.img ${KOKORO_ARTIFACTS_DIR}
diff --git a/kokoro/release.cfg b/kokoro/release.cfg
index 388ab18..47c21c2 100644
--- a/kokoro/release.cfg
+++ b/kokoro/release.cfg
@@ -13,7 +13,7 @@
     regex: "flash.sh"
     regex: "manifest.xml"
     regex: "sdcard.img"
-    regex: "partition-table.img"
+    regex: "partition-table-*.img"
     regex: "rootfs.img"
     regex: "u-boot.imx"
 
diff --git a/partition-table.mk b/partition-table.mk
index 13223f1..ef6a0b3 100644
--- a/partition-table.mk
+++ b/partition-table.mk
@@ -4,24 +4,55 @@
 
 include $(ROOTDIR)/build/preamble.mk
 
-partition-table: $(PRODUCT_OUT)/partition-table.img $(PRODUCT_OUT)/partition-table.json
+BPTTOOL := $(ROOTDIR)/tools/bpt/bpttool
+MMC_8GB  := 7818182656
+MMC_16GB := 15634268160
+MMC_64GB := 62537072640
 
-$(PRODUCT_OUT)/partition-table.json: $(ROOTDIR)/board/partition-table.json
-	mkdir -p $(PRODUCT_OUT)
-	$(ROOTDIR)/tools/bpt/bpttool make_table \
-		--input $(ROOTDIR)/board/partition-table.json \
-		--output_json $(PRODUCT_OUT)/partition-table.json
+SOURCE_JSON := $(ROOTDIR)/board/partition-table.json
+TARGET_8GB_JSON  := $(PRODUCT_OUT)/partition-table-8gb.json
+TARGET_8GB_IMG   := $(PRODUCT_OUT)/partition-table-8gb.img
+TARGET_16GB_JSON := $(PRODUCT_OUT)/partition-table-16gb.json
+TARGET_16GB_IMG  := $(PRODUCT_OUT)/partition-table-16gb.img
+TARGET_64GB_JSON := $(PRODUCT_OUT)/partition-table-64gb.json
+TARGET_64GB_IMG  := $(PRODUCT_OUT)/partition-table-64gb.img
 
-$(PRODUCT_OUT)/partition-table.img: $(ROOTDIR)/board/partition-table.json
-	mkdir -p $(PRODUCT_OUT)
-	$(ROOTDIR)/tools/bpt/bpttool make_table \
-		--input $(ROOTDIR)/board/partition-table.json \
-		--output_gpt $(PRODUCT_OUT)/partition-table.img
+partition-table: \
+  $(TARGET_8GB_JSON) $(TARGET_8GB_IMG) \
+  $(TARGET_16GB_JSON) $(TARGET_16GB_IMG) \
+  $(TARGET_64GB_JSON) $(TARGET_64GB_IMG)
+
+# 8GB
+$(TARGET_8GB_JSON): $(SOURCE_JSON)
+$(TARGET_8GB_JSON): MMC_SIZE = $(MMC_8GB)
+$(TARGET_8GB_IMG): $(SOURCE_JSON)
+$(TARGET_8GB_IMG): MMC_SIZE = $(MMC_8GB)
+
+# 16GB
+$(TARGET_16GB_JSON): $(SOURCE_JSON)
+$(TARGET_16GB_JSON): MMC_SIZE = $(MMC_16GB)
+$(TARGET_16GB_IMG): $(SOURCE_JSON)
+$(TARGET_16GB_IMG): MMC_SIZE = $(MMC_16GB)
+
+# 64GB
+$(TARGET_64GB_JSON): $(SOURCE_JSON)
+$(TARGET_64GB_JSON): MMC_SIZE = $(MMC_64GB)
+$(TARGET_64GB_IMG): $(SOURCE_JSON)
+$(TARGET_64GB_IMG): MMC_SIZE = $(MMC_64GB)
+
+$(PRODUCT_OUT)/%.json: $(SOURCE_JSON)
+	mkdir -p $(@D)
+	$(BPTTOOL) make_table --disk_size $(MMC_SIZE) --input $< --output_json $@
+
+$(PRODUCT_OUT)/%.img: $(SOURCE_JSON)
+	mkdir -p $(@D)
+	$(BPTTOOL) make_table --disk_size $(MMC_SIZE) --input $< --output_gpt $@
 
 targets::
-	@echo "partition-table - builds a partition table image for the eMMC"
+	@echo "partition-table - builds partition table images for all eMMC sizes"
 
 clean::
-	rm -f $(PRODUCT_OUT)/partition-table.img
+	rm -f $(PRODUCT_OUT)/partition-table-*.json
+	rm -f $(PRODUCT_OUT)/partition-table-*.img
 
 .PHONY:: partition-table