blob: 9fb9d5207ffb5906b912d45e6436f3ea52baf902 [file] [log] [blame]
##
## Copyright 2012 Google Inc.
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; version 2 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
depthcharge-y += fmap.c
image_obj := $(curobjdir)
image_src := $(cursrcdir)
build_image = $(image_obj)/build_image
build_image_src = $(image_src)/build_image
space = $(empty) $(empty)
comma = ,
BUILD_IMAGE_SPD_OPT = $(BUILD_IMAGE_SPD_OPT_NAME)$(subst $(space),$(comma),$(BUILD_IMAGE_SPD_OPT_SPACE))
add_spd_file = \
$(eval BUILD_IMAGE_SPD_FILES += $(2)) \
$(eval BUILD_IMAGE_SPD_OPT_NAME = --spds ) \
$(eval BUILD_IMAGE_SPD_OPT_SPACE += $(1):$(2)) \
modules: $$(BUILD_IMAGE_SPD_FILES)
BUILD_IMAGE_PATH_FULL = $(BUILD_IMAGE_PATH_EXTRAS) $(BUILD_IMAGE_PATH)
BUILD_IMAGE_PATH_SQUISHED = \
$(subst $(space),:,$(strip $(BUILD_IMAGE_PATH_FULL)))
BUILD_IMAGE_OPTS = --verbose --log-file $@.log -o $@
BUILD_IMAGE = \
BUILD_IMAGE_PATH="$(BUILD_IMAGE_PATH_SQUISHED):$(obj):$(module_obj)" \
CC="$(CC)" \
LINK_FLAGS="$(LINK_FLAGS)" \
OBJCOPY="$(OBJCOPY)" \
$(build_image) $(BUILD_IMAGE_OPTS) $(BUILD_IMAGE_LAYOUT) \
$(BUILD_IMAGE_LAYOUT_OPTS)
imagelib_files = $(shell find $(image_src) -name '*.py')
$(build_image): $(build_image_src) $(imagelib_files)
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(Q)rsync -cr $(image_src)/imagelib $(image_obj)/
.PHONY: images
all: images
ALL_IMAGES = $(strip $(IMAGES) $(IMAGES.$(CONFIG_BOARD)))
filter_image = $(if $(ALL_IMAGES),$(filter $(ALL_IMAGES),$1),$1)
image-handler=$(eval images: $(addprefix $(image_obj)/,$(call filter_image,$2)))
$(call add-special-class,image)
ifeq ($(CONFIG_BOOTPLAN_CB_SPLIT_PAYLOAD),y)
image-y += depthcharge.ro.elf depthcharge.ro.bin \
depthcharge.rw.elf depthcharge.rw.bin \
dev.ro.bin dev.ro.elf dev.rw.bin dev.rw.elf
$(image_obj)/depthcharge.ro.%: $$(module_obj)/cb_readonly.$$*
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(image_obj)/depthcharge.rw.%: $$(module_obj)/cb_readwrite.$$*
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(image_obj)/dev.ro.%: $$(module_obj)/cb_dev_ro.$$*
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(image_obj)/dev.rw.%: $$(module_obj)/cb_dev_rw.$$*
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
endif # CONFIG_BOOTPLAN_CB_SPLIT_PAYLOAD
ifeq ($(CONFIG_BOOTPLAN_CB_PAYLOAD),y)
image-y += depthcharge.elf depthcharge.payload \
dev.elf dev.payload netboot.elf netboot.payload
$(image_obj)/depthcharge.%: $$(module_obj)/cb_payload.$$*
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(image_obj)/dev.%: $$(module_obj)/cb_dev.$$*
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(image_obj)/netboot.%: $$(module_obj)/cb_netboot.$$*
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
endif # CONFIG_BOOTPLAN_CB_PAYLOAD
ifeq ($(CONFIG_BOOTPLAN_CB_IMAGE),y)
BUILD_IMAGE_LAYOUT = samus_cb
BUILD_IMAGE_LAYOUT_OPTS = \
--size=$(CONFIG_IMAGE_SIZE_KB) \
--hwid=$(CONFIG_IMAGE_HWID) \
--model=$(CONFIG_BOOTPLAN_CB_IMAGE_MODEL)$(MODEL_SUFFIX)
modules: $$(module_obj)/cb_payload.elf
modules: $$(module_obj)/cb_payload.payload
modules: $$(module_obj)/cb_dev.elf
modules: $$(module_obj)/cb_dev.payload
modules: $$(module_obj)/cb_netboot.elf
modules: $$(module_obj)/cb_netboot.payload
STANDARD_IMAGES=y
endif # CONFIG_BOOTPLAN_CB_IMAGE
ifeq ($(CONFIG_BOOTPLAN_FSP_V1_1),y)
BUILD_IMAGE_LAYOUT = fsp_v1_1
BUILD_IMAGE_LAYOUT_OPTS = \
--size=$(CONFIG_IMAGE_SIZE_KB) \
--hwid=$(CONFIG_IMAGE_HWID) \
--model=$(CONFIG_BOOTPLAN_FSP_MODEL)$(MODEL_SUFFIX) \
--ecs=$(CONFIG_BOOTPLAN_FSP_ECS) \
$(BUILD_IMAGE_SPD_OPT)
modules: $$(module_obj)/cb_payload.payload
modules: $$(module_obj)/cb_dev.payload
modules: $$(module_obj)/cb_netboot.payload
modules: $$(module_obj)/fsp_v1_1_entry.mod
modules: $$(module_obj)/fsp_v1_1_fw_sel.bin
STANDARD_IMAGES=y
endif # CONFIG_BOOTPLAN_FSP_V1_1
ifeq ($(CONFIG_BOOTPLAN_QEMU_X86),y)
BUILD_IMAGE_LAYOUT = qemu-x86
BUILD_IMAGE_LAYOUT_OPTS = \
--size=$(CONFIG_IMAGE_SIZE_KB) \
--hwid=$(CONFIG_IMAGE_HWID)
modules: $$(module_obj)/qemu_x86_entry.mod
modules: $$(module_obj)/qemu_firmware_select.elf
STANDARD_IMAGES=y
endif # CONFIG_BOOTPLAN_QEMU_X86
ifeq ($(CONFIG_BOOTPLAN_UEFI),y)
image-y += uefi.efi uefi.rwa.bin uefi.rwb.bin
image-y += uefi_dev.efi uefi_dev.rwa.bin uefi_dev.rwb.bin
image-y += uefi_net.efi
$(addprefix $(image_obj)/,$(image-y)): $(build_image)
# We'll add the layout and layout options manually, since we'll want to use
# different ones depending on what part of the image we're making.
BUILD_IMAGE_UEFI_COMMON_OPTS = \
--model=$(CONFIG_BOOTPLAN_UEFI_MODEL)$(MODEL_SUFFIX)
BUILD_IMAGE_UEFI_RO_COMMON_OPTS = \
$(BUILD_IMAGE_UEFI_COMMON_OPTS) \
--hwid=$(CONFIG_IMAGE_HWID)
$(image_obj)/uefi.ro.bin: $(build_image)
@printf " BUILD_IMAGE $(subst $(obj)/,,$@)\n"
$(Q)$(BUILD_IMAGE) uefi_ro $(BUILD_IMAGE_UEFI_RO_COMMON_OPTS)
$(image_obj)/uefi_dev.ro.bin: $(build_image)
@printf " BUILD_IMAGE $(subst $(obj)/,,$@)\n"
$(Q)$(BUILD_IMAGE) uefi_ro $(BUILD_IMAGE_UEFI_RO_COMMON_OPTS) --dev
$(image_obj)/uefi.rwa.bin: $$(module_obj)/uefi_rw.bin
@printf " BUILD_IMAGE $(subst $(obj)/,,$@)\n"
$(Q)$(BUILD_IMAGE) uefi_rw $(BUILD_IMAGE_UEFI_COMMON_OPTS)
$(image_obj)/uefi_dev.rwa.bin: $$(module_obj)/uefi_dev_rw.bin
@printf " BUILD_IMAGE $(subst $(obj)/,,$@)\n"
$(Q)$(BUILD_IMAGE) uefi_rw $(BUILD_IMAGE_UEFI_COMMON_OPTS) --dev
$(image_obj)/uefi.rwb.bin: $(image_obj)/uefi.rwa.bin
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(image_obj)/uefi_dev.rwb.bin: $(image_obj)/uefi_dev.rwa.bin
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(image_obj)/uefi.efi: $$(module_obj)/uefi.efi
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(image_obj)/uefi_dev.efi: $$(module_obj)/uefi_dev.efi
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
$(image_obj)/uefi_net.efi: $$(module_obj)/uefi_net.efi
@printf " CP $(subst $(obj)/,,$@)\n"
$(Q)cp $< $@
endif # CONFIG_BOOTPLAN_UEFI
ifeq ($(STANDARD_IMAGES),y)
image-y += image.bin image.serial.bin image.dev.bin image.net.bin
.PHONY: modules
$(addprefix $(image_obj)/,$(image-y)): modules
$(addprefix $(image_obj)/,$(image-y)): $(build_image)
$(image_obj)/image.bin:
@printf " BUILD_IMAGE $(subst $(obj)/,,$@)\n"
$(Q)$(BUILD_IMAGE)
$(image_obj)/image.serial.bin:
@printf " BUILD_IMAGE $(subst $(obj)/,,$@)\n"
$(Q)$(BUILD_IMAGE) --serial
$(image_obj)/image.dev.bin:
@printf " BUILD_IMAGE $(subst $(obj)/,,$@)\n"
$(Q)$(BUILD_IMAGE) --serial --dev
$(image_obj)/image.net.bin:
@printf " BUILD_IMAGE $(subst $(obj)/,,$@)\n"
$(Q)$(BUILD_IMAGE) --serial --netboot
endif # STANDARD_IMAGES