NuttX_编译系统分析
来源:互联网 发布:网络兼职有哪些 编辑:程序博客网 时间:2024/06/05 22:48
Nuttx 内存寻址模式有3种
1. 目录结构
| +~~~~~~~~~~~~~+ | | nuttx app $(TOPDIR) = nuttx $(TOPDIR)/ +---.config +---.version +---Makefile +---Makefile.unix +---Makefile.win(略) +---Directories.mk +---LibTargets.mk +---FlatLibs.mk +---KernelLibs.mk (略) +---ProtectedLibs.mk(略) +---/arch/arm/src/armv7-m/Toolchain.defs +---/tools +---configure.sh +---Config.mk +---/tools +---/tools +---/tools +---/tools
2. Makefile 文件包含关系
+--.config | | +-tools/Config.mk | | | | +--.config | | | | +-Make.defs--+--tools/Config.mk | | | | | +--arch/arm/src/armv7-m/Toolchain.defs | |Makefile-+--Makefile.unix--+--Directories.mk | | | | +--FlatLibs.mk (Flat embedded build) | | | | +------------+--ProtectedLibs.mk(Protected build with MPU))(略) | | | | | +--KernelLibs.mk (Kernel build with MMU)(略) | | | +--LibTargets.mk +--Makefile.win-(略)
3. Makefile 目标
默认的目标为:all: $(BIN)
伪目标有:
- context
- clean_context
- check_context
- export
- subdir_clean
- subdir_distclean
- clean
- distclean
- apps_clean
- apps_distclean
引用某大神的一个图:
http://blog.csdn.net/zhumaill/article/details/24400441
` |<--pass1dep-|<----------------------------------------+ |<--pass1deps-| |<--tools/mkdeps$(HOSTEXEEXT) | | | | | | +--+ |<--$(USERLIBS) | | | | | | |<--pass2dep-|<---------------------------------------| |<---pass2deps-| |<--tools/mkdeps$(HOSTEXEEXT) | | | | | | | | | |<--$(NUTTXLIBS) <--+ | | | | | | | | | +-----------------------------------+ | | | | | | | | | |<--lib/libsched$(LIBEXT)<--sched/libsched$(LIBEXT)<--------| | | | |<--lib/libc$(LIBEXT)<--libc/libc$(LIBEXT)<-----------------| | | | |<--lib/libmm$(LIBEXT)<--mm/libmm$(LIBEXT)<-----------------|all<--$(BIN)-| | | |<--lib/libarch$(LIBEXT)<--$(ARCH_SRC)/libarch$(LIBEXT)<----| | | | |<--lib/libcxx$(LIBEXT)<--libxx/libcxx$(LIBEXT)<------------| | | | |<--lib/libapps$(LIBEXT)<--$(APPDIR)/libapps$(LIBEXT)<------| | | | |<--lib/libnet$(LIBEXT)<--net/libnet$(LIBEXT)<--------------| | | | |<--lib/libfs$(LIBEXT)<--fs/libfs$(LIBEXT)<-----------------| | | | |<--lib/libdrivers$(LIBEXT)<--drivers/libdrivers$(LIBEXT)<--| | | | |<--lib/libbinfmt$(LIBEXT)<--binfmt/libbinfmt$(LIBEXT)<-----| | | | | | | +---------+ | | | | | | +--------+ | | | | | | |<--pass1<--+ | | | | | |<--pass2<------+ | | +---------------------------------------------------------------------------+ | | |<--check_context | | | |<--include/nuttx/config.h-|<--$(TOPDIR)/.config | | |<--tools/mkconfig$(HOSTEXEEXT) | | | |<--include/nuttx/version.h-|<--$(TOPDIR)/.version | | |<--tools/mkversion$(HOSTEXEEXT) | | |<--context-|<--include/math.h<--include/nuttx/math.h |<--include/float.h<--include/nuttx/float.h |<--include/stdarg.h<--include/nuttx/stdarg.h | | |<--include/arch<-Make.defs | | | |<--include/arch/board-|<--include/arch<--Make.defs | | |<--Make.defs | | |<--dirlinks-|<--include/arch/chip-|<--include/arch<--Make.defs | |<--Make.defs | |<--$(ARCH_SRC)/board<--Make.defs |<--$(ARCH_SRC)/chip<--Make.defs |<--include/apps<--Make.defs
4. Directories.mk
- NUTTX_ADDONS - USER_ADDONS - NONFSDIRS - FSDIRS - CONTEXTDIRS - USERDIRS - OTHERDIRS - CLEANDIRS - KERNDEPDIRS - USERDEPDIRS
5. FlatLibs.mk ProtectedLibs.mk(略) KernelLibs.mk(略)
导出make3个目标(都依赖context) - NUTTXLIBS - - USERLIBS - - EXPORTLIBS-
- NUTTXLIBS +--/lib/libsched.a ---------> 调度器相关 | +--/lib/libconfigs.a | +--/lib/libc.a | +--/lib/libmm.a | +--/lib/libarch.a | +--/lib/libapps.a | +--/lib/libcxx.a ----------> c++相关(略) | +--/lib/libnet.a ----------> network相关(略) | +--/lib/libcrypto.a -------> 加密相关(略) | +--/lib/libfs.a | +--/lib/libdrivers.a | +--/lib/libbinfmt.a | +--/lib/libgraphics.a ---+ | |-> 图像相关(略) +--/lib/libnx.a ---+ | +--/lib/libaudio.a --------> 音频相关(略) | +--/lib/libstubs.a (CONFIG_LIB_SYSCALL = y) - USERLIBS +--/lib/libproxies.a (CONFIG_LIB_SYSCALL = y) - EXPORTLIBS +-- $(NUTTXLIBS)
6. LibTargets.mk
- make -c 到对应目录中编译相应的lib
install 相应的lib 到/lib目录下
ps:在Makefile里会用到install,其他地方会用cp1) 如果目标文件存在, cp会先清空文件后往里写入新文件, 而install则会先删除掉原先的文件然后写入新文件2) install命令会恰当地处理文件权限的问题。 比如说,install -c会把目标文件的权限设置为rwxr-xr-x
7. tools目录
- configure.sh (configure.c, cfgparser.c, and cfgparser.h)
- Config.mk
- discover.py
- mkconfig.c, cfgdefine.c, and cfgdefine.h
- cmdconfig.c
- kconfig2html.c
- mkconfigvars.sh
- mkexport.sh and Makefile.export
- mkfsdata.pl
- mkversion.c, cfgdefine.c, and cfgdefine.h
- mksyscall.c, cvsparser.c, and cvsparser.h
- mksymtab.c, cvsparser.c, and cvsparser.h
- mkctags.sh
- nxstyle.c
- pic32mx
- bdf-convert.c
- Makefile.host
- mkromfsimg.sh
- mkdeps.c cnvwindeps.c mkwindeps.sh mknulldeps.sh
- define.sh / define.bat
- link.sh / link.bat
- unlink.sh / unlink.bat
- incdir.sh / incdir.bat
- copydir.sh / copydir.bat
- mkimage.sh
- indent.sh
- refresh.sh
- testbuild.sh
- zipme.sh
7.1 configure.sh
使用方式:cd ${TOPDIR}/tools./configure.sh <board-name>/<config-dir>这是一个配置脚本, 做了以下几个事情:- Copy configs/<board-name>/<config-dir>/Make.def to ${TOPDIR}/Make.defs- Copy configs/<board-name>/<config-dir>/setenv.sh to ${TOPDIR}/setenv.sh- Copy configs/<board-name>/<config-dir>/defconfig to ${TOPDIR}/.config
7.2 Config.mk
通用makefile 函数接口定义,需要顶层Make.defs 包含该Confilg.mk和顶层的.config文件
-include $(TOPDIR)/.configinclude $(TOPDIR)/tools/Config.mk
7.2.1. CONFIG_ARCH, CONFIG_ARCH_CHIP, CONFIG_ARCH_BOARD - 宏的重新定义
CONFIG_ARCH := $(patsubst "%",%,$(strip $(CONFIG_ARCH)))CONFIG_ARCH_CHIP := $(patsubst "%",%,$(strip $(CONFIG_ARCH_CHIP)))CONFIG_ARCH_BOARD := $(patsubst "%",%,$(strip $(CONFIG_ARCH_BOARD)))
7.2.2. OBJEXT LIBEXT - obj和lib扩展名的定义
OBJEXT ?= .oLIBEXT ?= .a
7.2.4. DELIM - 分割符
ifeq ($(CONFIG_WINDOWS_NATIVE),y) DELIM = $(strip \)else DELIM = $(strip /)endif
7.2.4. INCDIR
使用方式:- CFFLAGS += ${shell $(INCDIR) [options] "compiler" "dir1" "dir2" "dir2" ...}ifeq ($(CONFIG_WINDOWS_NATIVE),y) INCDIR = "$(TOPDIR)\tools\incdir.bat"else INCDIR = "$(TOPDIR)/tools/incdir.sh"endif
7.2.5. PREPROCESS - 预处理
使用方式:- $(call PREPROCESS, in-file, out-file)#CPP - The command to invoke the C pre-processor#CPPFLAGS - Options to pass to the C pre-processordefine PREPROCESS @echo "CPP: $1->$2" $(Q) $(CPP) $(CPPFLAGS) $1 -o $2endef
7.2.6. COMPILE/COMPILEXX - 编译
使用方式:- $(call COMPILE, in-file, out-file)- $(call COMPILEXX, in-file, out-file)#CC - The command to invoke the C compiler#CFLAGS - Options to pass to the C compiler#CXX - The command to invoke the C++ compiler#CXXFLAGS - Options to pass to the C++ compilerdefine COMPILE @echo "CC: $1" $(Q) $(CC) -c $(CFLAGS) $1 -o $2endefdefine COMPILEXX @echo "CXX: $1" $(Q) $(CXX) -c $(CXXFLAGS) $1 -o $2endef
7.2.7. ASSEMBLE - 汇编
使用方式:- $(call ASSEMBLE, in-file, out-file)#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
7.2.8. ARCHIVE - 打包生成lib
使用方式:- $(call ARCHIVE, archive-file, "file1 file2 file3 ...")#AR - The command to invoke the archiver (includes any options)ifeq ($(CONFIG_WINDOWS_NATIVE),y) define ARCHIVE @echo AR: $2 $(Q) $(AR) $1 $(2) endefelse define ARCHIVE @echo "AR: $2" $(Q) $(AR) $1 $(2) || { echo "$(AR) $1 FAILED!" ; exit 1 ; } endefendif
7.2.9. PRELINK - 链接
使用方式:- $(call PRELINK, prelink-file, "file1 file2 file3 ...")#LD - The command to invoke the linker (includes any options)#OBJCOPY - The command to invoke the object cop (includes any options)ifeq ($(CONFIG_WINDOWS_NATIVE),y) define PRELINK @echo PRELINK: $1 $(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1 endefelse define PRELINK @echo "PRELINK: $1" $(Q) $(LD) -Ur -o $1 $2 && $(OBJCOPY) --localize-hidden $1 endefendif
7.2.10. MOVEOBJ - 空
使用方式- 无define MOVEOBJendef
7.2.11. DELFILE - 删除一个文件
使用方式:- $(call DELFILE file")ifeq ($(CONFIG_WINDOWS_NATIVE),y) define DELFILE $(Q) if exist $1 (del /f /q $1) endefelse define DELFILE $(Q) rm -f $1 endefendif
7.2.12. DELDIR - 删除一个目录
使用方式:- $(call DELDIR dir")ifeq ($(CONFIG_WINDOWS_NATIVE),y) define DELDIR $(Q) if exist $1 (rmdir /q /s $1) endefelse define DELDIR $(Q) rm -rf $1 endefendif
7.2.13. MOVEFILE - 移动一个文件
使用方式:- $(call MOVEFILE target src")ifeq ($(CONFIG_WINDOWS_NATIVE),y) define MOVEFILE $(Q) if exist $1 (move /Y $1 $2) endefelse define MOVEFILE $(Q) mv -f $1 $2 endefendif
7.2.14. CLEAN - 清除默认目标 .o .a .swp .*
使用方式:- $(call CLEAN")ifeq ($(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) endefelse define CLEAN $(Q) rm -f *$(OBJEXT) *$(LIBEXT) *~ .* .swp endefendif
0 0
- NuttX_编译系统分析
- Android 编译系统分析
- Android编译系统分析
- Android编译系统分析
- Android 编译系统分析
- Android编译系统分析
- Android 编译系统分析
- Android 编译系统分析
- Android 编译系统分析
- Android 编译系统分析
- android编译系统分析
- Android编译系统分析
- Android 编译系统分析(一)
- Android 编译系统分析(二)
- Android 编译系统分析(三)
- Android编译系统分析
- Android编译系统分析
- Android编译系统分析
- python 字符串转浮点数
- VirtualBox在Linux下安装增强功能时出错
- html页面优化
- 在ubuntu中配置SSH(解决connect to host localhost port 22: Connection refused问题)
- 文章标题
- NuttX_编译系统分析
- android学习笔记——回调机制
- 结合Scikit-learn介绍几种常用的特征选择方法
- 错误票据
- Java 中有三大支柱
- 关于浏览器兼容问题
- android学习笔记——Intent的解析(Intent的隐式调用)
- 工具效率 使用Windows计划任务更新SVN
- JS实现-DIV自动居中代码