-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
44 lines (32 loc) · 1.33 KB
/
Makefile
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
# Configuration that will be passed to sub-make
# Name of the kernel module
export KERNEL_MODULE := roulette
# Path to Linux kernel headers
export KERNEL_BUILD_PATH := /lib/modules/$(shell uname -r)/build
# Find all C and Rust source files
export C_FILES := $(shell find src/ -type f -name "*.c")
export RUST_FILES := $(shell find src/ -type f -name "*.rs") Cargo.toml Cargo.lock
# Define the architecture; this will be used for the LLVM target specification
export UTS_MACHINE = x86_64
# The Rust compiler and cross-compiler
export CARGO=cargo
export XARGO=xargo
# A JSON file specifying an LLVM target
export LLVM_TARGET_SPEC=$(UTS_MACHINE)-unknown-none-gnu.json
# Top-level project directory
export BASE_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
# The build directory
export BUILD_DIR := build
# The Makefile that is copied to $(BUILD_DIR)
export KBUILD := kbuild.mk
all: $(BUILD_DIR)/Makefile Makefile
# The kbuild makefile has been copied to $(BUILD_DIR), so now we can invoke kbuild from
# the kernel headers.
$(MAKE) -C "$(KERNEL_BUILD_PATH)" M="$(BASE_DIR)/$(BUILD_DIR)" modules
$(BUILD_DIR)/Makefile : $(KBUILD)
@mkdir -p "${BUILD_DIR}/src"
cp "$(KBUILD)" "$(BUILD_DIR)/Makefile"
clean:
# cleanup is really simple, we just blow away the $(BUILD_DIR) and call `xargo clean`
rm -rf "$(BUILD_DIR)"
xargo clean