diff --git a/.gitignore b/.gitignore index f51474288..ad268dce5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,11 @@ *.o *.mod + +*.cmd + +Module.symvers +modules.order + +output/ +_install/ diff --git a/01-Char/Makefile b/01-Char/Makefile index 67b1a6f9d..e768b2077 100644 --- a/01-Char/Makefile +++ b/01-Char/Makefile @@ -1,25 +1,51 @@ +# All Right Reserved. +# Author : gaoyang3513@outlook.com +# Version : V1.0.0 202x.01.01 +# Description : +# Note : + +# --------------------------------------------------------------------------- +# Path information +LOCAL_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) + +# Subdirectory + +# Output directories +OUTPUT_DIR ?= $(LOCAL_DIR)/output +INSTALL_DIR ?= $(LOCAL_DIR)/_install + +# --------------------------------------------------------------------------- +# Variables +MULTI_CORES ?= $(shell grep -c ^processor /proc/cpuinfo) + +# --------------------------------------------------------------------------- +# Compile configure + +# --------------------------------------------------------------------------- +# Source and oject files ifneq ($(KERNELRELEASE),) obj-m := char_static.o +# --------------------------------------------------------------------------- +# Targets else # KERNELRELEASE ifneq ($(filter $(BOARD),mikv-Duo),) -KERNELDIR ?= ${HOME}/Source/10-CV1800/01-MilkDuo/02-Project/SDK_CV1800_BR2/linux_5.10/build/cv1800b_milkv_duo_sd -ROOTFS ?= ${HOME}/nfs/rootfs -else ifneq ($(filter $(ARCH),arm64),) -KERNELDIR ?= ${HOME}/Source/04-RK3568/02-Projects/SDK_RK3568_Linux_LBCat2/kernel -ROOTFS ?= ${HOME}/nfs/rootfs +KERNELDIR := ${HOME}/Source/10-CV1800/01-MilkDuo/02-Project/SDK_CV1800_BR2/linux_5.10/build/cv1800b_milkv_duo_sd +ROOTFS := ${HOME}/nfs/rootfs else KERNELDIR ?= /lib/modules/$(shell uname -r)/build endif -PWD := $(shell pwd) +.PHONY: all clean init + +all: + @$(MAKE) -C $(KERNELDIR) M=$(PWD) modules -j$(MULTI_CORES); + +install: + @$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install INSTALL_MOD_PATH=$(INSTALL_DIR) -modules: - @$(MAKE) -C $(KERNELDIR) M=$(PWD) modules -modules_install: - @$(MAKE) -C $(KERNELDIR) M=$(PWD) INSTALL_MOD_PATH=$(ROOTFS) modules_install clean: @rm -rf *.o *.ko .*.cmd *.mod* modules.order Module.symvers .tmp_versions diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..891e7f287 --- /dev/null +++ b/Makefile @@ -0,0 +1,64 @@ +# All Right Reserved. +# Author : gaoyang3513@outlook.com +# Version : V1.0.0 202x.01.01 +# Description : +# Note : + +# --------------------------------------------------------------------------- +# Path information +LOCAL_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) + +# Subdirectory +MODEL_CHAR := $(LOCAL_DIR)/01-Char + +# Output directories +OUTPUT_DIR ?= $(LOCAL_DIR)/output +INSTALL_DIR ?= $(LOCAL_DIR)/_install + +# --------------------------------------------------------------------------- +# Variables +MULTI_CORES ?= $(shell grep -c ^processor /proc/cpuinfo) + +SUB_DIRS := 01-Char/ + +# --------------------------------------------------------------------------- +# Compile configure + +# --------------------------------------------------------------------------- +# Source and oject files +ifneq ($(KERNELRELEASE),) + +obj-y := $(SUB_DIRS) + +# --------------------------------------------------------------------------- +# Targets +else # KERNELRELEASE + +ifneq ($(filter $(BOARD),mikv-Duo),) +KERNELDIR := ${HOME}/Source/10-CV1800/01-MilkDuo/02-Project/SDK_CV1800_BR2/linux_5.10/build/cv1800b_milkv_duo_sd +ROOTFS := ${HOME}/nfs/rootfs +else +KERNELDIR ?= /lib/modules/$(shell uname -r)/build +endif + +.PHONY: all clean init + +all: init + @for sub in $(SUB_DIRS); do \ + $(MAKE) -C $${sub}; \ + $(MAKE) -C $${sub} install INSTALL_DIR=$(OUTPUT_DIR); \ + done; + +clean: + @for sub in $(SUB_DIRS); do \ + $(MAKE) -C $${sub} clean; \ + done; + +install: + @mkdir -p $(INSTALL_DIR); + @cp -arf $(OUTPUT_DIR)/. $(INSTALL_DIR); + +init: + @mkdir -p $(OUTPUT_DIR); + +endif # KERNELRELEASE \ No newline at end of file