# use sudo (non interactively) when running as regular user ifneq ($(shell id -u),0) AS_ROOT := sudo -n endif MOUNT := $(AS_ROOT) mount UMOUNT := $(AS_ROOT) umount CTR := podman CP := cp GIT := git CTR_IMG_TAG := avans-linux CTRIZE := $(CTR) run CTRIZE += --rm CTRIZE += --tty CTRIZE += --volume /tmp:/tmp:rw CTRIZE += --volume .:/workdir:rw CTRIZE += --env-file ./env CTRIZE += --env MAKE* CTRIZE += $(CTR_IMG_TAG) export # create dummy files to represent non-file targets (container image build # status, sd card partition status, git submodule initialization, etc.) $(eval $(shell state/gen)) # read environment variables from ./env include ./env export # shortcuts .PHONY: all all: $(BOOTLOADER_FILES) .PHONY: sd_format sd_partition sd_format: state/sdcard_fmt sd_partition: state/sdcard_part state/container_img: Containerfile $(CTR) build --tag $(CTR_IMG_TAG) . touch $@ state/submodules: $(GIT) submodule update --init touch $@ state/sdcard_part: $(AS_ROOT) util/part $(SDCARD_DISK) touch $@ state/sdcard_fmt: state/sdcard_part $(eval $(shell state/gen)) $(AS_ROOT) mkfs.vfat -n BOOT -F 32 $(SDCARD_PART_BOOT) $(AS_ROOT) mkfs.ext4 -L ROOTFS -F $(SDCARD_PART_ROOTFS) touch $@ bootloader/.config: state/submodules $(CTRIZE) $(MAKE) -C bootloader am335x_evm_config .PHONY: build_bootloader build_bootloader: bootloader/.config $(CTRIZE) $(MAKE) -C bootloader BOOTLOADER_FILES += bootloader/u-boot.img BOOTLOADER_FILES += bootloader/u-boot.dtb BOOTLOADER_FILES += bootloader/MLO $(BOOTLOADER_FILES): build_bootloader kernel/.config: state/submodules $(CTRIZE) $(MAKE) -C kernel bb.org_defconfig .PHONY: build_kernel build_kernel: kernel/.config $(CTRIZE) $(MAKE) -C kernel zImage KERNEL_FILES += kernel/arch/$(ARCH)/boot/dts/am335x-boneblack.dtb KERNEL_FILES += kernel/arch/$(ARCH)/boot/zImage $(KERNEL_FILES): build_kernel .PHONY: load_boot load_rootfs load_boot: $(BOOTLOADER_FILES)# $(KERNEL_FILES) mkdir -p mnt/boot $(MOUNT) $(SDCARD_PART_BOOT) mnt/boot $(AS_ROOT) $(CP) $^ mnt/boot $(AS_ROOT) sync $(UMOUNT) mnt/boot load_rootfs: mkdir -p mnt/rootfs $(MOUNT) $(SDCARD_PART_ROOTFS) mnt/rootfs # TODO $(UMOUNT) mnt/rootfs .PHONY: status status: @echo '### STATUS REPORT' @echo '# ENVIRONMENT' state/gen @echo '# TARGETS' @ls state | awk '$$0 == "gen" || $$0 == "auto.mk" { next } { print }'