
concerto makefile 系统
Contents
concerto makefile system
用了TI 的系统这么久,发现在VISION_SDK 等都采用concerto makefile system . 百度看下了,基本没有查到任何信息。google了下,找到了项目的地址如参考。想想还是需要把这一部分弄清楚的。
concerto 是基于GNU make的编译系统。用于在PSDKRA 里面多个组件管理。它是make规则和make宏的集合,能够简化编译,并能够跨多个代码生成工具,CPU架构,操作系统,Soc 进行链接。TI 的TDA4 属于多核异构的架构,因此对一份代码非常方便地进行编译和链接到不同核。
Concerto 的目录和文件
当你在工程的顶层目录发现一个concerto目录的时候,你同时可以发现一个名字为Makefile和target.mak
${SW_COMPONENT}/concerto/
${SW_COMPONENT}/Makefile
${SW_COMPONENT}/target.mak
- concerto与软件项目无关,存在于不同的软件项目中。
-
关于concerto的更多项目可以阅读
concerto/README
-
concerto
文件夹内包含了通用的make规则和make宏,这些规则用于构建库文件和可执行文件。 -
concerto/compilers
包含了特定的编译器规则,例如:c6x, c7x, r5f, x86特定于编译器的规则。 -
target.mak
具有特定于项目制作规则,最常用的规则在文件列出。 -
SYSIDIRS
包含路径在项目中是所有文件需要的。 -
SYSLDIRS
库路径:在项目中搜索所有库。 -
SYSDEFS
or-D
全局定义,在这个项目中应用所有文件。 -
Makefile
项目编译顶层的入口。 -
make
andmake all
在这个项目中build 所有的软件。 -
make clean
在这个项目中clean 所有的软件。 -
concerto
的输出都在${SW_COMPONENT}/out/
这些文件是按层次排列的,首先是PLATFORM,然后是CPU,然后是OS,然后是PROFILE,然后是模块
example
out/J7/A72/LINUX/release/module
模块包含多个文件夹,该项目中的每个库或可执行文件一个。它将包含Concerto.mak文件中TARGET变量中提到的字符串。
concerto 基本概念
- concerto从根目录到子目录搜索所有名字为
concerto.mak
文件。- 每个
concerto.mak
生成一个库文件或可执行程序。 - 目录搜索:搜索所有在变量DIRECTORIES中包含的文件夹,定义在Makefile
- 每个
- concerto编译TARGET_COMBOS列举的文件,定义在Makefile
- 举一个target combos例子
TARGET_COMBOS += J7:SYSBIOS:R5F:3:debug:TIARMCGT
- 它定义了一组数据集合:这些数据有SOC, OS, CPU ARCH, CPU NUMBER(not used), BUILD PROFILE, TOOL CHAIN
-
像J7 , 相同的文件和库被编译多个适用不同CPU 的库。
-
使用顶级的make变量,如果不需要我们可以跳过某些目标组合。例如:仅仅构建调试配置或c7x 的库等等。
常用的命令及选项
make command | Description |
---|---|
make all | Build everything |
make clean | Clean everything |
make scrub | Delete all generated files |
make |
Verbose build, shows compiler invocation including all arguments passed to the compiler |
make |
Build’s a specific profile, valid values are, debug release all |
make targets | List all granular targets (libraries or executables) enabled in current build |
make |
Build a specific target listed during make targets |
make targets lists all enabled granular build targets. An example is shown below:
CONCERTO_TARGETS+=targetname1
CONCERTO_TARGETS+=targetname2
CONCERTO_TARGETS+=targetname3
...
Do make targetname1 to build the target named targetname1. This will build all dependant libraries and files within this project as well.
This can be used when you dont want to build the whole SW, but want to only build a specific library or executable.
It will not build libraries outside this project.
concerto.mak 文件分析
concerto.mak 文件长这个样子。
include (PRELUDE)
# all variable setup should be between PRELUDE and FINALE
TARGET := my_lib_name
TARGETTYPE := library
CSOURCES :=(call all-c-files)
include $(FINALE)
- 每一个concerto.mak编译一个库或可执行文件
- 上面是一个最简单concerto.mak文件例子
- 所有需要编译的c文件应与concerto.mak同目录。
- TARGETTYPE有两个选项一个是 library, 另一个是 exe 。
- 文件输出名字 “my_lib_name”
- 文件输出的名字还可以由前缀,后缀,扩展等等。
- 例如linux 系统的库文件的扩展名为.a : libmy_lib_name.a
- 用户可以设定自定义变量,或者利用通用的makefile 命令去自定义这个文件。
-
预定义的和通用的变量如下 。
Variable | Purpose |
---|---|
CSOURCES | List of C files to build, list each file explicitly or use the macro $(call all-c-files) |
DEFS | -D defines to apply when compiling files for this target |
IDIRS | include search paths to apply when compiling files for this target |
CFLAGS | additional compiler flags to apply when compiling files for this target |
LDIRS | library search paths to apply when linking files for this executable target |
STATIC_LIBS | static libraries (.a) to link when creating executable |
SYS_SHARED_LIBS | shared libraries (.so) to link when creating executable |
LFLAGS | additional linker flags to apply when linking files for this executable target |
SKIPBUILD | when SKIPBUILD=1, it would skip build of this target, useful to temporarily skip building certain concerto.mak files |
-
通常,一个软件项目的concerto.mak内容有条件编译ifeq
ifeq ((TARGET_CPU),(filter $(TARGET_CPU), x86_64 A72))
- 它允许为一个确定的CPU/OS编译一个特定的库。
-
下面的变量允许控制设定
Variable Purpose TARGET_CPU CPU architecture type TARGET_OS OS type TARGET_PLATFORM SoC or SoC family type TARGET_BUILD Build profile -
使用这些编译块和变量能够使用通用的makefile规则去编译项目更加模块化,例如:
- 使用 ifeq 与 $(filter …) 去基于make变量条件选择编译文件。
- 使用 include在常用的文件中收集通用的包含路径,库等。
- 定义项目特别的变量并使用他们在concerto.mak去条件编译或者设定特别的编译标志。
参考
相关
