配置Nuttx在编译之前需要先进行配置,而Nuttx是一个高度可配置的RTOS,Nuttx的配置文件使用kconfig-frontends工具来维护,配置工具将使用Kconfig文件,而Kconfig文件在Nuttx的代码文件夹中随处可见。每一个Kconfig文件包含了配置变量的声明,而每一个配置变量又给Nuttx提供了一种配置选择,Nuttx的最终配置都由这些Kconfig文件决定。
一般进行Nuttx配置的时候,都可以在Nuttx根目录中通过make menuconfig命令来操作,前提是在根目录中需要有.config文件存在,而.config文件是从某个特定的开发板中的某个路径下拷贝过来的。要获取.config文件,又有两种途径:一种是通过手动将.config和Make.defs文件从特定开发板中的某个路径中拷贝至Nuttx的顶层路径;一种是通过tools目录下的configure.sh脚本完成拷贝工作。最终在进行编译的时候,需要依赖这两个文件。手动配置Copy configs//[/]Make.defs to ${TOPDIR}/Make.defs
Copy configs//[/]defconfig to ${TOPDIR}/.config自动配置tools/confiure.sh [OPTIONS] [/]每个特定的开发板文件夹中都有两个文件Make.defs和defconfig文件来描述该开发板的配置。Make.defsMake.defs提供架构和特定工具的构建选项,在编译时它将被其他所有的Makefile包含,它将定义如下内容:Tools: CC, LD, AR, NM, OBJCOPY, OBJDUMP
Tools options: CFLAGS, LDFLAGS当Make.defs运行时,TOPDIR会传递给它,在Make.defs中将包含以下两个文件:$(TOPDIR)/.config: Nuttx的配置
$(TOPDIR)/tools/Config.mk:一些通用的定义。tools/Config.mk文件中包含了一些额外的宏定义,这些宏定义的值在需要的时候可能会在特定架构中的Make.defs中被覆盖,比如:COMPILE, ASSEMBLE, ARCHIVE, CLEAN, MKDEP等。defconfig
defconfig文件中包含一些如CONFIG_VARIABLE=value形式的定义,它拷贝至$(TOPDIR)路径下后,在编译时会被其他Makefile所包含,并且会用它来生成include/nuttx/config.h文件,这个文件在很多C文件中会用到。
编译大概的目录组织如下:build|-nuttx
| |
| - Makefile|-apps
| |
| - Makefile先罗列一下编译时所需要的文件,其中$(TOPDIR)指nuttx目录,编译时是在nuttx目录中进行。Makefile文件,包括各个目录及子目录下的Makefile文件
Make.defs文件,从特定开发板目录中拷贝过来的,见上文中的配置部分
.config文件,从特定开发板目录中拷贝过来的,见上文中的配置部分
tools/Config.mk文件,定义了某些通用的宏定义
tools/目录,该目录下提供了各类工具(脚本/执行文件),具体的功能也可以查看README.txt。
FlatLibs.mk/KernelLibs.mk/ProtectedLibs.mk文件,这三个文件分别对应到内存配置中的Flat模式、Kernel模式(需要MMU支持),保护模式(需要MPU支持),我使用的是Flat模式,所以在实际编译时只需要FlatLibs.mk文件即可。
Directories.mk文件,描述一些add-on目录完成配置后,编译的过程很简单:cd $(TOPDIR)
make
上文中也提到过,$(TOPDIR)中的.config文件主要描述当前的配置,Make.defs文件描述特定的开发板配置。系统第一次build的时候,会有一些额外的配置动作,包括:自动使用$(TOPDIR)/.config来生成include/nuttx/config.h文件
如果$(TOPDIR)/.version文件不存在的话,自动使用version 0.0来生成
自动使用$(TOPDIR)/.version来生成include/nuttx/version.h文件
创建链接,将$(TOPDIR)/include/arch链接到$(TOPDIR)/arch//include目录
创建链接,将$(TOPDIR)/include/arch/board链接到$(TOPDIR)/configs//include目录
创建链接,将$(TOPDIR)/arch//src/board链接到$(TOPDIR)/configs//src目录
创建链接, 将$(TOPDIR)/include/apps链接到$(APPDIR)/include目录
创建make dependencies,描述Makefile中的自动依赖关系,文件为Make.dep讲这么多,还是直接从Makefile开始入手跟踪吧。在$(TOPDIR)目录中,Makefile内容如下:...-include .config #将.config文件包含进来,其中`-`表示如果.config文件不存在,Makefile也不会报错,并继续运行ifeq ($(CONFIG_WINDOWS_NATIVE),y)include Makefile.winelseinclude Makefile.unix #根据编译环境,选择对应的Makefile,真正的入口endif下面将分别介绍上面讲到的文件,核心是围绕Makefile.unix文件。
.config整个.config文件内容格式如下所示,用来定义配置选项,在编译时需要用到。...# Build Setup## CONFIG_EXPERIMENTAL is not set# CONFIG_DEFAULT_SMALL is not setCONFIG_HOST_LINUX=y# CONFIG_HOST_OSX is not set# CONFIG_HOST_WINDOWS is not set# CONFIG_HOST_OTHER is not set## Build Configuration#CONFIG_APPS_DIR="../apps"CONFIG_BUILD_FLAT=y# CONFIG_BUILD_2PASS is not set...
tools/Config.mk在Config.mk文件中,定义了如PREPROCESS, COMPILE, COMPILEXX, ASSEMBLE, ARCHIVE, DELFILE等通用宏,在其他文件中将使用$(call XXX, in-file, out-file)形式来使用,其中XXX表示定义的这些宏。# These are configuration variables that are quoted by configuration tool# but which must be unquoated when used in the build system.# 调整架构相关宏的值,其中patsubst为Makefile匹配与替换函数,strip为去空格函数CONFIG_ARCH := $(patsubst "%",%,$(strip $(CONFIG_ARCH)))
CONFIG_ARCH_CHIP := $(patsubst "%",%,$(strip $(CONFIG_ARCH_CHIP)))
CONFIG_ARCH_BOARD := $(patsubst "%",%,$(strip $(CONFIG_ARCH_BOARD)))# Some defaults just to prohibit some bad behavior if for some reason they# are not definedOBJEXT ?= .o
LIBEXT ?= .a# DELIM - Path segment delimiter character## Depends on this settings defined in board-specific defconfig file installed# at $(TOPDIR)/.config:## CONFIG_WINDOWS_NATIVE - Defined for a Windows native build# 定义DELIM分隔符ifeq ($(CONFIG_WINDOWS_NATIVE),y)
DELIM = $(strip \)else
DELIM = $(strip /)endif# INCDIR - Convert a list of directory paths to a list of compiler include# directirves# Example: CFFLAGS += ${shell $(INCDIR) [options] "compiler" "dir1" "dir2" "dir2" ...}## Note that the compiler string and each directory path string must quoted if# they contain spaces or any other characters that might get mangled by the# shell## Depends on this setting passed as a make commaond line definition from the# toplevel Makefile:## TOPDIR - The path to the top level NuttX directory in the form# appropriate for the current build environment## Depends on this settings defined in board-specific defconfig file installed# at $(TOPDIR)/.config:## CONFIG_WINDOWS_NATIVE - Defined for a Windows native buildifeq ($(CONFIG_WINDOWS_NATIVE),y)
INCDIR = "$(TOPDIR)\tools\incdir.bat"else
INCDIR = "$(TOPDIR)/tools/incdir.sh"endif# PREPROCESS - Default macro to run the C pre-processor# Example: $(call PREPROCESS, in-file, out-file)## Depends on these settings defined in board-specific Make.defs file# installed at $(TOPDIR)/Make.defs:## CPP - The command to invoke the C pre-processor# CPPFLAGS - Options to pass to the C pre-processor# 预处理宏define PREPROCESS
@echo "CPP: $1->$2"
$(Q) $(CPP) $(CPPFLAGS) $1 -o $2endef# COMPILE - Default macro to compile one C file# Example: $(call COMPILE, in-file, out-file)## Depends on these settings defined in board-specific Make.defs file# installed at $(TOPDIR)/Make.defs:## CC - The command to invoke the C compiler# CFLAGS - Options to pass to the C compilerdefine COMPILE
@echo "CC: $1"
$(Q) $(CC) -c $(CFLAGS) $1 -o $2endef# COMPILEXX - Default macro to compile one C++ file# Example: $(call COMPILEXX, in-file, out-file)## Depends on these settings defined in board-specific Make.defs file# installed at $(TOPDIR)/Make.defs:## CXX - The command to invoke the C++ compiler# CXXFLAGS - Options to pass to the C++ compilerdefine COMPILEXX
@echo "CXX: $1"
$(Q) $(CXX) -c $(CXXFLAGS) $1 -o $2endef# ASSEMBLE - Default macro to assemble one assembly language file# Example: $(call ASSEMBLE, in-file, out-file)## NOTE that the most common toolchain, GCC, uses the compiler to assemble# files because this has the advantage of running the C Pre-Processor against# the assembly language files. This is not possible with other toolchains;# platforms using those other tools should define AS and over-ride this# definition in order to use the assembler directly.## Depends on these settings defined in board-specific Make.defs file# installed at $(TOPDIR)/Make.defs:## CC - By default, the C compiler is used to compile assembly language# files# AFLAGS - Options to pass to the C+compilerdefine ASSEMBLE
@echo "AS: $1"
$(Q) $(CC) -c $(AFLAGS) $1 -o $2endef# MOVEOBJ - Default macro to move an object file to the correct location# Example: $(call MOVEOBJ, prefix, directory)## This is only used in directories that keep object files in sub-directories.# Certain compilers (ZDS-II) always place the resulting files in the the# directory where the compiler was invoked with not option to generate objects# in a different location.define MOVEOBJendef# ARCHIVE - Add a list of files to an archive# Example: $(call ARCHIVE, archive-file, "file1 file2 file3 ...")## Note: The fileN strings may not contain spaces or characters that may be# interpreted strangely by the shell## Depends on these settings defined in board-specific Make.defs file# installed at $(TOPDIR)/Make.defs:## AR - The command to invoke the archiver (includes any options)## Depends on this settings defined in board-specific defconfig file installed# at $(TOPDIR)/.config:## CONFIG_WINDOWS_NATIVE - Defined for a Windows native buildifeq ($(CONFIG_WINDOWS_NATIVE),y)define ARCHIVE
@echo AR: $2 $(Q) $(AR) $1 $(2)endefelsedefine ARCHIVE
@echo "AR: $2"
$(Q) $(AR) $1 $(2) || { echo "$(AR) $1 FAILED!" ; exit 1 ; }endefendif# PRELINK - Prelink a list of files# This is useful when files were compiled with fvisibility=hidden.# Any symbol which was not explicitly made global is invisible outside the# prelinked file.## Example: $(call PRELINK, prelink-file, "file1 file2 file3 ...")## Note: The fileN strings may not contain spaces or characters that may be# interpreted strangely by the shell## Depends on these settings defined in board-specific Make.defs file# installed at $(TOPDIR)/Make.defs:## LD - The command to invoke the linker (includes any options)# OBJCOPY - The command to invoke the object cop (includes any options)## Depends on this settings defined in board-specific defconfig file installed# at $(TOPDIR)/.config:## CONFIG_WINDOWS_NATIVE - Defined for a Windows native buildifeq ($(CONFIG_WINDOWS_NATIVE),y)define PRELINK
@echo PRELINK: $1 $(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1endefelsedefine PRELINK
@echo "PRELINK: $1"
$(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1endefendif# DELFILE - Delete one fileifeq ($(CONFIG_WINDOWS_NATIVE),y)define DELFILE $(Q) if exist $1 (del /f /q $1)endefelsedefine DELFILE $(Q) rm -f $1endefendif# DELDIR - Delete one directoryifeq ($(CONFIG_WINDOWS_NATIVE),y)define DELDIR $(Q) if exist $1 (rmdir /q /s $1)endefelsedefine DELDIR $(Q) rm -rf $1endefendif# MOVEFILE - Move one fileifeq ($(CONFIG_WINDOWS_NATIVE),y)define MOVEFILE $(Q) if exist $1 (move /Y $1 $2)endefelsedefine MOVEFILE $(Q) mv -f $1 $2endefendif# CLEAN - Default clean targetifeq ($(CONFIG_WINDOWS_NATIVE),y)define CLEAN $(Q) if exist *$(OBJEXT) (del /f /q *$(OBJEXT)) $(Q) if exist *$(LIBEXT) (del /f /q *$(LIBEXT)) $(Q) if exist *~ (del /f /q *~) $(Q) if exist (del /f /q .*.swp)endefelsedefine CLEAN $(Q) rm -f *$(OBJEXT) *$(LIBEXT) *~ .*.swpendefendif
Make.defsMake.defs中定义了一些板级相关的宏定义。# 包含需要依赖的文件include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/arch/arm/src/arm/Toolchain.defsifeq ($(WINTOOL),y) # Windows-native toolchains
DIRLINK = $(TOPDIR)/tools/copydir.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mkwindeps.sh
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/ld.script}"else
# Linux/Cygwin-native toolchain 在Linux环境下使用的工具链
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx -isystem $(TOPDIR)/include/uClibc++
ARCHSCRIPT = -T$(TOPDIR)/configs//$(CONFIG_ARCH_BOARD)/scripts/ld.scriptendif# 定义工具,其中$(CROSSDEV)在$(TOPDIR)/arch/arm/src/arm/Toolchain.defs文件中定义CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
AR = $(CROSSDEV)ar rcs
NM = $(CROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump# 编译器版本ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
ARCHOPTIMIZATION += -fno-omit-frame-pointer -mapcs -mno-sched-prologendififneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointerendififeq ($(ARCHCCMAJOR),4)
ARCHCPUFLAGS = -mtune=arm9tdmi -march=armv5te -mfloat-abi=soft -fno-builtinelse
ARCHCPUFLAGS = -mapcs-32 -mtune=arm9tdmi -march=armv5te -msoft-float -fno-builtinendifARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fpermissive -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHDEFINES =
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10# 定义所有编译时的FLAG选项CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -std=c++11 -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)AFLAGS = $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048# 定义文件后缀ASMEXT = .S
OBJEXT = .o
LIBEXT = .a
EXEEXT =ifneq ($(CONFIG_ARM_TOOLCHAIN),BUILDROOT)
LDFLAGS += -nostartfiles -nodefaultlibsendififeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -gendif# 定义Host的编译器HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
HOSTLDFLAGS =
Directories.mkDirectories.mk主要定义了NUTTX_ADDONS和USER_ADDONS,其中NUTTX_ADDONS包含了一系列文件夹,最终将编译进Nuttx内核中,而USER_ADDONS包含了一系列文件夹,最终会编译进Apps中。Directories.mk将Nuttx内核中的文件夹都包含了进来。# All add-on directories.## NUTTX_ADDONS is the list of directories built into the NuttX kernel.# USER_ADDONS is the list of directories that will be built into the user# applicationNUTTX_ADDONS :=
USER_ADDONS :=# In the protected build, the applications in the apps/ directory will be# into the userspace; in the flat build, the applications will b built into# the kernel space. But in the kernel build, the applications will not be# built at all by this Makefile.ifeq ($(CONFIG_BUILD_PROTECTED),y)
USER_ADDONS += $(APPDIR)elseifneq ($(CONFIG_BUILD_KERNEL),y)
NUTTX_ADDONS += $(APPDIR)endifendif# Lists of build directories.## FSDIRS depend on file descriptor support; NONFSDIRS do not (except for parts# of FSDIRS). We will exclude FSDIRS from the build if file descriptor# support is disabled. NOTE that drivers, in general, depends on file# descriptor support but is always built because there are other components# in the drivers directory that are needed even if file descriptors are not# supported.# CONTEXTDIRS include directories that have special, one-time pre-build# requirements. Normally this includes things like auto-generation of# configuration specific files or creation of configurable symbolic links# USERDIRS - When NuttX is build is a monolithic kernel, this provides the# list of directories that must be built# OTHERDIRS - These are directories that are not built but probably should# be cleaned to prevent garbage from collecting in them when changing# configurations.NONFSDIRS = sched drivers configs $(ARCH_SRC) $(NUTTX_ADDONS)FSDIRS = fs binfmt
CONTEXTDIRS = configs $(APPDIR)USERDIRS =
OTHERDIRS = libifeq ($(CONFIG_BUILD_PROTECTED),y)
USERDIRS += libc mm $(USER_ADDONS)ifeq ($(CONFIG_HAVE_CXX),y)
USERDIRS += libxxendifelseifeq ($(CONFIG_BUILD_KERNEL),y)
USERDIRS += libc mmifeq ($(CONFIG_HAVE_CXX),y)
USERDIRS += libxxendifelseNONFSDIRS += libc mm
OTHERDIRS += $(USER_ADDONS)ifeq ($(CONFIG_HAVE_CXX),y)
NONFSDIRS += libxxelseOTHERDIRS += libxxendifendifendififeq ($(CONFIG_LIB_SYSCALL),y)
NONFSDIRS += syscall
CONTEXTDIRS += syscall
USERDIRS += syscallelseOTHERDIRS += syscallendififeq ($(CONFIG_LIB_ZONEINFO_ROMFS),y)
CONTEXTDIRS += libcendififeq ($(CONFIG_NX),y)
NONFSDIRS += graphics libnx
CONTEXTDIRS += graphics libnxelseOTHERDIRS += graphics libnxendififeq ($(CONFIG_AUDIO),y)
NONFSDIRS += audioelseOTHERDIRS += audioendififeq ($(CONFIG_DRIVERS_WIRELESS),y)
NONFSDIRS += wirelesselseOTHERDIRS += wirelessendif# CLEANDIRS are the directories that will clean in. These are# all directories that we know about.# KERNDEPDIRS are the directories in which we will build target dependencies.# If NuttX and applications are built separately (CONFIG_BUILD_PROTECTED or# CONFIG_BUILD_KERNEL), then this holds only the directories containing# kernel files.# USERDEPDIRS. If NuttX and applications are built separately (CONFIG_BUILD_PROTECTED),# then this holds only the directories containing user files. If# CONFIG_BUILD_KERNEL is selected, then applications are not build at all.CLEANDIRS = $(NONFSDIRS) $(FSDIRS) $(USERDIRS) $(OTHERDIRS)KERNDEPDIRS = $(NONFSDIRS)USERDEPDIRS = $(USERDIRS)# Add file system directories to KERNDEPDIRS (they are already in CLEANDIRS)ifeq ($(CONFIG_NFILE_DESCRIPTORS),0)ifeq ($(CONFIG_NET),y)ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
KERNDEPDIRS += fsendifKERNDEPDIRS += driversendifelseKERNDEPDIRS += $(FSDIRS)endif# Add networking directories to KERNDEPDIRS and CLEANDIRSifeq ($(CONFIG_NET),y)
KERNDEPDIRS += netendifCLEANDIRS += netifeq ($(CONFIG_CRYPTO),y)
KERNDEPDIRS += cryptoendifCLEANDIRS += crypto
FlatLibs.mk内存配置在Flat模式情况下,会使用FlatLibs.mk文件,该文件主要定义NUTTXLIBS和USERLIBS,其中NUTTXLIBS包含了一系列的库文件,最终用于特定处理器来编译Nuttx Image,USERLIBS包含一系列库文件用于用户层的Apps。此外,还定义了EXPORTLIBS,用于在make export时,生成库文件。# NUTTXLIBS is the list of NuttX libraries that is passed to the# processor-specific Makefile to build the final NuttX target.# Libraries in FSDIRS are excluded if file descriptor support# is disabled.# USERLIBS is the list of libraries used to build the final user-space# application# EXPORTLIBS is the list of libraries that should be exported by# 'make export' isNUTTXLIBS = lib$(DELIM)libsched$(LIBEXT)USERLIBS =# Driver support. Generally depends on file descriptor support but there# are some components in the drivers directory that are needed even if file# descriptors are not supported.NUTTXLIBS += lib$(DELIM)libdrivers$(LIBEXT)# Add libraries for board supportNUTTXLIBS += lib$(DELIM)libconfigs$(LIBEXT)# Add libraries for syscall support.NUTTXLIBS += lib$(DELIM)libc$(LIBEXT) lib$(DELIM)libmm$(LIBEXT)NUTTXLIBS += lib$(DELIM)libarch$(LIBEXT)ifeq ($(CONFIG_LIB_SYSCALL),y)
NUTTXLIBS += lib$(DELIM)libstubs$(LIBEXT)USERLIBS += lib$(DELIM)libproxies$(LIBEXT)endif# Add libraries for C++ support. CXX, CXXFLAGS, and COMPILEXX must# be defined in Make.defs for this to work!ifeq ($(CONFIG_HAVE_CXX),y)
NUTTXLIBS += lib$(DELIM)libcxx$(LIBEXT)endif# Add library for application support.ifneq ($(APPDIR),)
NUTTXLIBS += lib$(DELIM)libapps$(LIBEXT)endif# Add libraries for network supportifeq ($(CONFIG_NET),y)
NUTTXLIBS += lib$(DELIM)libnet$(LIBEXT)endif# Add libraries for Crypto API supportifeq ($(CONFIG_CRYPTO),y)
NUTTXLIBS += lib$(DELIM)libcrypto$(LIBEXT)endif# Add libraries for file system supportifeq ($(CONFIG_NFILE_DESCRIPTORS),0)ifneq ($(CONFIG_NSOCKET_DESCRIPTORS),0)
NUTTXLIBS += lib$(DELIM)libfs$(LIBEXT)endifelseNUTTXLIBS += lib$(DELIM)libfs$(LIBEXT) lib$(DELIM)libbinfmt$(LIBEXT)endif# Add libraries for the NX graphics sub-systemifeq ($(CONFIG_NX),y)
NUTTXLIBS += lib$(DELIM)libgraphics$(LIBEXT)NUTTXLIBS += lib$(DELIM)libnx$(LIBEXT)endif# Add libraries for the Audio sub-systemifeq ($(CONFIG_AUDIO),y)
NUTTXLIBS += lib$(DELIM)libaudio$(LIBEXT)endif# Add libraries for the Wireless sub-systemifeq ($(CONFIG_WIRELESS),y)
NUTTXLIBS += lib$(DELIM)libwireless$(LIBEXT)endif# Add C++ libraryifeq ($(CONFIG_HAVE_CXX),y)
NUTTXLIBS += lib$(DELIM)libcxx$(LIBEXT)endif# Export all librariesEXPORTLIBS = $(NUTTXLIBS)
tools/tools目录下包含了各种各样的脚本和Host C程序,这些都是Nuttx编译系统的必要的部分。README.txt有详尽的介绍。
Makefile.unixMakefile.unix才是我们的核心,上述所介绍的文件,最终都要为它所用,直接看代码吧。
作者:Loyen
链接:https://www.jianshu.com/p/f3432b8aad11