mirror of
https://github.com/chipsec/chipsec
synced 2026-06-08 13:31:00 +00:00
4f6ed29c84
Several improvements * Drop the detection of EFI through kallsyms. This detection is no longer useful since commit2c0c4c9fd1("Using CONFIG_EFI instead of user defined HAS_EFI (#1036)") replaced `HAS_EFI` with `CONFIG_EFI`. * Use `...-objs-y` and `...-objs-$(CONFIG_...)` logic to choose which `cpu.asm` file is being built. This is something that other modules do in Linux kernel source. * Introduce `quiet_cmd_...` and `cmd_...` definition in order to use the build system of the kernel to compile `cpu.asm` with NASM. This should prevent issues like the one mentioned in2210002bab("Fixed build error on latest Ubuntu") from happening again. Moreover this makes the custom clean command `rm -f ${asm-path}/cpu.o` no longer necessary. * Remove variables which become unused after these changes. Now, all that `Makefile` needs is a kernel directory, specified with `KSRC`. This change has been tested on a test system running Ubuntu 20.10 and on GitHub Actions workers running Ubuntu 16.04, 18.04 and 20.04 on Linux 5.4.0-1040-azure. It has also been compile-tested on many other Linux distributions using a work-in-progress GitHub Actions configuration (https://github.com/fishilico/chipsec/actions/runs/661200380).
40 lines
859 B
Makefile
40 lines
859 B
Makefile
DESTDIR =
|
|
MODDIR = $(DESTDIR)/lib/modules
|
|
KVERS = $(shell uname -r)
|
|
KVER = $(KVERS)
|
|
VMODDIR = $(MODDIR)/$(KVER)
|
|
KSRC ?= $(VMODDIR)/build
|
|
|
|
obj-m += chipsec.o
|
|
chipsec-objs-y := chipsec_km.o
|
|
chipsec-objs-$(CONFIG_X86_32) += i386/cpu.o
|
|
chipsec-objs-$(CONFIG_X86_64) += amd64/cpu.o
|
|
chipsec-objs := $(chipsec-objs-y)
|
|
|
|
quiet_cmd_nasm32 = NASM_32 $@
|
|
cmd_nasm32 = nasm -f elf32 -o $@ $<
|
|
|
|
quiet_cmd_nasm64 = NASM_64 $@
|
|
cmd_nasm64 = nasm -f elf64 -o $@ $<
|
|
|
|
|
|
all: chipsec
|
|
|
|
check_kernel_dir:
|
|
@if [ ! -d $(KSRC) ]; then \
|
|
echo "Unable to find the Linux source tree."; \
|
|
exit 1; \
|
|
fi
|
|
|
|
chipsec: check_kernel_dir clean
|
|
make -C $(KSRC) M=$(CURDIR) modules
|
|
|
|
clean: check_kernel_dir
|
|
make -C $(KSRC) M=$(CURDIR) clean
|
|
|
|
$(obj)/i386/cpu.o: $(src)/i386/cpu.asm
|
|
$(call if_changed,nasm32)
|
|
|
|
$(obj)/amd64/cpu.o: $(src)/amd64/cpu.asm
|
|
$(call if_changed,nasm64)
|