Commit a9d6bd1e authored by Nick Elsmore's avatar Nick Elsmore

Add build.mk

parent c56f4828
#
# SPDX-License-Identifier: GPL-2.0+
#
KERNEL_DIR ?= $(realpath kernel)
UBOOT_DIR ?= $(realpath u-boot)
MULTISTRAP_DIR ?= $(realpath multistrap)
OUT_DIR ?= $(PWD)/out
VALID_PYRA_SOC := omap5
VALID_PYRA_DDR := 2gb 4gb
PYRA_SOC ?= omap5
PYRA_DDR ?= 4gb
ifeq (,$(filter $(PYRA_SOC),$(VALID_PYRA_SOC)))
$(error PYRA_SOC value "$(PYRA_SOC)" is invalid.)
endif
ifeq (,$(filter $(PYRA_DDR),$(VALID_PYRA_DDR)))
$(error PYRA_DDR value "$(PYRA_DDR)" is invalid.)
endif
KERNEL_DEFCONFIG := letux_pyra_defconfig
UBOOT_DEFCONFIG := $(PYRA_SOC)_pyra_$(PYRA_DDR)_defconfig
KBUILD_DEBARCH := armhf
KERNEL_BUILD_DIR := $(OUT_DIR)/kernel
UBOOT_BUILD_DIR := $(OUT_DIR)/bootloader
ROOTFS_DIR := $(OUT_DIR)/pyra-debian-stretch-mate-rootfs
all: linux bootloader rootfs
$(OUT_DIR):
@install -d $(OUT_DIR)
.PHONY: linux bootloader rootfs clean
linux: $(OUT_DIR)
$(MAKE) -C $(KERNEL_DIR) $(KERNEL_DEFCONFIG) O=$(KERNEL_BUILD_DIR)
$(MAKE) -C $(KERNEL_DIR) bindeb-pkg O=$(KERNEL_BUILD_DIR)
@install -d $(OUT_DIR)/dtb
@cp $(KERNEL_BUILD_DIR)/arch/arm/boot/zImage $(OUT_DIR)
@cp $(KERNEL_BUILD_DIR)/arch/arm/boot/dts/*.dtb $(OUT_DIR)/dtb
bootloader: $(OUT_DIR)
$(MAKE) -C $(UBOOT_DIR) $(UBOOT_DEFCONFIG) O=$(UBOOT_BUILD_DIR)
$(MAKE) -C $(UBOOT_DIR) O=$(UBOOT_BUILD_DIR)
@cp $(UBOOT_BUILD_DIR)/MLO $(OUT_DIR)
@cp $(UBOOT_BUILD_DIR)/u-boot.img $(OUT_DIR)
rootfs: $(OUT_DIR)
@multistrap -f $(MULTISTRAP_DIR)/pyra-stretch-mate.conf -d $(ROOTFS_DIR)
clean:
$(MAKE) -C $(UBOOT_DIR) distclean O=$(UBOOT_BUILD_DIR)
$(MAKE) -C $(UBOOT_DIR) clean O=$(UBOOT_BUILD_DIR)
$(MAKE) -C $(KERNEL_DIR) distclean O=$(KERNEL_BUILD_DIR)
$(MAKE) -C $(KERNEL_DIR) clean O=$(KERNEL_BUILD_DIR)
@rm -rf $(OUT_DIR)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment