From 3182b56e35e1a07c920ebded54fc55686ced99bf Mon Sep 17 00:00:00 2001 From: "Alex Xu (Hello71)" Date: Wed, 11 Nov 2020 07:55:00 -0500 Subject: revamp module support, other refactoring --- Makefile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b82a41e..0efb2cf 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ +MAKEFLAGS += -r CFLAGS += -Wall -Wextra +KERNVER ?= $(shell uname -r) all: initramfs.img -initramfs.img: gen_init_cpio load-random-seed dropbear_ed25519_host_key modules.sh - ./make +initramfs.img: gen_init_cpio load-random-seed dropbear_ed25519_host_key modules.dep + KERNVER=$(KERNVER) COMPRESSOR="zstd -19 -c -T0" ./make %: %.c $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -o $@ @@ -11,9 +13,11 @@ initramfs.img: gen_init_cpio load-random-seed dropbear_ed25519_host_key modules. dropbear_ed25519_host_key: dropbearkey -t ed25519 -f $@ -modules.sh: modules - printf '%s\n' '#!/bin/sh' 'set -e' > $@ - xargs -a $< -L1 -r modprobe --show-depends >> $@ +modules.dep.ver: FORCE + if ! [ -f $@ ] || [ "$$(cat $@)" != "$(KERNVER)" ]; then echo $(KERNVER) > $@; fi + +modules.dep: modules /lib/modules/$(KERNVER)/modules.dep modules.dep.ver + awk '!/^#/ { print $1 }' modules | xargs modinfo -F filename -k $(KERNVER) | sed -e 's:^/lib/modules/$(KERNVER)/:^:' | grep -f - /lib/modules/$(KERNVER)/modules.dep > $@ install: initramfs.img rm -f /boot/initramfs.img.old /boot/initramfs.img.new @@ -22,9 +26,9 @@ install: initramfs.img mv /boot/initramfs.img.new /boot/initramfs.img clean: - rm -f initramfs.img initramfs.d gen_init_cpio load-random-seed + rm -f initramfs.img initramfs.d gen_init_cpio load-random-seed modules.dep -include initramfs.d .PHONY: all install clean -MAKEFLAGS += -r # slightly faster +FORCE: -- cgit v1.2.3-70-g09d2