mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-24 18:51:36 +01:00
Build the Linux kernel independently from Buildroot
This will allow for other types of root filesystems that don't rely on Buildroot to be added and used in the future. Propagate --verbose on all build scripts to see full GCC commands. build-all: allow for neat subsets also 9p share rootfs_overlay. TODO document.
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
obj-m += $(addsuffix .o, $(notdir $(basename $(filter-out %.mod.c, $(wildcard $(BR2_EXTERNAL_KERNEL_MODULES_PATH)/*.c)))))
|
||||
obj-m += $(OBJECT_FILES)
|
||||
ccflags-y := -DDEBUG -g -std=gnu99 -Werror -Wno-declaration-after-statement -Wframe-larger-than=1000000000
|
||||
|
||||
.PHONY: all clean
|
||||
.PHONY: all
|
||||
|
||||
all:
|
||||
$(MAKE) -C '/lib/modules/$(shell uname -r)/build' M='$(PWD)' modules
|
||||
|
||||
clean:
|
||||
$(MAKE) -C '$(LINUX_DIR)' M='$(PWD)' clean
|
||||
$(MAKE) -C '$(LINUX_DIR)' M='$(M)'
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# We can almost do everything from the Makefile itself by using default values for
|
||||
#
|
||||
# LINUX_DIR ?= "/lib/modules/$(uname -r)/build"
|
||||
# BR2_EXTERNAL_KERNEL_MODULES_PATH="$(pwd)"
|
||||
#
|
||||
# The problem with that is that if you define those variables in your environment,
|
||||
# the build breaks, so this is more portable.
|
||||
#
|
||||
# Trying to add `-i` to overcome incompatible modules will fail,
|
||||
# because any build failure prevents the generation of all `.mod.c` files.
|
||||
|
||||
j="$(($(nproc) - 2))"
|
||||
while getopts j: OPT; do
|
||||
case "$OPT" in
|
||||
'j')
|
||||
j="$OPTARG"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
make -j "$j" KERNEL_MODULES_PATH="$(pwd)" LINUX_DIR="/lib/modules/$(uname -r)/build" "$@"
|
||||
make -C user/ -j "$j" "$@"
|
||||
@@ -1,12 +1,13 @@
|
||||
.PHONY: all clean
|
||||
.PHONY: all clean mkdir
|
||||
|
||||
CFLAGS_EXTRA = -fopenmp -std=c99
|
||||
CXXFLAGS_EXTRA = -std=c++17
|
||||
CCFLAGS_EXTRA = -Wall -Werror -Wextra
|
||||
IN_EXT_C = .c
|
||||
IN_EXT_CXX = .cpp
|
||||
LIBS =
|
||||
LIBS = -lm
|
||||
OUT_EXT = .out
|
||||
OUT_DIR = .
|
||||
|
||||
OUTS := $(foreach IN_EXT,$(IN_EXT_C) $(IN_EXT_CXX),$(addsuffix $(OUT_EXT), $(basename $(wildcard *$(IN_EXT)))))
|
||||
ifeq ($(BR2_PACKAGE_EIGEN),y)
|
||||
@@ -30,14 +31,18 @@ ifeq ($(BR2_PACKAGE_OPENBLAS),y)
|
||||
else
|
||||
OUTS := $(filter-out openblas$(OUT_EXT),$(OUTS))
|
||||
endif
|
||||
OUTS := $(addprefix $(OUT_DIR)/,$(OUTS))
|
||||
|
||||
all: $(OUTS)
|
||||
all: mkdir $(OUTS)
|
||||
|
||||
%$(OUT_EXT): %$(IN_EXT_C)
|
||||
$(OUT_DIR)/%$(OUT_EXT): %$(IN_EXT_C)
|
||||
$(CC) $(CFLAGS) $(CFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||
|
||||
%$(OUT_EXT): %$(IN_EXT_CXX)
|
||||
$(OUT_DIR)/%$(OUT_EXT): %$(IN_EXT_CXX)
|
||||
$(CXX) $(CXXFLAGS) $(CXXFLAGS_EXTRA) -o '$@' '$<' $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f *'$(OUT_EXT)'
|
||||
|
||||
mkdir:
|
||||
mkdir -p '$(OUT_DIR)'
|
||||
|
||||
Reference in New Issue
Block a user