Files
Linux_Drivers/Makefile
2025-03-22 11:57:55 +08:00

136 lines
4.4 KiB
Makefile

# ---------------------------------------------------------------------------- #
# All Right Reserved.
# Author :
# Version : V1.0.0 202x.01.01
# Description :
# Note : gaoyang3513@163.com.cn Modified 202x.01.01
# ---------------------------------------------------------------------------- #
# That's our default target when none is given on the command line
PHONY := all
all:
# ---------------------------------------------------------------------------- #
# Path information
# ---------------------------------------------------------------------------- #
LOCAL_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
# SDK directories
SDK_TOP ?= $(HOME)/Source/15-SG200x/01-MilkDuo/02-Project/SDK_SG200x_V2.0.0
KERNEL_DIR ?= $(SDK_TOP)/linux_5.10/build/sg2000_milkv_duos_glibc_arm64_sd
TOOLCHAIN_DIR ?= $(SDK_TOP)/host-tools/gcc/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin
# Subdirectory
OUTPUT_DIR := $(LOCAL_DIR)/output
INSTALL_DIR ?= $(LOCAL_DIR)/__install
export KERNEL_DIR
# ---------------------------------------------------------------------------- #
# Functions
# ---------------------------------------------------------------------------- #
define filechk_version.h
echo \#define LINUX_VERSION_CODE $(shell \
expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \
echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))'
endef
# ---------------------------------------------------------------------------- #
# Variables
# ---------------------------------------------------------------------------- #
VERSION = 1
PATCHLEVEL = 1
SUBLEVEL = 0
EXTRAVERSION =
NAME = Kleptomaniac Octopus
version_h := include/generated/version.h
MAKEFLAGS += --no-print-directory
MULTI_CORES ?= $(shell grep -c ^processor /proc/cpuinfo)
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V)
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
ifeq ($(KBUILD_VERBOSE),1)
quiet =
Q =
else
quiet = quiet_
Q = @
endif
export Q quiet
# ---------------------------------------------------------------------------- #
# Compile configure
# ---------------------------------------------------------------------------- #
#CROSS_COMPILE ?= riscv64-unknown-linux-musl-
ARCH ?= arm64
CROSS_COMPILE ?= aarch64-linux-gnu-
CC := $(CROSS_COMPILE)gcc
LD := $(CROSS_COMPILE)ld
AR := $(CROSS_COMPILE)ar
STRIP := $(CROSS_COMPILE)strip
PATH := $(TOOLCHAIN_DIR):$(PATH)
export ARCH CROSS_COMPILE PATH
# ---------------------------------------------------------------------------- #
# Objects
# ---------------------------------------------------------------------------- #
SUB_DIRS := 03-Bus/01-Platform/01-osdev
#$(warning "SUB_DIRS: $(SUB_DIRS)")
# ---------------------------------------------------------------------------- #
# Targets
# ---------------------------------------------------------------------------- #
.PHONY += init all clean distclean install menuconfig oldconfig $(version_h)
include scripts/Kbuild.include
all: init
$(Q)for sub in $(SUB_DIRS); do \
$(MAKE) -C $$sub; \
$(MAKE) install INSTALL_DIR=$(OUTPUT_DIR) -C $$sub || exit "$$?"; \
done;
clean:
$(Q)for sub in $(SUB_DIRS); do \
$(MAKE) clean -C $$sub || exit "$$?"; \
done;
# Directory
$(Q)if [ -d $(LOCAL_DIR)/include/config ]; then rm -rf $(LOCAL_DIR)/include/config; fi;
$(Q)if [ -d $(LOCAL_DIR)/include/generated ]; then rm -rf $(LOCAL_DIR)/include/generated; fi;
$(Q)if [ -d $(LOCAL_DIR)/output ]; then rm -rf $(LOCAL_DIR)/output; fi;
$(Q)if [ -d $(LOCAL_DIR)/__install ]; then rm -rf $(LOCAL_DIR)/__install; fi;
install:
$(Q)mkdir -p $(INSTALL_DIR)
$(Q)cp -arf $(OUTPUT_DIR)/. $(INSTALL_DIR)
init: $(version_h)
$(Q)mkdir -p $(OUTPUT_DIR);
$(Q)mkdir -p include/config include/generated
$(Q)$(LOCAL_DIR)/scripts/kconfig/Kconfiglib/genconfig.py --sync-dep include/config --header-path include/generated/autoconf.h
oldconfig:
$(Q)$(LOCAL_DIR)/scripts/kconfig/Kconfiglib/oldconfig.py
%_defconfig:
$(Q)$(LOCAL_DIR)/scripts/kconfig/Kconfiglib/defconfig.py --kconfig Kconfig configs/$@
menuconfig:
$(Q)mkdir -p include/config include/generated
$(Q)$(LOCAL_DIR)/scripts/kconfig/Kconfiglib/menuconfig.py Kconfig
savedefconfig:
$(Q)$(LOCAL_DIR)/scripts/kconfig/Kconfiglib/savedefconfig.py --kconfig Kconfig --out defconfig
$(version_h):
$(Q)$(call filechk,version.h)