Files
Linux_Drivers/Makefile
2024-01-27 15:27:10 +00:00

67 lines
1.7 KiB
Makefile

# 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/ \
02-I2C/
# ---------------------------------------------------------------------------
# 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;
@if [ -d $(LOCAL_DIR)/output ]; then rm -rf $(LOCAL_DIR)/output; fi;
@if [ -d $(LOCAL_DIR)/_install ]; then rm -rf $(LOCAL_DIR)/_install; fi;
install:
@mkdir -p $(INSTALL_DIR);
@cp -arf $(OUTPUT_DIR)/. $(INSTALL_DIR);
init:
@mkdir -p $(OUTPUT_DIR);
endif # KERNELRELEASE