targets: moved boot and partition-table into board

Boot and partition-table targets need to be board specific.

Change-Id: If22ddc32b9c71532d95cef4671abfc022d1a313a
diff --git a/boot.mk b/boot.mk
new file mode 100644
index 0000000..e49f85d
--- /dev/null
+++ b/boot.mk
@@ -0,0 +1,35 @@
+# Copyright 2018 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ifeq ($(ROOTDIR),)
+$(error $$ROOTDIR IS NOT DEFINED -- don\'t forget to source setup.sh)
+endif
+
+include $(ROOTDIR)/build/preamble.mk
+
+boot: $(PRODUCT_OUT)/boot_$(USERSPACE_ARCH).img
+
+$(PRODUCT_OUT)/boot_$(USERSPACE_ARCH).img: | out-dirs
+	$(LOG) boot fallocate
+	fallocate -l $(BOOT_SIZE_MB)M $@
+	mkfs.ext2 -F $@
+	$(LOG) boot finished
+
+targets::
+	@echo "boot - builds the kernel and boot partition"
+
+clean::
+	rm -f $(PRODUCT_OUT)/boot_*.img
+
+.PHONY:: boot
diff --git a/partition-table.mk b/partition-table.mk
new file mode 100644
index 0000000..40f2047
--- /dev/null
+++ b/partition-table.mk
@@ -0,0 +1,72 @@
+# Copyright 2018 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ifeq ($(ROOTDIR),)
+$(error $$ROOTDIR IS NOT DEFINED -- don\'t forget to source setup.sh)
+endif
+
+include $(ROOTDIR)/build/preamble.mk
+
+BPTTOOL := $(ROOTDIR)/tools/bpt/bpttool
+MMC_8GB  := 7818182656
+MMC_16GB := 15634268160
+MMC_64GB := 62537072640
+
+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
+
+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)/partition-table-%.json: $(SOURCE_JSON)
+	mkdir -p $(@D)
+	$(BPTTOOL) make_table --disk_size $(MMC_SIZE) --input $< --output_json $@
+
+$(PRODUCT_OUT)/partition-table-%.img: $(SOURCE_JSON)
+	mkdir -p $(@D)
+	$(BPTTOOL) make_table --disk_size $(MMC_SIZE) --input $< --output_gpt $@
+
+targets::
+	@echo "partition-table - builds partition table images for all eMMC sizes"
+
+clean::
+	rm -f $(PRODUCT_OUT)/partition-table-*.json
+	rm -f $(PRODUCT_OUT)/partition-table-*.img
+
+.PHONY:: partition-table