[Mod] 更新模板

This commit is contained in:
gaoyang3513
2024-07-19 14:59:19 +08:00
parent 618b26c8c4
commit 3241f7e9a7

View File

@ -1,59 +1,65 @@
#******************************************************************************* #------------------------------------------------------------------------------#
# HangZhou Hikvision Digital Technology Co., Ltd. All Right Reserved. # All Right Reserved.
# Author : # Author :
# Version : V1.0.0 202x.01.01 # Version : V1.0.0 202x.01.01
# Description : # Description :
# Note : gaoyang3513@163.com Modified 2020.10.21 # Note : gaoyang3513@163.com Modified 202x.01.01
#******************************************************************************* #------------------------------------------------------------------------------#
#******************************************************************************* #------------------------------------------------------------------------------#
# Path information # Path information
#******************************************************************************* #------------------------------------------------------------------------------#
LOCAL_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) # Top directories
KERNEL_DIR ?= $(realpath $(LOCAL_DIR)/../../../../linux_5.10) LOCAL_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
KERNEL_DIR ?= $(realpath $(LOCAL_DIR)/../../../../linux_5.10/build/kernel_output)
# Subdirectory # Subdirectories
# Output directories
OUTPUT_DIR := $(LOCAL_DIR)/output OUTPUT_DIR := $(LOCAL_DIR)/output
INSTALL_DIR ?= $(LOCAL_DIR)/__install INSTALL_DIR ?= $(LOCAL_DIR)/__install
#$(info Output directoty : $(OUTPUT_DIR)) #$(info Output directoty : $(OUTPUT_DIR))
#$(info Install directoty: $(INSTALL_DIR)) #$(info Install directoty: $(INSTALL_DIR))
#******************************************************************************* #------------------------------------------------------------------------------#
# Variables # Variables
#******************************************************************************* #------------------------------------------------------------------------------#
MULTI_CORES ?= $(shell grep -c ^processor /proc/cpuinfo) MULTI_CORES ?= $(shell grep -c ^processor /proc/cpuinfo)
#------------------------------------------------------------------------------#
# Compile configure # Compile configure
#******************************************************************************* #------------------------------------------------------------------------------#
ARCH ?= riscv export ARCH ?= riscv
CROSS_COMPILE ?= riscv64-unknown-linux-musl- export CROSS_COMPILE ?= riscv64-unknown-linux-musl-
CC := $(CROSS_COMPILE)gcc CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld LD := $(CROSS_COMPILE)ld
AR := $(CROSS_COMPILE)ar AR := $(CROSS_COMPILE)ar
STRIP := $(CROSS_COMPILE)strip STRIP := $(CROSS_COMPILE)strip
export ARCH CROSS_COMPILE #------------------------------------------------------------------------------#
#*******************************************************************************
# Targets # Targets
#******************************************************************************* #------------------------------------------------------------------------------#
ifneq ($(KERNELRELEASE),)
# called from kernel build system: just declare what our modules are
obj-m += pn5180.o
else
.PHONY: init all clean distclean install menuconfig .PHONY: init all clean distclean install menuconfig
ifeq ($(KERNELRELEASE),)
all: init all: init
@$(MAKE) modules -C $(KERNEL_DIR) M=$(LOCAL_DIR) -j$(MULTI_CORES) @$(MAKE) modules -C $(KERNEL_DIR) M=$(LOCAL_DIR) -j$(MULTI_CORES)
@$(MAKE) modules_install -C $(KERNEL_DIR) M=$(LOCAL_DIR) INSTALL_MOD_PATH=$(KERNEL_DIR)/_install_modules INSTALL_MOD_DIR=private @$(MAKE) modules_install -C $(KERNEL_DIR) M=$(LOCAL_DIR) INSTALL_MOD_PATH=$(KERNEL_DIR)/_install_modules INSTALL_MOD_DIR=private
clean: clean:
# File
@for n in *.o *.ko *.mod.c *.mod *.cmd *.symvers *.order; do \
find $(LOCAL_DIR) -type f -name $$n -exec rm {} \;;\
done
# Directory # Directory
@if [ -d $(LOCAL_DIR)/output ]; then rm -rf $(LOCAL_DIR)/output; fi; @if [ -d $(LOCAL_DIR)/output ]; then rm -rf $(LOCAL_DIR)/output; fi;
@if [ -d $(LOCAL_DIR)/__install ]; then rm -rf $(LOCAL_DIR)/__install; fi; @if [ -d $(LOCAL_DIR)/__install ]; then rm -rf $(LOCAL_DIR)/__install; fi;
@if [ -d $(LOCAL_DIR)/.tmp_versions ]; then rm -rf $(LOCAL_DIR)/.tmp_versions; fi; @if [ -d $(LOCAL_DIR)/.tmp_versions ]; then rm -rf $(LOCAL_DIR)/.tmp_versions; fi;
# File
@for f in {Module.symvers,modules.order}; do \
if [ -e $$f ]; then rm -rf $$f; fi; \
done
install: install:
@mkdir -p $(INSTALL_DIR) @mkdir -p $(INSTALL_DIR)
@ -61,9 +67,4 @@ install:
init: init:
@mkdir -p $(OUTPUT_DIR); @mkdir -p $(OUTPUT_DIR);
else
# called from kernel build system: just declare what our modules are
obj-m += pn5180.o
endif # ifeq ($(KERNELRELEASE),) endif # ifeq ($(KERNELRELEASE),)