-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (43 loc) · 2.13 KB
/
Copy pathMakefile
File metadata and controls
53 lines (43 loc) · 2.13 KB
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
# GhostRing — Hypervisor-based endpoint security
# Author: Baurzhan Atynov <bauratynov@gmail.com>
# SPDX-License-Identifier: Apache-2.0
KDIR ?= /lib/modules/$(shell uname -r)/build
MODULE_DIR = loader/linux
CC = gcc
CFLAGS_BASE = -std=c99 -Wall -Wextra -Werror -ffreestanding -nostdlib \
-mno-red-zone -mcmodel=kernel -fno-stack-protector
# ─── CPU detection ───────────────────────────────────────────────────
VENDOR := $(shell grep -m1 vendor_id /proc/cpuinfo 2>/dev/null | awk '{print $$NF}')
ifeq ($(VENDOR),GenuineIntel)
DEFAULT_TARGET = vmx
else ifeq ($(VENDOR),AuthenticAMD)
DEFAULT_TARGET = svm
else
DEFAULT_TARGET = vmx
endif
# ─── Targets ─────────────────────────────────────────────────────────
.PHONY: all vmx svm module clean test
all: $(DEFAULT_TARGET)
@echo "[GhostRing] Built for $(DEFAULT_TARGET) (detected: $(VENDOR))"
vmx: CFLAGS = $(CFLAGS_BASE) -DGHOSTRI_NG_VTX
vmx: module
@echo "[GhostRing] Intel VT-x build complete"
svm: CFLAGS = $(CFLAGS_BASE) -DGHOSTRI_NG_SVM
svm: module
@echo "[GhostRing] AMD-V build complete"
module:
$(MAKE) -C $(KDIR) M=$(CURDIR)/$(MODULE_DIR) \
EXTRA_CFLAGS="$(CFLAGS)" modules
# ─── Clean ───────────────────────────────────────────────────────────
clean:
$(MAKE) -C $(KDIR) M=$(CURDIR)/$(MODULE_DIR) clean
find . -name '*.o' -o -name '*.ko' -o -name '*.mod*' \
-o -name '.*.cmd' -o -name 'modules.order' \
-o -name 'Module.symvers' | xargs rm -f
rm -rf .tmp_versions
@echo "[GhostRing] Clean complete"
# ─── Test ────────────────────────────────────────────────────────────
test:
@echo "[GhostRing] Running unit tests..."
$(MAKE) -C tests run
@echo "[GhostRing] All tests passed"