pH/kernel/Makefile

83 lines
2.2 KiB
Makefile
Raw Normal View History

2017-10-15 22:36:00 -04:00
2019-09-20 17:55:12 -04:00
LINUX_VERSION = 5.3
2017-10-15 22:36:00 -04:00
KERNEL_VERSION = linux-$(LINUX_VERSION)
2019-09-20 17:55:12 -04:00
KERNEL_DOWNLOAD = https://cdn.kernel.org/pub/linux/kernel/v5.x/$(KERNEL_VERSION)
2017-10-15 22:36:00 -04:00
PWD = $(shell pwd)
2019-09-20 17:55:12 -04:00
NPROC = $(shell nproc)
2017-10-15 22:36:00 -04:00
PATCH_FILES := $(shell find patches/ -name "00*.patch" | sort)
KERNEL_DL_PATH = downloads/$(KERNEL_VERSION).tar
2019-09-20 17:55:12 -04:00
KERNEL_BUILD_PATH = $(KERNEL_VERSION)
2017-10-15 22:36:00 -04:00
KERNEL_BUILD_OUTPUT = $(KERNEL_BUILD_PATH)/vmlinux
PH_LINUX = ph_linux
PH_LINUX_VER = $(PH_LINUX)-$(LINUX_VERSION)
2017-10-15 22:36:00 -04:00
SHA256_FILE = v$(KERNEL_VERSION).sha256
$(shell mkdir -p downloads)
2019-09-20 17:55:12 -04:00
$(shell mkdir -p .work)
2019-09-20 17:55:12 -04:00
SHA256_SENTINEL = .work/.sha256-verififed
2017-10-15 22:36:00 -04:00
.PHONY: all gen-sha256
all: $(KERNEL_BUILD_OUTPUT) $(PH_LINUX_VER)
2017-10-15 22:36:00 -04:00
$(KERNEL_DL_PATH):
2019-09-20 17:55:12 -04:00
cd downloads; wget $(KERNEL_DOWNLOAD).tar.xz
cd downloads; unxz $(KERNEL_VERSION).tar.xz
cd downloads; wget $(KERNEL_DOWNLOAD).tar.sign
2017-10-15 22:36:00 -04:00
2019-09-20 17:55:12 -04:00
$(KERNEL_BUILD_PATH): $(KERNEL_DL_PATH) $(SHA256_SENTINEL)
rm -rf .work/$(KERNEL_VERSION)
tar -C .work -xf downloads/$(KERNEL_VERSION).tar
for p in $(PATCH_FILES); do patch -p1 -d .work/$(KERNEL_VERSION) < "$$p"; done
cp config .work/$(KERNEL_VERSION)/.config
rm -rf ./$(KERNEL_VERSION)
mv .work/$(KERNEL_VERSION) .
2017-10-15 22:36:00 -04:00
2019-09-20 17:55:12 -04:00
#$(PATCH_SENTINEL): | $(KERNEL_BUILD_PATH)
# for p in $(PATCH_FILES); do patch -p1 -d $(KERNEL_VERSION) < "$$p"; done
# touch $@
2017-10-15 22:36:00 -04:00
2019-09-20 17:55:12 -04:00
$(PH_LINUX_VER): $(KERNEL_BUILD_OUTPUT)
rm -f $(PH_LINUX)
cp $(KERNEL_BUILD_OUTPUT) $(PH_LINUX_VER)
strip $(PH_LINUX_VER)
ln -s $(PWD)/$(PH_LINUX_VER) $(PH_LINUX)
2017-10-15 22:36:00 -04:00
2019-09-20 17:55:12 -04:00
$(KERNEL_BUILD_OUTPUT): $(KERNEL_BUILD_PATH)
cd $(KERNEL_VERSION); make -j$(NPROC)
2017-10-15 22:36:00 -04:00
2019-09-20 17:55:12 -04:00
clean:
rm -rf $(KERNEL_BUILD_PATH) $(SHA256_SENTINEL) $(PH_LINUX_VER) $(PH_LINUX) .work
2017-10-15 22:36:00 -04:00
2019-09-20 17:55:12 -04:00
$(SHA256_SENTINEL): $(KERNEL_DL_PATH)
sha256sum -c v$(LINUX_VERSION).sha256
touch $@
2017-10-15 22:36:00 -04:00
gen-sha256: $(SHA256_FILE)
2019-09-20 17:55:12 -04:00
GPGTMP = verify-tmp/
GPGOPTS = --homedir $(GPGTMP) --trust-model direct --no-autostart
GPG_IMPORT = gpg $(GPGOPTS) --import
GPG_VERIFY = gpg $(GPGOPTS) --verify
2017-10-15 22:36:00 -04:00
$(KERNEL_DL_PATH).verify: $(KERNEL_DL_PATH)
rm -rf $(GPGTMP)
2019-09-20 17:55:12 -04:00
mkdir -m 0700 $(GPGTMP)
2017-10-15 22:36:00 -04:00
$(GPG_IMPORT) < keys/torvalds.key
$(GPG_IMPORT) < keys/gregkh.key
$(GPG_VERIFY) downloads/$(KERNEL_VERSION).tar.sign $(KERNEL_DL_PATH) 2> .out
mv .out $(KERNEL_DL_PATH).verify
rm -rf $(GPGTMP)
2019-09-20 17:55:12 -04:00
$(SHA256_FILE): $(KERNEL_DL_PATH).verify
sha256sum $(KERNEL_DL_PATH) > v$(LINUX_VERSION).sha256
2017-10-15 22:36:00 -04:00