207 lines
No EOL
6 KiB
Makefile
207 lines
No EOL
6 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.
|
|
#
|
|
############################################################################
|
|
|
|
|
|
############################################################################
|
|
# NXBASE - Mandatory variable. Gets exported to all sub-makes.
|
|
#
|
|
# The NXBASE variable should always point to the top-level NuttX directory.
|
|
# Ideally, it should be exported as an envvar rather than being set as
|
|
# argument to make.
|
|
#
|
|
# Example:
|
|
# ~/.bashrc: export NXBASE=/path/to/nuttx
|
|
# ~/.zshrc: export NXBASE=/path/to/nuttx
|
|
############################################################################
|
|
|
|
ifeq ($(realpath ${NXBASE}),)
|
|
$(error Build stopped, NXBASE required)
|
|
else
|
|
export NXBASE
|
|
endif
|
|
|
|
############################################################################
|
|
# NXOUT - Mandatory variable. Gets exported to all sub-makes.
|
|
#
|
|
# The NXOUT variable defines the output directory for the build.
|
|
# It is infered to the default ${NXBASE}/build directory. This path
|
|
# is reserved by the NuttX build system.
|
|
############################################################################
|
|
|
|
NXOUT ?= $(realpath ${NXBASE}/build)
|
|
export NXOUT
|
|
|
|
############################################################################
|
|
# ARCH - Mandatory variable. Gets exported. Mainly used in Kconfig.
|
|
#
|
|
# Rather than depending on the Kconfig system to set the architecture,
|
|
# which still needs initial manual setup, the architecture can be set
|
|
# ahead of time. This still require setting the arch manually, but avoids
|
|
# relying on Kconfig to do so. This greatly simplifies Kconfig "tree".
|
|
#
|
|
# The architecture must be resolved early on in the build system. the
|
|
# supported architectures are stored in the ARCHS variable.
|
|
############################################################################
|
|
|
|
ARCHS := arm risc-v sim
|
|
|
|
ifeq (${ARCH},)
|
|
$(error Build stopped, ARCH not set)
|
|
endif
|
|
|
|
ifeq ($(findstring ${ARCH}, ${ARCHS}),)
|
|
$(info Currently supported ARCHS: ${ARCHS})
|
|
$(error Build stopped, ARCH not supported)
|
|
endif
|
|
|
|
export ARCH
|
|
|
|
TOOLCHAIN ?= gcc
|
|
TOOLCHAIN := ${NXBASE}/tools/${ARCH}/toolchain/${TOOLCHAIN}.defs
|
|
ifeq ($(realpath ${TOOLCHAIN}),)
|
|
$(error Build stopped, TOOLCHAIN not found)
|
|
else
|
|
export TOOLCHAIN
|
|
endif
|
|
|
|
# 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
|
|
|
|
# BDIR variable sets the board directory.
|
|
# It can be implied if the build starts from 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
|
|
|
|
# Kconfiglib the only option
|
|
|
|
.PHONY: menuconfig savedefconfig oldconfig olddefconfig defconfig genconfig
|
|
|
|
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
|
|
|
|
.PHONY: ${KCONFIG_CONFIG}
|
|
${KCONFIG_CONFIG}:
|
|
$(Q) [ -f ${KCONFIG_CONFIG} ] || \
|
|
${KCONFIG_ENV} ${KCONFIG_DEFCONFIG} ${BDIR}/configs/${BCFG}/defconfig
|
|
|
|
.PHONY: ${KCONFIG_AUTOHEADER}
|
|
${KCONFIG_AUTOHEADER}:
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_GENCONFIG}
|
|
|
|
menuconfig: ${KCONFIG_CONFIG}
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_MENUCONFIG}
|
|
|
|
savedefconfig:
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_SAVEDEFCONFIG}
|
|
|
|
oldconfig:
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_OLDCONFIG}
|
|
|
|
olddefconfig:
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_OLDDEFCONFIG}
|
|
|
|
defconfig:
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_DEFCONFIG}
|
|
|
|
genconfig: ${KCONFIG_CONFIG}
|
|
$(Q) ${KCONFIG_ENV} ${KCONFIG_GENCONFIG}
|
|
|
|
############################################################################
|
|
# Here starts the rules definition for building NuttX libraries
|
|
############################################################################
|
|
include ${KCONFIG_CONFIG}
|
|
|
|
MAKE_INC := -f ${KCONFIG_CONFIG}
|
|
MAKE_INC += -f ${NXBASE}/tools/Config.mk
|
|
|
|
.PHONY: libarch
|
|
TARGETS := libarch
|
|
libarch: ${KCONFIG_CONFIG} ${KCONFIG_AUTOHEADER}
|
|
$(Q) ${MAKE} ${MAKE_INC} -f Makefile -C arch/${ARCH} all
|
|
|
|
|
|
|
|
ifeq (${CONFIG_AUDIO},y)
|
|
.PHONY: libaudio
|
|
TARGETS += libaudio
|
|
libaudio: ${KCONFIG_CONFIG} ${KCONFIG_AUTOHEADER}
|
|
$(Q) ${MAKE} ${MAKE_INC} -f Makefile -C audio all
|
|
endif
|
|
|
|
ifeq (${CONFIG_CRYPTO},y)
|
|
.PHONY: libcrypto
|
|
TARGETS += libcrypto
|
|
libcrypto: ${KCONFIG_CONFIG} ${KCONFIG_AUTOHEADER}
|
|
$(Q) ${MAKE} ${MAKE_INC} -f Makefile -C crypto all
|
|
endif
|
|
|
|
.PHONY: libbinfmt
|
|
TARGETS += libbinfmt
|
|
libbinfmt: ${KCONFIG_CONFIG} ${KCONFIG_AUTOHEADER}
|
|
$(Q) ${MAKE} ${MAKE_INC} -f Makefile -C binfmt all
|
|
|
|
# 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 |