summaryrefslogtreecommitdiff
path: root/Makefile
blob: 1c5bca3c845a378fbb5dcbc7efcca2f37b9bc336 (plain) (blame)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
VERSION=linux-6.8.4
VERSION_DISTR = $(VERSION)-vmkos
VERSION_BUILD = $(VERSION_DISTR)-night
CLEAN_BUILD = $(subst linux-,,$(VERSION_BUILD))

TRUSTED_KEYS = ABAF11C65A2970B130ABE3C479BE3E4300411886  # Linus Torvalds
TRUSTED_KEYS += 647F28654894E3BD457199BE38DBBDC86092693E  # Greg Kroah-Hartman

SRC_URL = https://cdn.kernel.org/pub/linux/kernel/v6.x/$(VERSION).tar.xz
# PGP_SGN_URL = https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.8.4.tar.sign

CFLAGS = -std=gnu2x -Wall -Werror -Wno-pointer-sign -Werror=vla
C_ARCH = $$(uname -m)

ifdef ONELINE_OUTPUT
	# SED_SUBST = | stdbuf --output=L sed 's/^/\\e[0A\\e[K3<>/gi'
	SED_SUBST = | stdbuf --output=L ./interliner
else
SED_SUBST=
endif

SILENCE=
ifdef QUIET
SILENCE += >all.log
endif

ifdef SILENT
SILENCE += 2>err.log
endif

OUT_FMT = $(SED_SUBST) $(SILENCE)

default: all

all: pre_install install post_install

pre_install: interliner $(VERSION).tar
	# rm -f linux-6.8.4.tar.xz
	@printf "> MAKING::$@\n"
	tar --skip-old-files -xvf linux-6.8.4.tar.xz 2>tar.err.log | grep -v "skipping existing file" | sed 's/^/\t=> /g' $(OUT_FMT)
	@printf "> MAKING::$@::DONE\n"

install: interliner $(VERSION) clear.ok patch patch.ok build build.ok
	@printf "> MAKING::$@\n"

	sudo install -C -m755 $(VERSION)/arch/$(C_ARCH)/boot/bzImage /boot/vmlinuz-linux-VMKOS

	./mkcp.sh $(VERSION) | sed 's/^/\t==> /g' $(SED_SUBST) $(OUT_FMT)

	@printf "> MAKING::$@::DONE\n"

reinstall: interliner $(VERSION) clear.ok patch patch.ok build build.ok
	@printf "> MAKING::$@\n"
	tar -xvf linux-6.8.4.tar.xz 2>tar.err.log | sed 's/^/\t=> /g' $(OUT_FMT)
	sudo install -C -m755 $(VERSION)/arch/$(C_ARCH)/boot/bzImage /boot/vmlinuz-linux-VMKOS
	./mkcp.sh $(VERSION) | sed 's/^/\t==> /g' $(SED_SUBST) $(OUT_FMT)
	@printf "> MAKING::$@::DONE\n"

post_install: interliner
	# @printf "> MAKING::$@\n"
	@printf "> MAKING::$@::DONE\n"

.PHONY: pre_install install post_install clean clean_misc

$(VERSION).tar: $(VERSION).tar.xz $(VERSION).tar.sign
	@printf "\t> MAKING::$@\n"

	xz -kd $(VERSION).tar.xz | sed 's/^/\t==> /g' $(OUT_FMT)

ifdef NO_VERIFY
	@printf "\t==> Will not verify\n"
else ifdef SKIP_VERIFY
	@printf "\t==> Will not verify\n"
else
	@printf "\t==> Verifying...\n"

	gpg2 --recv-keys $(TRUSTED_KEYS) $(OUT_FMT)
	if [ "$$(gpg2 --logger-fd 1 --verify $(VERSION).tar.sign | grep 'Good signature')" == "" ]; then false; fi
endif

	@printf "\t> MAKING::$@::DONE\n"

$(VERSION).tar.xz:
	@printf "\t> MAKING::$@\n"
	wget https://cdn.kernel.org/pub/linux/kernel/v6.x/$(VERSION).tar.xz | sed 's/^/\t==> /g' $(OUT_FMT)
	@printf "\t> MAKING::$@::DONE\n"

$(VERSION).tar.sign:
	@printf "\t> MAKING::$@\n"
	wget https://cdn.kernel.org/pub/linux/kernel/v6.x/$(VERSION).tar.sign | sed 's/^/\t==> /g' $(OUT_FMT)
	@printf "\t> MAKING::$@::DONE\n"

patch: ./patch.sh
	@printf "\t> MAKING::$@\n"
	./patch.sh $(VERSION) skip | sed 's/^/\t==> /g' $(SED_SUBST) $(OUT_FMT)
	@printf "\t> MAKING::$@::DONE\n"

build: ./build.sh
	@printf "\t> MAKING::$@\n"
	./build.sh $(VERSION) $(CLEAN_BUILD) | sed 's/^/\t==> /g' $(SED_SUBST) $(OUT_FMT)
	@printf "\t> MAKING::$@::DONE\n"

mkcp: ./mkcp.sh
	@printf "\t> MAKING::$@\n"
	./mkcp.sh $(VERSION) $(CLEAN_BUILD) | sed 's/^/\t==> /g' $(SED_SUBST) $(OUT_FMT)
	@printf "\t> MAKING::$@::DONE\n"

interliner: interliner.c

clean: interliner
	rm -f *.tar *.sign *.sign?? *.xz $(OUT_FMT)

clean_misc: interliner
	rm -f *.tar *.sign *.sign?? $(OUT_FMT)

clear.ok:
	rm -f *.ok