-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (67 loc) · 2.81 KB
/
Copy pathMakefile
File metadata and controls
83 lines (67 loc) · 2.81 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# This file is heavily based on https://github.com/home-assistant/operating-system/blob/dev/Makefile
DEPLOYMENT_MODE := dev
BUILDDIR := $(shell pwd)
BUILDROOT = $(BUILDDIR)/buildroot
BUILDROOT_EXTERNAL = $(BUILDDIR)
RELEASE_DIR = $(BUILDDIR)/release
DEFCONFIG_DIR = $(BUILDROOT_EXTERNAL)/configs
TARGET_CONFIG_DIR = $(DEFCONFIG_DIR)/targets/
VERSION_DATE := $(shell date --utc +'%Y%m%d')
VERSION := "$(DEPLOYMENT_MODE)-$(VERSION_DATE)-$(shell git rev-parse --short HEAD)"
# Generate the targets
TARGETS := $(notdir $(patsubst %.config,%,$(wildcard $(TARGET_CONFIG_DIR)/*.config)))
TARGETS_CONFIG := $(notdir $(patsubst %.config,%-generate,$(wildcard $(TARGET_CONFIG_DIR)/*.config)))
# Set O variable if not already done on the command line
ifneq ("$(origin O)", "command line")
O := $(BUILDDIR)/output
else
override O := $(BUILDDIR)/$(O)
endif
.NOTPARALLEL: $(TARGETS) $(TARGETS_CONFIG) all
.PHONY: $(TARGETS) $(TARGETS_CONFIG) all qemu qemu-dev clean legal client help
all: $(TARGETS)
qemu:
export QEMU_BUILD=1
$(MAKE) rpi4_64
qemu-dev:
./qemu/run_qemu_rpi4.sh
vscode:
./scripts/development/prepare-vscode.sh
$(RELEASE_DIR):
mkdir -p $(RELEASE_DIR)
# Generate the required defconfig files and pass them to buildroot
$(TARGETS_CONFIG): %-generate:
@echo "generating config: configs/targets/$*.config"
python3 scripts/make_defconfig.py -g configs/targets/$*.config -o configs/$*_defconfig
@echo "building with config $*_defconfig"
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) "$*_defconfig"
$(TARGETS): %: $(RELEASE_DIR) %-generate
@echo "build $@"
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) VERSION=$(VERSION)
mv -f $(O)/images/*.raucb $(RELEASE_DIR)/
mv -f $(O)/images/*.img $(RELEASE_DIR)/
# Create a slightly compressed version of all .img files
zstd -T0 -f $(RELEASE_DIR)/*.img
# Do not clean when building for one target
ifneq ($(words $(filter $(TARGETS),$(MAKECMDGOALS))), 1)
@echo "clean $@"
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) clean
endif
@echo "finished $@"
clean:
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) clean
rm -rf configs/*_defconfig
legal:
# Create legal-info
rm -rf output/legal-info/
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) legal-info
client:
$(MAKE) -C $(BUILDROOT) O=$(O) BR2_EXTERNAL=$(BUILDROOT_EXTERNAL) leocommon-client-dirclean leocommon-client
help:
@echo "Supported targets: $(TARGETS)"
@echo "Run 'make <target>' to build a target image."
@echo "Run 'make all' to build all target images."
@echo "Run 'make clean' to clean the build output."
@echo "Run 'make <target>-config' to configure buildroot for a target."
@echo "Run 'make qemu' to run the qemu rpi3b emulator in interactive mode"
@echo "Run 'make qemu-dev' to run the qemu rpi3b emulator in dev mode (keeps all files)."