147 lines
3.9 KiB
Makefile
147 lines
3.9 KiB
Makefile
############################################################################
|
|
# Makefile
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
# this work for additional information regarding copyright ownership. The
|
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
# "License"); you may not use this file except in compliance with the
|
|
# License. You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
############################################################################
|
|
|
|
ifeq ($(realpath ${NXBASE}),)
|
|
$(error Build stopped, NXBASE required)
|
|
endif
|
|
|
|
# New OUT variable will be used as the output directory.
|
|
# All the defined target should refer to this variable for their output.
|
|
# Preferably, this out variable should be externally provided, for
|
|
# portability reasons. Rather than keep the output local to the NuttX
|
|
# source tree, this mechanism allows to specify any out-of-tree dir.
|
|
|
|
# ${NXBASE}/build is the default output directory, and it's reserved by the
|
|
# NuttX build system.
|
|
|
|
NXOUT ?= $(realpath ${NXBASE}/build)
|
|
export NXOUT
|
|
|
|
ARCHS := arm risc-v sim
|
|
|
|
ifeq (${ARCH},)
|
|
$(error Architecture should be provided externally)
|
|
endif
|
|
|
|
ifeq ($(findstring ${ARCH}, ${ARCHS}),)
|
|
$(info Currently supported ARCHS: ${ARCHS})
|
|
$(error Unsuported architecture)
|
|
endif
|
|
|
|
TOOLCHAIN ?= gcc
|
|
export TOOLCHAIN
|
|
|
|
# Force the BCFG to always be passed to build process.
|
|
# This new Environment variable defines the board:config to be used.
|
|
|
|
ifndef BCFG
|
|
$(info ERROR: Board configuration not set)
|
|
$(error Build stopped, BCFG required.)
|
|
endif
|
|
|
|
# New BDIR variable defines the board directory.
|
|
|
|
BDIR ?= ${CURDIR}
|
|
|
|
ifeq ($(realpath ${BDIR}/configs/${BCFG}),)
|
|
$(error Build stopped, BDIR:BCFG config invalid)
|
|
endif
|
|
|
|
# Control build verbosity
|
|
#
|
|
# V=0: Exit silent mode
|
|
# V=1,2: Enable echo of commands
|
|
# V=2: Enable bug/verbose options in tools and scripts
|
|
|
|
ifeq ($(V),)
|
|
MAKE := $(MAKE) -s --no-print-directory
|
|
endif
|
|
|
|
ifeq ($(V),1)
|
|
export Q :=
|
|
else ifeq ($(V),2)
|
|
export Q :=
|
|
else
|
|
export Q := @
|
|
endif
|
|
|
|
# Support for ROMFS image creation
|
|
|
|
ifeq (${CONFIG_FS_ROMFS},y)
|
|
ifdef ROMFSIMG
|
|
TARGETS += ${ROMFSIMG}
|
|
else
|
|
$(error ROMFSIMG is not defined by the board Makefile)
|
|
endif
|
|
endif
|
|
|
|
# Kconfiglib the only option
|
|
|
|
KCONFIG_CONFIG = ${NXOUT}/.config
|
|
KCONFIG_AUTOHEADER = ${NXOUT}/config.h
|
|
|
|
KCONFIG_ENV = KCONFIG_CONFIG=${KCONFIG_CONFIG}
|
|
KCONFIG_ENV += KCONFIG_AUTOHEADER=${KCONFIG_AUTOHEADER}
|
|
KCONFIG_ENV += ARCH=${ARCH}
|
|
|
|
KCONFIG_OLDCONFIG = oldconfig
|
|
KCONFIG_OLDDEFCONFIG = olddefconfig
|
|
KCONFIG_MENUCONFIG = menuconfig
|
|
KCONFIG_SAVEDEFCONFIG = savedefconfig
|
|
KCONFIG_GENCONFIG = genconfig
|
|
KCONFIG_DEFCONFIG = defconfig
|
|
|
|
${KCONFIG_CONFIG}:
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_DEFCONFIG} ${BDIR}/configs/${BCFG}/defconfig
|
|
|
|
${KCONFIG_AUTOHEADER}:
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_GENCONFIG}
|
|
|
|
.PHONY: menuconfig defconfig
|
|
|
|
menuconfig: ${KCONFIG_CONFIG}
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_MENUCONFIG}
|
|
|
|
savedefconfig: ${KCONFIG_CONFIG}
|
|
$(Q) ${KCONFGI_ENV} ${KCONFIG_SAVEDEFCONFIG}
|
|
|
|
oldconfig: ${KCONFIG_CONFIG}
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_OLDCONFIG}
|
|
|
|
olddefconfig: ${KCONFIG_CONFIG}
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_OLDDEFCONFIG}
|
|
|
|
defconfig:
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_DEFCONFIG}
|
|
|
|
genconfig: ${KCONFIG_CONFIG}
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_GENCONFIG}
|
|
|
|
CONFIGMK := ${NXBASE}/tools/Config.mk
|
|
|
|
MAKE_INC = -f ${KCONFIG_CONFIG}
|
|
MAKE_INC += -f ${CONFIGMK}
|
|
|
|
TARGETS = libarch
|
|
.PHONY: libarch
|
|
libarch: ${KCONFIG_CONFIG} ${KCONFIG_AUTOHEADER}
|
|
$(Q) ${MAKE} ${MAKE_INC} -f Makefile -C arch/${ARCH}/ all
|