目录
相关旧帖:【总结】crosstool-ng使用心得和注意事项
crosstool-ng中关于配置,此处,主要介绍两个大的方面:
关于crosstool-ng的配置本身,其实也有一定的使用逻辑和技巧。
这些逻辑和技巧,实际上,作者在其主页:
中已经解释过了,此处,是加上自己实际折腾的经验的基础上
再次整理出来,解释清楚:第 3.2 节 “crosstool-ng本身的配置的使用的基本逻辑”
很明显,由于配置参数极多,并且,不同版本中,也可能发生细微的变化,所以不可能面面俱到的解释所有的配置参数的详细的含义。
但是,又很明显,一些常见的参数,核心的参数,重要的参数,则至始至终,都不会改变的,而且也是必须要搞懂的。
所以,此处,主要介绍crosstool-ng中,常见的,核心的那些参数。
而这些常见的,核心的参数,根据其相关性,又主要分两方面:
在去使用和crosstool-ng之前,需要了解一些,和crosstool-ng本身的一些逻辑和背景知识。
然后才能对于后面的配置和编译,如何使用crosstool-ng,有个真正的理解。
正如Linux世界中的常见逻辑,crosstool-ng中,也可以通过help,查看到,其本身具有哪些功能:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0_build $ ct-ng help This is crosstool-NG version 1.18.0 Copyright (C) 2008 Yann E. MORIN <[email protected]> This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See below for a list of available actions, listed by category: Configuration actions: menuconfig - Update current config using a menu based program oldconfig - Update current config using a provided .config as base extractconfig - Extract to stdout the configuration items from a build.log file piped to stdin defconfig - Save current config as a mini-defconfig to ${CONFIG} olddefconfig - Update config from a mini-defconfig ${CONFIG} (default: ${CONFIG}=./defconfig) saveconfig - Save current config as a preconfigured target show-tuple - Print the tuple of the currently configured toolchain Preconfigured toolchains (#: force number of // jobs): list-samples - prints the list of all samples (for scripting) show-<sample> - show a brief overview of <sample> (list with list-samples) <sample> - preconfigure crosstool-NG with <sample> (list with list-samples) build-all[.#] - Build *all* samples (list with list-samples) and install in ${CT_PREFIX} (which you must set) Build actions (#: force number of // jobs): build[.#] - Build the currently configured toolchain list-steps - List all build steps Clean actions: clean - Remove generated files distclean - Remove generated files, configuration and build directories Distribution actions: wiki-samples - Print a DokuWiki table of samples updatetools - Update the config tools tarball - Build a tarball of the configured toolchain Environment variables (see /opt/crosstool-ng/share/doc/crosstool-ng/ct-ng.1.18.0/0 - Table of content.txt): STOP=step - Stop the build just after this step (list with list-steps) RESTART=step - Restart the build just before this step (list with list-steps) CT_PREFIX=dir - install samples in dir (see action "build-all", above). V=0|1|2 - 0 => show only human-readable messages (default) 1 => show only the commands being executed 2 => show both Use action "menuconfig" to configure your toolchain Use action "build" to build your toolchain Use action "version" to see the version See "man 1 ct-ng" for some help as well
正如此,看了help之后,才有后面的,各种功能的用法。比如:
查看当前有哪些(默认的)示例配置,可以用:
ct-ng list-samples
查看单个的某个示例配置的核心参数,用:
ct-ng show-<sample>
直接借用(使用,调用)该默认配置,用:
ct-ng <sample>
等等。
关于其他的更多用法,后续会详细解释的。
如上所述,用list-steps,可以查看到,当前,用crosstool-ng去build,去制作交叉编译器,具体分成哪些步骤:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0_build $ ct-ng list-steps Available build steps, in order: - libc_check_config - companion_libs_for_build - binutils_for_build - companion_libs_for_host - binutils_for_host - cc_core_pass_1 - kernel_headers - libc_start_files - cc_core_pass_2 - libc - cc_for_build - cc_for_host - libelf_for_target - binutils_for_target - debug - test_suite - finish Use "<step>" as action to execute only that step. Use "+<step>" as action to execute up to that step. Use "<step>+" as action to execute from that step onward.
知道了,此处分了多少步骤,具体有哪些步骤之后
后面才有可能去实现,从之前出错的哪一步,恢复,继续编译。
如第 3.1.1 节 “用ct-ng help查看所拥有的功能”中所述,我们可以通过
ct-ng list-samples
查看到,当前crosstool-ng中,已经有了哪些默认的,帮我们配置好的哪些配置:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0 $ ct-ng list-samples Status Sample name MKDIR config.gen IN config.gen/arch.in IN config.gen/kernel.in IN config.gen/cc.in IN config.gen/binutils.in IN config.gen/libc.in IN config.gen/debug.in [L.X] alphaev56-unknown-linux-gnu [L.X] alphaev67-unknown-linux-gnu [L.X] arm-bare_newlib_cortex_m3_nommu-eabi [L.X] arm-cortex_a15-linux-gnueabi [L..] arm-cortex_a8-linux-gnueabi [L..] arm-davinci-linux-gnueabi [L..] armeb-unknown-eabi [L.X] armeb-unknown-linux-gnueabi [L.X] armeb-unknown-linux-uclibcgnueabi [L..] arm-unknown-eabi [L..] arm-unknown-linux-gnueabi [L.X] arm-unknown-linux-uclibcgnueabi [L.X] armv6-rpi-linux-gnueabi [L.X] avr32-unknown-none [L..] bfin-unknown-linux-uclibc [L..] i586-geode-linux-uclibc [L.X] i586-mingw32msvc,i686-none-linux-gnu [L.X] i686-nptl-linux-gnu [L.X] i686-unknown-mingw32 [L.X] m68k-unknown-elf [L.X] m68k-unknown-uclinux-uclibc [L.X] mips64el-n32-linux-uclibc [L.X] mips64el-n64-linux-uclibc [L.X] mips-ar2315-linux-gnu [L..] mipsel-sde-elf [L..] mipsel-unknown-linux-gnu [L.X] mips-malta-linux-gnu [L..] mips-unknown-elf [L.X] mips-unknown-linux-uclibc [L..] powerpc-405-linux-gnu [L.X] powerpc64-unknown-linux-gnu [L..] powerpc-860-linux-gnu [L.X] powerpc-e300c3-linux-gnu [L.X] powerpc-e500v2-linux-gnuspe [L..] powerpc-unknown_nofpu-linux-gnu [L..] powerpc-unknown-linux-gnu [L..] powerpc-unknown-linux-uclibc [L.X] s390-ibm-linux-gnu [L.X] s390x-ibm-linux-gnu [L..] sh4-unknown-linux-gnu [L..] x86_64-unknown-linux-gnu [L..] x86_64-unknown-linux-uclibc [L.X] x86_64-unknown-mingw32 L (Local) : sample was found in current directory G (Global) : sample was installed with crosstool-NG X (EXPERIMENTAL): sample may use EXPERIMENTAL features B (BROKEN) : sample is currently broken
如此,后续就可以去使用这些默认配置了。
在后续的配置(和编译)之后,可以通过show-tuple,去查看到当前配置的交叉编译器是啥样的:
比如,我之前在折腾:
【记录】重试使用最新版本1.18.0的crosstool-ng去配置和编译xscale的交叉编译器
后,对应的结果是:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0_build $ ct-ng show-tuple arm-xscale-linux-gnueabi
就知道当前,配置的交叉编译器,是:arm-xscale-linux-gnueabi
类似的,可以通过version查看当前的crosstool-ng工具本身的版本:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.18.0_build $ ct-ng version This is crosstool-NG version 1.18.0 Copyright (C) 2008 Yann E. MORIN <[email protected]> This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
即,此处的crosstool-ng的版本是:1.18.0