forked from jens-maus/thinRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (72 loc) · 3.42 KB
/
Makefile
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
84
85
86
87
88
89
90
91
PRODUCT=intel_nuc
BUILDROOT_VERSION=2021.02.1
VERSION=$(shell cat ./VERSION)
BOARD=$(shell echo $(PRODUCT) | cut -d'_' -f2)
.PHONY: all
all: usage
.PHONY: usage
usage:
@echo "ThinRoot Build Environment"
@echo "Usage:"
@echo " $(MAKE) dist: install buildroot and create default image"
@echo " $(MAKE) release: create image and corresponding release archive"
@echo " $(MAKE) install of=/dev/sdX: write image to SD card under /dev/sdX"
@echo " $(MAKE) distclean: clean everything"
buildroot-$(BUILDROOT_VERSION).tar.bz2:
wget https://buildroot.org/downloads/buildroot-$(BUILDROOT_VERSION).tar.bz2
wget https://buildroot.org/downloads/buildroot-$(BUILDROOT_VERSION).tar.bz2.sign
cat buildroot-$(BUILDROOT_VERSION).tar.bz2.sign | grep SHA1: | sed 's/^SHA1: //' | shasum -c
BUILDROOT_PATCHES=$(wildcard buildroot-patches/*.patch)
buildroot-$(BUILDROOT_VERSION): | buildroot-$(BUILDROOT_VERSION).tar.bz2
if [ ! -d $@ ]; then tar xf buildroot-$(BUILDROOT_VERSION).tar.bz2; for p in $(BUILDROOT_PATCHES); do patch -d buildroot-$(BUILDROOT_VERSION) -p1 < $${p}; done; fi
build-$(PRODUCT): | buildroot-$(BUILDROOT_VERSION) download
mkdir -p build-$(PRODUCT)
download: buildroot-$(BUILDROOT_VERSION)
mkdir -p download
build-$(PRODUCT)/.config: | build-$(PRODUCT)
cd build-$(PRODUCT) && $(MAKE) O=$(shell pwd)/build-$(PRODUCT) -C ../buildroot-$(BUILDROOT_VERSION) BR2_EXTERNAL=../buildroot-external PRODUCT=$(PRODUCT) $(PRODUCT)_defconfig
.PHONY: dist
dist: | buildroot-$(BUILDROOT_VERSION) build-$(PRODUCT)/.config
cd build-$(PRODUCT) && $(MAKE) O=$(shell pwd)/build-$(PRODUCT) -C ../buildroot-$(BUILDROOT_VERSION) BR2_EXTERNAL=../buildroot-external PRODUCT=$(PRODUCT)
.PHONY: release
release: dist
cp -a build-$(PRODUCT)/images/bzImage ./release/thinroot-$(VERSION).img
cd ./release && sha256sum thinroot-$(VERSION).img >thinroot-$(VERSION).img.sha256
.PHONY: clean
clean:
rm -rf build-$(PRODUCT) buildroot-$(BUILDROOT_VERSION)
.PHONY: distclean
distclean: clean
rm -f buildroot-$(BUILDROOT_VERSION).tar.bz2*
rm -rf download
.PHONY: mount
mount:
sudo kpartx -av build-$(PRODUCT)/images/sdcard.img
sudo mkdir -p /mnt/p2
sudo mount /dev/mapper/loop0p2 /mnt/p2
.PHONY: unmount
umount:
sudo umount /mnt/p2
sudo kpartx -dv build-$(PRODUCT)/images/sdcard.img
.PHONY: install
install:
sudo dd if=build-$(PRODUCT)/images/sdcard.img of=$(of) bs=1M conv=fsync status=progress
.PHONY: menuconfig
menuconfig: buildroot-$(BUILDROOT_VERSION) build-$(PRODUCT)
cd build-$(PRODUCT) && $(MAKE) O=$(shell pwd)/build-$(PRODUCT) -C ../buildroot-$(BUILDROOT_VERSION) BR2_EXTERNAL=../buildroot-external PRODUCT=$(PRODUCT) menuconfig
.PHONY: xconfig
xconfig: buildroot-$(BUILDROOT_VERSION) build-$(PRODUCT)
cd build-$(PRODUCT) && $(MAKE) O=$(shell pwd)/build-$(PRODUCT) -C ../buildroot-$(BUILDROOT_VERSION) BR2_EXTERNAL=../buildroot-external PRODUCT=$(PRODUCT) xconfig
.PHONY: savedefconfig
savedefconfig: buildroot-$(BUILDROOT_VERSION) build-$(PRODUCT)
cd build-$(PRODUCT) && $(MAKE) O=$(shell pwd)/build-$(PRODUCT) -C ../buildroot-$(BUILDROOT_VERSION) BR2_EXTERNAL=../buildroot-external PRODUCT=$(PRODUCT) savedefconfig BR2_DEFCONFIG=../buildroot-external/configs/$(PRODUCT)_defconfig
# Create a fallback target (%) to forward all unknown target calls to the build Makefile.
# This includes:
# linux-menuconfig
# linux-update-defconfig
# busybox-menuconfig
# busybox-update-config
# uboot-menuconfig
# uboot-update-defconfig
%:
@$(MAKE) -C build-$(PRODUCT) PRODUCT=$(PRODUCT) $@