aboutsummaryrefslogtreecommitdiff
path: root/makefile
blob: 6b4ce78dec1361d9963cc45a10544c20141a8421 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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
endif

MOUNT := $(AS_ROOT) mount
UMOUNT := $(AS_ROOT) umount

CTR := podman
CP := cp
GIT := git

CTR_IMG_TAG := avans-linux

CTRIZE := $(CTR) run --rm --interactive --tty
CTRIZE += --volume .:/workdir:rw
CTRIZE += --env-file ./env
CTRIZE += $(CTR_IMG_TAG)

.PHONY: all
all: os_bootloader

.PHONY: container_img
container_img: Containerfile
	$(CTR) build --tag $(CTR_IMG_TAG) .

# 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):
	$(GIT) submodule init
	$(GIT) submodule update

.PHONY: os_bootloader
os_bootloader: $(SUBMODULE_INIT)
	$(CTRIZE) $(MAKE) -$(MAKEFLAGS) -C u-boot am335x_evm_config
	$(CTRIZE) $(MAKE) -$(MAKEFLAGS) -C u-boot

.PHONY: os_kernel
os_kernel:
	$(CTRIZE) $(MAKE) -$(MAKEFLAGS) -C kernel omap2plus_defconfig
	$(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