创建交叉编译器的命令非常简单, 使用NetBSD新的src/build.sh 脚本. 请注意,普通用户(非root)可以运行这里的所有命令:
代码: 全选
$ cd /usr/src
$ ./build.sh -m sparc64 tools
如果以前已经编译过这些工具,并且它们仅需进行更新, 那么可以使用更新选项"-u",这样仅重新编译需更新的工具:
代码: 全选
$ ./build.sh -u -m sparc64 tools
代码: 全选
...
===> build.sh started: Thu Dec 2 22:18:11 CET 2007
===> build.sh ended: Thu Dec 2 22:28:22 CET 2007
===> Summary of results:
build.sh command: ./build.sh -m sparc64 tools
build.sh started: Thu Dec 2 22:18:11 CET 2007
No nonexistent/bin/nbmake, needs building.
Bootstrapping nbmake
MACHINE: sparc64
MACHINE_ARCH: sparc64
TOOLDIR path: /usr/src/tooldir.NetBSD-4.0-i386
DESTDIR path: /usr/src/destdir.sparc64
RELEASEDIR path: /usr/src/releasedir
Created /usr/src/tooldir.NetBSD-4.0-i386/bin/nbmake
makewrapper: /usr/src/tooldir.NetBSD-4.0-i386/bin/nbmake-sparc64
Updated /usr/src/tooldir.NetBSD-4.0-i386/bin/nbmake-sparc64
Tools built to /usr/src/tooldir.NetBSD-4.0-i386
build.sh started: Thu Dec 2 22:18:11 CET 2007
build.sh ended: Thu Dec 2 22:28:22 CET 2007
===> .
工具链本身也是其中的一部分, 但是因为它在i386系统上并且是在i386上编译的, 它将被放置于自己的目录内,标志着在哪里进行的交叉编译。 这是交叉编译工具所在位置:
代码: 全选
$ pwd
/usr/src
$ ls -d tooldir.*
tooldir.NetBSD-4.0-i386
代码: 全选
$ ls tooldir.NetBSD-4.0-i386/bin/
nbasn1_compile nbmakefs nbzic
nbcap_mkdb nbmakeinfo sparc64--netbsd-addr2li
nbcat nbmakewhatis sparc64--netbsd-ar
nbcksum nbmenuc sparc64--netbsd-as
nbcompile_et nbmkcsmapper sparc64--netbsd-c++
nbconfig nbmkdep sparc64--netbsd-c++filt
nbcrunchgen nbmkesdb sparc64--netbsd-cpp
nbctags nbmklocale sparc64--netbsd-dbsym
nbdb nbmknod sparc64--netbsd-g++
nbeqn nbmktemp sparc64--netbsd-g77
nbfgen nbmsgc sparc64--netbsd-gcc
nbfile nbmtree sparc64--netbsd-gcc-3.3
nbgencat nbnroff sparc64--netbsd-gccbug
nbgroff nbpax sparc64--netbsd-gcov
nbhexdump nbpic sparc64--netbsd-ld
nbhost-mkdep nbpwd_mkdb sparc64--netbsd-lint
nbindxbib nbrefer sparc64--netbsd-mdsetim
nbinfo nbrpcgen sparc64--netbsd-nm
nbinfokey nbsoelim sparc64--netbsd-objcopy
nbinstall nbstat sparc64--netbsd-objdump
nbinstall-info nbsunlabel sparc64--netbsd-ranlib
nbinstallboot nbtbl sparc64--netbsd-readelf
nblex nbtexi2dvi sparc64--netbsd-size
nblorder nbtexindex sparc64--netbsd-strings
nbm4 nbtsort sparc64--netbsd-strip
nbmake nbuudecode
nbmake-sparc64 nbyacc
One important tool that should be pointed out here is "nbmake-sparc64". This is a shell wrapper for a BSD compatible make(1) command that's setup to use all the right commands from the crosscompiler toolchain. Using this wrapper instead of /usr/bin/make allows crosscompiling programs that were written using the NetBSD Makefile infrastructure (see src/share/mk). We will use this make(1) wrapper in a second to cross compile the kernel!