aboutsummaryrefslogtreecommitdiff
path: root/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'makefile')
-rw-r--r--makefile65
1 files changed, 35 insertions, 30 deletions
diff --git a/makefile b/makefile
index 6b4ce78..da94b65 100644
--- a/makefile
+++ b/makefile
@@ -1,7 +1,3 @@
-# read environment variables from ./env
-include ./env
-export
-
# use sudo (non interactively) when running as regular user
ifneq ($(shell id -u),0)
AS_ROOT := sudo -n
@@ -20,42 +16,51 @@ CTRIZE := $(CTR) run --rm --interactive --tty
CTRIZE += --volume .:/workdir:rw
CTRIZE += --env-file ./env
CTRIZE += $(CTR_IMG_TAG)
+export
+
+# create files that represent otherwise PHONY targets
+$(shell state/gen)
+-include state/auto.mk
+
+# read environment variables from ./env
+include ./env
+export
.PHONY: all
-all: os_bootloader
+all: $(BOOTLOADER_FILES)
-.PHONY: container_img
-container_img: Containerfile
+state/container_img: Containerfile
$(CTR) build --tag $(CTR_IMG_TAG) .
+ touch $@
-# this list holds the .git files in each submodule folder (add
-# $(SUBMODULE_INIT) as prerequisite to require the submodules to exist)
-SUBMODULE_INIT += ./u-boot/.git
-SUBMODULE_INIT += ./kernel/.git
-$(SUBMODULE_INIT):
+state/submodules:
$(GIT) submodule init
$(GIT) submodule update
+ touch $@
-.PHONY: os_bootloader
-os_bootloader: $(SUBMODULE_INIT)
- $(CTRIZE) $(MAKE) -$(MAKEFLAGS) -C u-boot am335x_evm_config
- $(CTRIZE) $(MAKE) -$(MAKEFLAGS) -C u-boot
+BOOTLOADER_FILES += bootloader/MLO
+BOOTLOADER_FILES += bootloader/u-boot.img
+BOOTLOADER_FILES += bootloader/u-boot.dtb
+bootloader/.config: state/submodules
+ $(CTRIZE) $(MAKE) -$(MAKEFLAGS) -C bootloader am335x_evm_config
+$(BOOTLOADER_FILES): bootloader/.config
+ $(CTRIZE) $(MAKE) -$(MAKEFLAGS) -C bootloader
-.PHONY: os_kernel
-os_kernel:
+KERNEL_FILES += kernel/
+kernel/.config: state/submodules
$(CTRIZE) $(MAKE) -$(MAKEFLAGS) -C kernel omap2plus_defconfig
+$(KERNEL_FILES): kernel/.config
$(CTRIZE) $(MAKE) -$(MAKEFLAGS) -C kernel
-# sd card block device prefix (assumed partition numbers, see readme.md)
-# SDCARD_BD_PREFIX := /dev/sdc
-SDCARD_BD_PREFIX := /dev/mmcblk0p
-load_bootloader: $(os_bootloader)
- mkdir -p /tmp/sdcard-boot
- $(MOUNT) $(SDCARD_BD_PREFIX)1 /tmp/sdcard-boot
- $(AS_ROOT) $(CP) u-boot/MLO u-boot/u-boot.img u-boot/u-boot.dtb /tmp/sdcard-boot
- $(UMOUNT) $(SDCARD_BD_PREFIX)1
-
-format_sd:
- $(AS_ROOT) mkfs.vfat -n BOOT -F 32 $(SDCARD_BD_PREFIX)1
- $(AS_ROOT) mkfs.ext4 -L ROOTFS -F $(SDCARD_BD_PREFIX)2
+.PHONY: load_bootloader
+load_bootloader: $(BOOTLOADER_FILES)
+ mkdir -p mnt/boot mnt/rootfs
+ $(MOUNT) $(SDCARD_PART_BOOT) mnt/boot
+ $(AS_ROOT) $(CP) $(BOOTLOADER_FILES) mnt/boot
+ $(UMOUNT) mnt/boot
+
+.PHONY: sd_format
+sd_format:
+ $(AS_ROOT) mkfs.vfat -n BOOT -F 32 $(SDCARD_PART_BOOT)
+ $(AS_ROOT) mkfs.ext4 -L ROOTFS -F $(SDCARD_PART_ROOTFS)