mirror of
https://github.com/chipsec/chipsec
synced 2026-06-08 13:31:00 +00:00
fbf45bd56c
It was previously possible to build Chipsec kernel module for a different Linux
kernel than the running one, and ff4a273 broke that possibility.
Bring that back just by giving a way to override the KSRC variable when calling
the Makefile.
Fix issue #1122
41 lines
900 B
Makefile
41 lines
900 B
Makefile
MACHINE ?= $(shell uname -m)
|
|
|
|
DESTDIR =
|
|
MODDIR = $(DESTDIR)/lib/modules
|
|
KVERS = $(shell uname -r)
|
|
KVER = $(KVERS)
|
|
VMODDIR = $(MODDIR)/$(KVER)
|
|
KSRC ?= $(VMODDIR)/build
|
|
|
|
ifeq (,$(filter %i686 %i386 %i586,$(MACHINE)))
|
|
elf-size := elf64
|
|
asm-path := amd64
|
|
else
|
|
elf-size := elf32
|
|
asm-path := i386
|
|
endif
|
|
|
|
chipsec-objs := chipsec_km.o $(asm-path)/cpu.o
|
|
obj-m += chipsec.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
|
|
nasm -f $(elf-size) -o $(asm-path)/cpu.o $(asm-path)/cpu.asm
|
|
touch $(asm-path)/.cpu.o.cmd
|
|
@if [ `grep -c 'efi_call' /proc/kallsyms` != "0" ]; then \
|
|
make CFLAGS_MODULE=-DHAS_EFI=1 -C $(KSRC) M=$(CURDIR) modules; \
|
|
else \
|
|
make -C $(KSRC) M=$(CURDIR) modules; \
|
|
fi
|
|
|
|
clean: check_kernel_dir
|
|
make -C $(KSRC) M=$(CURDIR) clean
|
|
rm -f ${asm-path}/cpu.o
|