MokoMakefile/zh cn

From Openmoko

(Difference between revisions)
Jump to: navigation, search
m (linkfix)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
MokoMakefile is a Makefile which saves lots of work when setting up an OpenMoko build environment.
+
{{Languages|MokoMakefile}}
By automating the setup process of a new OpenMoko build environment, it provides an environment which is configured the same for all the existing developers and should therefore be preferred over manual procedures or individual setup procedures.
+
It brings the same repeatability to build environment creation and maintenance as that which the BitBake scripts bring to [[OpenEmbedded]] ease and standardize the process of building OpenEmbedded.
+
  
Unlike the manual process described at [[Building OpenMoko from scratch]], MokoMakefile does not install anything into your system (it can and should be started as normal user).
 
MokoMakefile is a wrapper around all that to make it easy to set up and maintain a development environment that fully complies with the setup instructions published by OpenMoko.
 
  
MokoMakefile is developed by [[User:RodWhitby|Rod Whitby]] - it is not an official product of OpenMoko (although I would be happy for them to pick it up and use it internally).  If there is any discrepancy between the [[OpenMoko2007.2#How_to_build|official OpenMoko build instructions]], and the operation of the MokoMakefile, then you should consider the official instructions to be correct.
+
MokoMakefile 是在设立Openmoko Build 环境时储存所有工作的Makefile。藉由自动化安装新的Openmoko build 环境的过程,它提供所有的开发人员相同的设定环境。
  
The MokoMakefile is able to build either OM-2007.1 or OM-2007.2 images.  The core team chooses the default, but you can select one or the other at the top of the Makefile.
+
透过设定新的Openmoko build 环境设定过程,它提供现有的开发人员相同的设定,但一般较喜欢透过手动或个别的设定程序设定。
  
MokoMakefile also builds the QEMU-based Neo1973 emulator as part of the build process and has make targets to install the  OpenMoko images into it and run it. These commands can also be used without downloading and building the whole OpenMoko OpenEmbedded distribution. This part is described in [[Using QEMU with MokoMakefile]].
+
它会为BUILD 环境产物提供相同的重复性,并且可以像BitBake script放入[[OpenEmbedded]] 般轻松维护,并且提供建立OpenEmbedded的标准化过程。
  
== 生成OPENMOKO的要求 ==
+
它不像是在[[Building Openmoko 2007.1 from scratch|Building Openmoko from scratch]]中所提到的手动设定过程。MokiMakefile并不会安装任何程序到你的系统里(即使是一般的使用者也可以使用)。
Independent on whether MokoMakefile or a manual process is used to setup an OpenMoko build environment, there are several requirements which must be fulfilled in order for the OpenMoko build to succeed:
+
  
* RAM: The build host needs to have at least 512MB of RAM, and about the same amount of swap. Some packages built by OpenEmbedded like busybox are built by compiling all source files into one binary which causes gcc to grow beyond 300MB of size and no part of this memory may be on swap for the compile to finish in predictable time. For busybox, this can be turned off, but turning this off means that busybox will not as well optimized by gcc.
+
MokoMakefile是一个可以将所有东西包装起来,让开发人员能透过Openmoko设定指引的过程,完成编译,并且在开发环境下,它易于设定及维护。
  
* Disk space: You need about 12 GB of available disk space for the OpenMoko build to succeed (see below for a tip on how to reduce this).
+
MokoMakefile是由[[User:RodWhitby|Rod Whitby]] 所开发--它并不是一个Openmoko正式的产品。 若它与[[Openmoko2007.2#How_to_build|official Openmoko build instructions]]及MokoMakefile有差异之处,你应该考虑用正式的操作来修正它。
 +
MokoMakefile 可以建立OM-2007.1 或OM-2007.2 影像文件。核心团队选择默认值,但是你可以选择Makefile中的一些工具来使用。
  
* Time: The initial build takes at least 5 hours (on 2GHz core2duo without multiprocessor optimization) and may take several days on slower machines.
+
MokoMakefile也可以建立 QEMU-based Neo1973 仿真器,将它视为安装及执行Openmoko映像文件的目标装置。这些指令也可以在没有下载整个Openmoko OpenEmbedded套件的状况下下载及建立映像档。你可以在[[Using QEMU with MokoMakefile]]中找到这个部份的说明。
  
=== 软件要求 ===
+
== 建置Openmoko的需求 ==
The version control system used by OpenEmbedded is [http://monotone.ca monotone], it is not downloaded and installed by MokoMakefile. If your distribution does not provide a package, you can download and install a static binary from http://monotone.ca
+
  
Some distribution specific hints on preparing your build host for building OpenEmbedded are on  http://www.openembedded.org/wiki/OEandYourDistro but they may be outdated, incomplete and do not cover everything which OpenMoko needs to build.
+
不论单独或者是使用客制化的方法使用MokoMakefile来安装Openmoko 环境,你必须符合某些需求,让Openmoko build 可以成功运做:
  
A good guide is [[Building OpenMoko from scratch#Build host prerequisites|the section on build host prerequisites]] in [[Building OpenMoko from scratch]]
+
* RAM:build host 必须拥有至少512MB的RAM,及与它相同大小的swap空间。有一些套件像是busybox由OpenEmbedded建立,它是藉由先编译所有的来源档案,使它成为二进制文件,它会让 gcc 增加为超过 300MB 的大小,因此,会导致没有内存可以用做swap之用,造成无法预期编译时间的状况。
 +
对于busybox,这个可以关闭它,但关闭它并不会表示它能被gcc最佳化。
  
If you forgot anything which OE needs itself, OE will tell you shortly after you start building, but it does not check build dependencies of OpenMoko, so you either have to install them before starting or install them after the build failed. OpenEmbedded will continue where it stopped when you restart the build afterwards.
+
* 磁盘空间:你必须拥有12GB的可用硬盘空间,供给Openmoko build 使用(你可以参考下面的章节暸解怎么减少所需磁盘空间用量)。
  
==== Package requirements by distribution ====
+
* 时间:initial build 会花费至少5小时的时间 (在没有最佳化的多处理器的 2GHz core2duo 硬件环境下)且,在更慢速度的环境下,它可能会花费更长的时间。
Your distribution needs to provide these commands in order for OpenEmbedded to start building:
+
subversion texi2html texinfo help2man
+
  
OpenMoko needs the development packages (with header files, development libraries and tools) in order to finish building:
+
=== 需求软件 ===
ncurses zlib (or libz) OpenSSL GTK++
+
OpenEmbedded 用来控制系统的版本是[http://monotone.ca monotone],它并不是由MokoMakefile下载及安装的。如果你的套件并没有提供软件包,你可以从http://monotone.ca 下载并安装稳定的二进制文件。
 +
 
 +
 
 +
在http://www.openembedded.org/wiki/OEandYourDistro 中,你可以看到有一些套件特别隐喻指出要准备给OpenEmbedded使用的build host,但它可能有点老旧,不完整,并且不包含Openmoko需要的内容。
 +
 
 +
在[[Building Openmoko from scratch#Build host prerequisites|the section on build host prerequisites]] in [[Building Openmoko from scratch]]是很好的导引文章。
 +
 
 +
如果你忘记了OE本身所必须使用的东西,OE将会在你开始build 时出现提示,但是它并不会查看Openmoko的BUILD独立性,所以,你必须在开始前先安装它,或者在build失败之后安装它们。OpenEmbedded 会在你上次中断build的地方重新开始。
 +
 
 +
==== 依套件而衍生的软件包需求 ====
 +
 
 +
你的套件必须能提供以下的指令,以便于OpenEmbedded开始建立build:
 +
 
 +
subversion texi2html texinfo help2man
 +
 
 +
Openmoko须要开发套件(搭配header档案、开发链接库及工具) 以利于完成BUILD:
 +
 
 +
ncurses zlib (or libz) OpenSSL GTK++
 +
 
 +
因为在与QEMU及GCC-4互动时产生问题,你也必须安装gcc-3.x 。
  
Because there are bugs in the interaction of QEMU and GCC-4, you'll need a copy of gcc-3.x installed as well.
 
  
 
===== Debian / Ubuntu =====
 
===== Debian / Ubuntu =====
  apt-get install subversion monotone build-essential help2man diffstat texi2html texinfo cvs gawk
+
apt-get install subversion monotone build-essential help2man diffstat texi2html texinfo cvs gawk cogito
  
  apt-get install libncurses5-dev zlib1g-dev libssl-dev libgtk2.0-dev  
+
apt-get install libncurses5-dev zlib1g-dev libssl-dev libgtk2.0-dev
  # To prevent errors in host validation
+
# To prevent errors in host validation
  apt-get install ca-certificates
+
apt-get install ca-certificates
  # For OpenMoko 2007.2 using BitBake-1.8.8:
+
# For Openmoko 2007.2 using BitBake-1.8.8:
  apt-get install python-pysqlite2 sqlite3 sqlite3-doc python-pysqlite2-dbg
+
apt-get install python-pysqlite2 sqlite3 sqlite3-doc python-pysqlite2-dbg
  # For building faster
+
# For building faster
  apt-get install quilt python-psyco ccache
+
apt-get install quilt python-psyco ccache
  # For qemu, install a second compiler for bug avoidance; MokoMakefile knows to look for it.
+
# For qemu, install a second compiler for bug avoidance; MokoMakefile knows to look for it.
  apt-get install gcc-3.4 g++-3.4 libsdl1.2-dev lynx netpbm dosfstools
+
apt-get install gcc-3.4 g++-3.4 libsdl1.2-dev lynx netpbm dosfstools
  
 
===== SuSE =====
 
===== SuSE =====
For building OpenMoko on 10.3, you need
+
要在10.3上建立Openmoko,你必须要使用:
gcc-c++ ncurses-devel zlib-devel libopenssl-devel gtk2-devel subversion diffstat texinfo help2man and [http://download.opensuse.org/repositories/devel:/tools:/scm/openSUSE_Factory/repodata/repoview/Development.Tools.group.html monotone]
+
For MokoMakefile to not fail on compiling qemu-user, you need to use gcc33:
+
wget download.opensuse.org/repositories/devel:/tools:/gcc/openSUSE_Factory/i586/{cpp,gcc}33-3.3.3-41.8.i586.rpm
+
rpm -Uhv {cpp,gcc}33-3.3.3-41.8.i586.rpm
+
  
See also the [[Talk:MokoMakefile#Building_on_SuSE_Linux_10.3-AMD64|Talk page on Building on SuSE Linux 10.3-AMD64]]
+
gcc-c++ ncurses-devel zlib-devel libopenssl-devel gtk2-devel subversion diffstat texinfo help2man and [http://download.opensuse.org/repositories/devel:/tools:/scm/openSUSE_Factory/repodata/repoview/Development.Tools.group.html monotone]
  
10.1 and 10.2: same packages as 10.3, but install <code>openssl-devel</code> instead of libopenssl-devel. Use monotone for [http://download.opensuse.org/repositories/devel:/tools:/scm/openSUSE_10.2/repodata/repoview/Development.Tools.group.html 10.2] or [http://download.opensuse.org/repositories/devel:/tools:/scm/SUSE_Linux_10.1/repodata/repoview/Development.Tools.group.html 10.1]
+
为了让MokoMakefile不要在编译QUMU-USER时失败,你必须使用gcc33:
  
==== For all distributions ====
+
wget download.opensuse.org/repositories/devel:/tools:/gcc/openSUSE_Factory/i586/{cpp,gcc}33-3.3.3-41.8.i586.rpm
As the QEMU-based neo1973 emulator is also built as part of the build process started by MokoMakefile, so you need gcc-3.3 and other packages for building QEMU installed. See [[Using QEMU with MokoMakefile#Build requirements|the build requirements section]] in [[Using QEMU with MokoMakefile]] for information on the required software.
+
rpm -Uhv {cpp,gcc}33-3.3.3-41.8.i586.rpm
  
If you are having problems compiling QEMU and do not need it, you can disable building of QEMU by adding following line to build/conf/local.conf file:
+
你可以在[[Talk:MokoMakefile#Building_on_SuSE_Linux_10.3-AMD64|Talk page on Building on SuSE Linux 10.3-AMD64]]中找到它的内容。
ENABLE_BINARY_LOCALE_GENERATION = "0"
+
  
== 用 MokoMakefile 生成 Openmoko ==
+
10.1 及 10.2: 它与10.3套件相同,但是会安装 <code>openssl-devel</code> 而不是libopenssl-devel。针对monotone,请使用[http://download.opensuse.org/repositories/devel:/tools:/scm/openSUSE_10.2/repodata/repoview/Development.Tools.group.html 10.2] or [http://download.opensuse.org/repositories/devel:/tools:/scm/SUSE_Linux_10.1/repodata/repoview/Development.Tools.group.html 10.1]。
  
1 - Create your $OMDIR directory (note that you can change ~/moko to any directory you like. If you have your ~moko dir mounted from a different file system, be sure to edit /etc/mtab to add the 'exec' permission to the file system, else bitbake will fail with error messages stating that /usr/bin/env is an invalid interpreter):
+
==== 针对所有的套件 ====
  mkdir ~/moko ; cd ~/moko
+
如QEMU-based neo1973 仿真器也可以像由MokoMakefils开始建立映像档的其中一部份,所以,你需要gcc-3.3及其它的软件套件来建立QEMU安装。你可以参考在[[Using QEMU with MokoMakefile|在MokoMakefile中使用UEMU]]中的 [[Using QEMU with MokoMakefile#Build requirements|建立映像档基本需求]] 中所提到需求软件讯息。
2 - Grab MokoMakefile:
+
  wget http://www.rwhitby.net/files/openmoko/Makefile
+
  
If that doesn't work, try
+
在编译 QEMU 的过程若你有任何问题,或者是你不需要用到它,你可以藉由在build/conf/local.conf 档案中加入下列的指令,来停用QEMU。
  
  wget http://svn.nslu2-linux.org/svnroot/mokomakefile/trunk/Makefile
+
ENABLE_BINARY_LOCALE_GENERATION = "0"
  
  note: If you want to compile for the old version 2007.1 instead of the new
+
== 使用MokoMakefile建立Openmoko套件  ==
        version edit the top of the Makefile. Edit the lines at the top to
+
        look like this:
+
            OPENMOKO_GENERATION = 2007.1
+
            #OPENMOKO_GENERATION = 2007.2
+
  
{{note|For building 2007.2, MokoMakefile uses BitBake 1.8.8 which requires python-sqlite2 and sqlite-3.3 or later. Users of SUSE Linux 10.1 can update to [http://download.opensuse.org/pub/opensuse/distribution/10.2/repo/oss/suse/i586/sqlite-3.3.8-14.i586.rpm the version of openSUSE 10.2]}}
+
1 - 建立你的 $OMDIR 目录 (请注意你可以将 ~/moko 目录修改为任何你喜欢的目录。如果你已经从不同的档案系统挂载了 ~moko 目录,请确认你有编辑 /etc/mtab目录,为档案系统加入'执行'权限,否则 bitbake则会出现错误讯息:
  
3 - Set up the environment:
+
mkdir ~/moko ; cd ~/moko
  make setup
+
2 - 取得MokoMakefile:
4 - Start building. Before starting a lengthy make process, check the Tips section below for how to make Make multicore aware. You may want to modify the build/conf/local.conf file for your target (emulation/chroot) environment:
+
  make openmoko-devel-image
+
  
''Hint:'' The images build with this command can be found under {$OMDIR}/build/tmp/deploy/images/neo1973
+
wget http://www.rwhitby.net/files/openmoko/Makefile
  
This will set up the recommended directory structure as described in [[Building OpenMoko from scratch]], will download all the required software (from the right places with the right versions), and will immediately start building an image.
+
如果它无法使用的话,请试着使用下面的指令:
  
Once you have done this, you can choose to continue using the MokoMakefile to initiate your subsequent builds, or you can go into the build directory and run bitbake commands manually. The choice is yours.
+
wget http://svn.projects.openmoko.org/svnroot/mokomakefile/trunk/Makefile
  
[[Category:Application Developer]]
+
note: 如果你想要从旧版的 2007.1 开始编译,而不是使用新版的内容编译Makefile,请从如下的内容开始编辑:
[[Category:Guides]]
+
OPENMOKO_GENERATION = 2007.1
 +
#OPENMOKO_GENERATION = 2007.2
  
==Updating the environment==
+
{{note|为了要建立2007.2,MokoMakefile使用的BitBake 1.8.8必须使用需要python-sqlite2 及 sqlite-3.3或之后的版本。SUSE Linux 10.1的使用者可以从 [http://download.opensuse.org/pub/opensuse/distribution/10.2/repo/oss/suse/i586/sqlite-3.3.8-14.i586.rpm 这里更新openSUSE 10.2]}}
For easy maintenance of your build environment the following commands are available.
+
  
1 - To update the MokoMakefile to the latest version:
+
3 - 设定环境:
  make update-makefile
+
make setup
 +
4 - 开始building。在程序开始之前,请查看Tips一节,取得Make multicore aware。你可能想要修改build/conf/local.conf 档案到你的目的地 (emulation/chroot) 环境:
  
2 - To make sure that any recent changes to the build directory structure have been applied:
+
make openmoko-devel-image
  make setup
+
  
3 - To update the OpenMoko repository checkout and the MokoMakefile patches to the latest version:
+
''Hint:'' 使用这个指令建立的映像文件可以在下面的路径下找到{$OMDIR}/build/tmp/deploy/images/neo1973
  make update
+
  
A quick way to rebuild a new image with the latest updates:
+
它将会设定在[[Building Openmoko from scratch|从scratch中建立Openmoko]]建议的路径结构,它会下载所有需要的档案(从正确的地方取得正确的版本),它将会立刻开始建立影像文件。
  make update-makefile && make setup update openmoko-devel-image
+
  
==Build issues==
+
一旦你做好了它,你可以选择继续使用MokoMakefile来启始你拉下来的build,或者你可以进入build 目录,并且手动执行bitbake指令。你可以自行选择自己要的方法。
First, make sure that the problem is reproducible after running
+
  
make update-makefile && make setup && make update
+
==更新环境==
  
then run
+
为了要更为容易的维护你所建立的环境,下面的指令是很有用的。
  
make clean-package-<foo>
+
1 - 将MokoMakefile更新到最近的版本:
  
(where you replace <foo> with the name of the package which is failing)
+
make update-makefile
  
and finally
+
2 - 确认建立的目录架构是否有任何新的变更:
  
make openmoko-devel-image
+
make setup
  
If you can get the error to occur three times in a row after running that sequence of commands (including the update and setup steps) three times, then feel free to report it to rwhitby in #openmoko on [http://wiki.openmoko.org/wiki/Development_resources#IRC IRC].
+
3 - 要更新放置Openmoko原始码及档案的储存位置及MokoMakefile patches到最近的版本:
  
===MokoMakefile 的错误信息 ===
+
make update
If you experience the following after changing from OM-2007.1 to OM-2007.2:
+
  
Patch bitbake-1.6.6-om3.patch does not apply (enforce with -f)
+
以最后变更的项目来重建新映像档的最快方法:
  
then type "make clobber-patches" to fix it.  There was a period of 24 hours when there was a bug in the MokoMakefile which causes this problem.  Once the patches have been clobbered, they will re-download and the problem will not reoccur.
+
make update-makefile && make setup update openmoko-devel-image
  
If you see:
+
==与制作映像档相关的问题==
 +
首先,确认在执行下面指令后,问题是可以重新制作:
  
ERROR: No providers of build target u-boot-openmoko (for [])
+
make update-makefile && make setup && make update
  
then look back in the log to see if you encountered an earlier error while building the openmoko-devel-image target. The above error is a side-effect of MokoMakefile's logic to handle the re-naming of "uboot-openmoko" to "u-boot-openmoko".
+
之后,执行:
  
===Fixes for distribution/environment-specific or isolated issues===
+
make clean-package-<foo>
  
Work-arounds for temporary or isolated problems can be found and should be added to the [[Talk:MokoMakefile|Discussion page]] which is associated with this page.  As they are fixed, they will be removed from that page.
+
( <foo> 替代为失败的软件名称)
  
==提示==
+
最后,
*You can reduce the amount of consumed disk space significantly by adding
+
  INHERIT += "rm_work"
+
in your local.conf (e.g. ~/moko/build/conf/local.conf). This will remove the contents of each build/tmp/work/*/<package> directory after the corresponding package builds correctly. As of 10/16/07, this appears to be present in local.conf by default.
+
  
*If you an encounter an error with monotone similar to the following:
+
make openmoko-devel-image
  mtn: misuse: database /home/''username''/moko/OE.mtn is laid out according to an old schema
+
Then you need to upgrade OE.mtn  Use the following command while in ~/moko:
+
  # mtn --db OE.mtn db migrate
+
  
*If a certain package does not build due to corrupted download or some such try to remove the sources and rebuild it.
+
如果好运的话--你应该会在 $omdir/build/tmp/deploy/glibc/images/neo1973/ 目录下找到映像文件。
rm sources/<package>*
+
接着,你可以参考 [[Flashing the Neo 1973||Flashing openmoko更新这些内容]]
cd build
+
. ../setup-env
+
bitbake -crebuild <package>
+
after that your build might just work again.
+
  
*For people with multiple CPU's (or dual-core ones) this small patch might be useful to build things faster.
+
若是没有找到映像档的话,你可以在执行此一系列的命令列(包含更新及安装操作)之后得到约三次的错误讯息,之后就可以将报告放到[http://wiki.openmoko.org/wiki/Development_resources#IRC IRC]中。
Edit the local.conf and add the following lines:
+
PARALLEL_MAKE = "-j 4"
+
BB_NUMBER_THREADS = "4"
+
  
Change the PARALLEL_MAKE and BB_NUMBER_THREADS values to something that suits better if it chokes your machine.
+
===已知的MokoMakefile错误 ===
 +
从OM-2007.1 更新到 OM-2007.2,你会历经下列过程:
  
*For amd64 host users you need the patch from http://bugs.openembedded.org/show_bug.cgi?id=1765 to build db3-native
+
Patch bitbake-1.6.6-om3.patch does not apply (enforce with -f)
  
* If you encounter an error related with the qemu-native package and not compiling for the qemu, you can edit the build/conf/local.conf file and add ENABLE_BINARY_LOCALE_GENERATION = "0" line to avoid the error.
+
然后,键入 "make clobber-patches" 修复它。若在MokoMakefile中有BUG的话,它可能会进行约24小时。一旦patches遭到破坏,他们将会重新下载,并且这个问题就不会再发生。
  
* To prevent building tons of locales, add a line like this to local.conf:
+
如果你看到下列讯息:
GLIBC_GENERATE_LOCALES = "en_US.UTF-8 nl_NL.UTF-8"
+
  
* To not build any binary locales at all, add this to local.conf:
+
ERROR: No providers of build target u-boot-openmoko (for [])
ENABLE_BINARY_LOCALE_GENERATION = "0"
+
  
* If you want to rebuild the package indexes (for instance, after compiling a new version of a package) without building <code>openmoko-devel-image</code>, run <code>make build-package-package-index</code>.
+
查看日志记录来查看你是否遇到了与建立openmoko-devel-image 相同的错误,上面的错误是MokoMakefile的逻辑性的边际效应,只要将"uboot-openmoko" 重新以 "u-boot-openmoko"命名即可。
  
[[User:Wurp]] will update this to be a little more comprehensible, but maybe it can help someone as-is in the meantime:
+
===修正套件/特定环境或独立性问题===
* If MokoMakefile always fails on some fetch in zlib, just find the binary somewhere, add it to the downloads or sources directory manually (create the .md5 matching file if necessary), and retry.
+
  
=== 有用的命令 ===
+
暂时性或独立的问题时,都可以在[[Talk:MokoMakefile|讨论页]]中找到相关的内容。当他们被修复之后,他们将会从那个页面中被移除。
Here is the list (not complete) of useful MokoMakefile commands (actually make targets) and a short description of each one. These should be run inside $OMDIR directory.
+
  
; make openmoko-devel-image : build the full development image
+
==Tips==
 +
*你可以藉由下列指令,减少消耗的磁盘空间:
  
; make openmoko-devel-tools : build statically-linked [[dfu-util]] and [[openocd]] binaries
+
INHERIT += "rm_work"
  
; make openmoko-toolchain : builds [[toolchain]]
+
将这行指令加到 local.conf (e.g. ~/moko/build/conf/local.conf)。 在相对应的软件套件正确建立后,它将会移除T每一个映像文件中的/tmp/work/*/<package> 目录。在10/16/07中,预设的情况下,它会出现在local.conf中。
  
; make qemu : builds qemu, downloads flash images from official repository, flashes qemu emulated Neo1973 and runs emulator (see also [[OpenMoko under QEMU]]).  
+
*如果你在monotone中遇到了如下的错误:
 +
mtn: misuse: database /home/''username''/moko/OE.mtn is laid out according to an old schema
  
; make qemu-local : same as ''make qemu'', but uses locally built images instead of official ones.
+
接着,你须要升级OE.mtn。在~/moko中使用以下的内容:
 +
# mtn --db OE.mtn db migrate
  
; make run-qemu : runs qemu with usb keyboard ''(note: qemu must first be built!)''. This target starts the emulator with some predefined set of options. If you need to start it with other options (enable telnet, etc), see [[QEMU_command_line]].
+
* 如果特定的软件包,因为下载中断或者是试图移动原始码及重建它而没有进行建立映像档的工作:
 +
rm sources/<package>*
 +
cd build
 +
. ../setup-env
 +
bitbake -crebuild <package>
  
; make build-package-<package name> : buids ''<package name>'' package
+
之后,你的BUILD可能必须重新运作一次。
  
; make update-makefile : updates MokoMakefile
+
*针对拥有多个CPU的使用者(或者dual-core)而言,这个小的patch对于加速建立映像档的工作,会有些作用。
  
; make clean-package-<foo>: cleans the "<foo>" package
+
编辑local.conf 并且加入下列指令列:
 +
PARALLEL_MAKE = "-j 4"
 +
BB_NUMBER_THREADS = "4"
  
; make setup : to make sure that any recent changes to the build directory structure have been applied
+
变更PARALLEL_MAKE 及 BB_NUMBER_THREADS 值,以配合装置。
 
+
; make update : to update the OpenMoko repository checkout and the MokoMakefile patches to the latest version
+
  
==Developing with MokoMakefile==
+
*针对amd64 主机的使用者,你必须从http://bugs.openembedded.org/show_bug.cgi?id=1765 修补到db3-native
  
{{note|If using MokoMakefile with OM2007.2 then references to $OMDIR/openmoko should be replaced with $OMDIR/openembedded. Also references to tmp/work/armv4t-linux should be replaced with tmp/work/fic-gta01-angstrom-linux-gnueabi}}
+
* 如果遇到与 qemu-native 软件相关的错误,并且没有从qemu编译,你可以编辑 build/conf/local.conf 档案,并且启用ENABLE_BINARY_LOCALE_GENERATION = "0" 指令列来避免这个错误。
  
For the following explanations $OMDIR is the directory where there Makefile puts all the stuff.
+
* 要避免locales过大,在local.conf中加入以下的指令:
  
To make in-tree changes and have them built and used by qemu:
+
GLIBC_GENERATE_LOCALES = "en_US.UTF-8 nl_NL.UTF-8"
  
  cd $OMDIR/openmoko
+
* 为了不要建立二位的locale,请加入以下的内容到local.conf:
  quilt new descriptive-patch-name.patch
+
ENABLE_BINARY_LOCALE_GENERATION = "0"
  quilt add trunk/src/name-of-file-to-change # do this for every file you are about to modify
+
  ...make the changes...
+
  quilt refresh # this creates a file in $OMDIR/patches/openmoko-HEAD/ and updates the quilt series file there
+
  
Note: Do '''NOT''' use absolute paths as this confuses quilt and will get you a diff of the file against /dev/null!
+
* 若你想要重建软件的索引 (如,在编译新版的软件时)而不要建立 <code>openmoko-devel-image</code>,请执行run <code>make build-package-package-index</code>。
  
To build the changes and have them used by qemu:
+
[[User:Wurp]] 将会更新它,让它变为易于理解的,但也许它同时也可以帮忙很多人。
 +
* 如果MokoMakefile经常在zlib的部份失败,请找出它的二位档案,将它下载或手动加到原始的目录下(有必要的话,建立.md5),并且重试。
  
  make build-qemu
+
=== 好用的指令列 ===
  make flash-qemu-local
+
以下是MokoMakefile中较有用的指令清单(actually make targets) 及针对这些指令的一些简单的介绍。它应该在$OMDIR 中执行。
  make run-qemu
+
  
If you want to modify applications instead of the openmoko toolchain, this is what you have to do (example: openmoko-messages):
+
; make openmoko-devel-image :建立完整的开发映像档。
  
  cd $OMDIR/build
+
; make openmoko-devel-tools :建立静态连结的[[dfu-util]]及[[openocd]]二位文件
  . ../setup-env
+
  bitbake -c unpack openmoko-messages
+
  cd ../build/tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages/
+
  ...make the changes...
+
  cd -
+
  bitbake openmoko-messages
+
  
Then continue with MokoMakefile usage.
+
; make openmoko-toolchain : 建立[[toolchain]]
  
If you want to add an application to your openmoko distribution, do this:
+
; make qemu:建立qemu,从正式的下载点下载更新映像档,更新qemu模拟的Neo1973并且执行仿真器(请参考[[Openmoko under QEMU]])。
All file edits should be done using quilt as described above. That way a patch can easily be submitted to the openmoko project.
+
First, create a directory that will correspond to your package and edit a '''.bb''' file in there:
+
  cd $OMDIR/openmoko/
+
  quilt new mycoolpackage.patch
+
  mkdir trunk/oe/packages/mycoolpackage
+
  quilt add trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb
+
  quilt edit trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb
+
  
The file should have the following content:
+
; make qemu-local :与''make qemu'',但是使用本机建立的映像档,而不是官方的映像档。
  DESCRIPTION = "This is a cool package"
+
 
  SECTION = "username/mycoolpackage"
+
; make run-qemu : 使用usb 键盘执行qemu''(note: qemu 必须先建立好!)''。它主要是启动预先定义选项的仿真器。如果你需要以其它的选项(如enable、telnet)来启动它的话,请参考[[QEMU_command_line]]。
  PV = "1"
+
 
 
+
; make build-package-<package name> : 建立 ''<package name>'' 套件
  inherit autotools
+
 
 
+
; make update-makefile : 更新MokoMakefile
  SRC_URI = "http://www.example.com/download/mycoolpackage-1.tar.gz"
+
 
 +
; make clean-package-<foo>: 清除 "<foo>" 套件
 +
 
 +
; make setup : 确认目录结构中任何最近的更新是否被套用。
 +
 
 +
; make update : 要更新Openmoko repository checkout and the MokoMakefile patches to the latest version
 +
 
 +
==使用MokoMakefile开发程序==
 +
 
 +
 
 +
{{note|如果将MokoMakefile用在OM2007.2上,并且参考$OMDIR/openmoko,它应该用$OMDIR/openembedded取代与置换。Also references to tmp/work/armv4t-linux should be replaced with tmp/work/fic-gta01-angstrom-linux-gnueabi}}
 +
 
 +
针对下列的解释 $OMDIR 是Makefile放置所有东西的位置。
 +
 
 +
要让in-tree 变更,并且让它们可以被qemu使用:
 +
 
 +
cd $OMDIR/openmoko
 +
quilt new descriptive-patch-name.patch
 +
quilt add trunk/src/name-of-file-to-change # do this for every file you are about to modify
 +
...make the changes...
 +
quilt refresh # this creates a file in $OMDIR/patches/openmoko-HEAD/ and updates the quilt series file there
 +
 
 +
Note: Do'''NOT'''  absolute paths as this confuses quilt and will get you a diff of the file against /dev/null!
 +
 
 +
要建立变更内容,并且 让他们可以被qemu使用:
 +
 
 +
make build-qemu
 +
make flash-qemu-local
 +
make run-qemu
 +
 
 +
如果你想要修改应用程序,而不是Openmoko toolchain,它是你必须做的工作(如:openmoko-messages):
 +
 
 +
cd $OMDIR/build
 +
. ../setup-env
 +
bitbake -c unpack openmoko-messages
 +
cd tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages/
 +
''...make the changes...''
 +
cd -
 +
bitbake openmoko-messages
 +
 
 +
然后,继续使用MokoMakefile。
 +
 
 +
如果你想要在Openmoko套件中加入应用程序,请进行下列工作:
 +
所有的档案编辑都应该使用quilt。这样patch就可以轻松的送到openmoko项目当中。
 +
首先,建立一个与套件相对应的路径,并且编辑这个路径下的 '''.bb''' 档案。
 +
cd $OMDIR/openmoko/
 +
quilt new mycoolpackage.patch
 +
mkdir trunk/oe/packages/mycoolpackage
 +
quilt add trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb
 +
quilt edit trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb
 +
 
 +
这个档案应该有下面的内容:
 +
 
 +
DESCRIPTION = "This is a cool package"
 +
SECTION = "username/mycoolpackage"
 +
PV = "1"
 +
 
 +
inherit autotools
 +
 
 +
SRC_URI = "http://www.example.com/download/mycoolpackage-1.tar.gz"
  
 
Explanation:
 
Explanation:
* DESCRIPTION - Just a short text explaining the package
+
* DESCRIPTION - 解释套件用途的简短说明。
* SECTION - I have no clue, but I'll use username/mycoolpackage for now
+
* SECTION - 现在,我会使用username/mycoolpackage
* PV - Package Version
+
* PV - 套件版本
* inherit autotools - The package can be compiled by './configure && make && make install' so we tell MokoMakefile to do it this way.
+
* inherit autotools - 这个套件可以被'./configure && make && make install' 编译,所以我们可以让MokoMakefile用这个方法运作。
* SRC_URI = ... - This is the download location of the package source. It's imperative that the tar.gz contains a directory called '''packagename-packageversion''' (in this case: mycoolpackage-1) so that MokoMakefile can find it automatically or the build will fail.
+
* SRC_URI = ... - 这是软件下载的位置,tar.gz包含了名为'''packagename-packageversion'''的目录,(在这个案例中,为 mycoolpackage-1),因此MokoMakefile可以自动找到它,或者这个build会失败。
  
This is not all. We also need to tell MokoMakfile that it needs to build and include the package in the image. To do this, do
+
这并不是全部,我们也会需要告诉MokoMakfile它需要被建立,并且在映像文件中包含软件套件。要完成这个工作,请执行下面的指令:
  $OMDIR/openmoko# quilt edit trunk/oe/packages/tasks/task-openmoko.bb
+
Here, increase the value '''PR''' by one and add '''mycoolpackage \''' (with the backslash!) just before the line reading '''#  update-alternatives \'''.
+
  
Now run
+
$OMDIR/openmoko# quilt edit trunk/oe/packages/tasks/task-openmoko.bb
  quilt refresh
+
  cd ..
+
  make update openmoko-devel-image
+
  
And if everything's alright you should now have an OpenMoko image to flash to your phone or run in qemu as described above.
+
在这里,在读入'''#  update-alternatives \'''.
 +
程序行前,加入 '''PR''' 及 '''mycoolpackage \''' (使用\符号)
  
=== Hello World 程序 ===
+
现在,执行
  
There is a [http://wiki.openmoko.org/wiki/Building_a_hello_world_application Hello World!] tutorial available too.
+
quilt refresh
 +
cd ..
 +
make update openmoko-devel-image
  
==Testimonials==
+
如果每一件事都顺利的话,你应该建立好了可以更新到手机的Openmoko映像档,并且可以在qemu 执行。
MokoMakefile is recommended by 4 out of 4 new developers on #openmoko, with testimonials such as "For some reason last night I couldn't get my manual install of everything to work (bb complained about my bbpath I think) ... but with your makefile, it works great!", "MokoMakefile rocks!", "Wow this build system is nice - it just seems more polished than my gumstix toolchain buildroot system", and "make openmoko-devel-image :) - no magic there".
+
  
Project page:
+
=== Hello World 应用程序范例 ===
 +
 
 +
[http://wiki.openmoko.org/wiki/Building_a_hello_world_application Hello World范例程序!]手册可以在这里下载。
 +
 
 +
==感谢状==
 +
MokoMakefile被#openmoko开发人员所推崇:
 +
"因为某些原因,我无法手动安装每个套件,让(bb 抱怨我的 bbpath ) ... 但是使用你的makefile,它可以顺利的运作。 "
 +
"MokoMakefile rocks!"
 +
"Wow this build system is nice - it just seems more polished than my gumstix toolchain buildroot system", and "make openmoko-devel-image :) - no magic there".
 +
 
 +
专案网页:
 
http://mokomakefile.projects.openmoko.org/
 
http://mokomakefile.projects.openmoko.org/
[[Category:Guides]]
+
 
 +
[[Category:Application Developer/zh cn]]
 +
[[Category:System Developers/zh cn]]

Latest revision as of 15:53, 22 October 2008


MokoMakefile 是在设立Openmoko Build 环境时储存所有工作的Makefile。藉由自动化安装新的Openmoko build 环境的过程,它提供所有的开发人员相同的设定环境。

透过设定新的Openmoko build 环境设定过程,它提供现有的开发人员相同的设定,但一般较喜欢透过手动或个别的设定程序设定。

它会为BUILD 环境产物提供相同的重复性,并且可以像BitBake script放入OpenEmbedded 般轻松维护,并且提供建立OpenEmbedded的标准化过程。

它不像是在Building Openmoko from scratch中所提到的手动设定过程。MokiMakefile并不会安装任何程序到你的系统里(即使是一般的使用者也可以使用)。

MokoMakefile是一个可以将所有东西包装起来,让开发人员能透过Openmoko设定指引的过程,完成编译,并且在开发环境下,它易于设定及维护。

MokoMakefile是由Rod Whitby 所开发--它并不是一个Openmoko正式的产品。 若它与official Openmoko build instructions及MokoMakefile有差异之处,你应该考虑用正式的操作来修正它。 MokoMakefile 可以建立OM-2007.1 或OM-2007.2 影像文件。核心团队选择默认值,但是你可以选择Makefile中的一些工具来使用。

MokoMakefile也可以建立 QEMU-based Neo1973 仿真器,将它视为安装及执行Openmoko映像文件的目标装置。这些指令也可以在没有下载整个Openmoko OpenEmbedded套件的状况下下载及建立映像档。你可以在Using QEMU with MokoMakefile中找到这个部份的说明。

Contents

[edit] 建置Openmoko的需求

不论单独或者是使用客制化的方法使用MokoMakefile来安装Openmoko 环境,你必须符合某些需求,让Openmoko build 可以成功运做:

  • RAM:build host 必须拥有至少512MB的RAM,及与它相同大小的swap空间。有一些套件像是busybox由OpenEmbedded建立,它是藉由先编译所有的来源档案,使它成为二进制文件,它会让 gcc 增加为超过 300MB 的大小,因此,会导致没有内存可以用做swap之用,造成无法预期编译时间的状况。

对于busybox,这个可以关闭它,但关闭它并不会表示它能被gcc最佳化。

  • 磁盘空间:你必须拥有12GB的可用硬盘空间,供给Openmoko build 使用(你可以参考下面的章节暸解怎么减少所需磁盘空间用量)。
  • 时间:initial build 会花费至少5小时的时间 (在没有最佳化的多处理器的 2GHz core2duo 硬件环境下)且,在更慢速度的环境下,它可能会花费更长的时间。

[edit] 需求软件

OpenEmbedded 用来控制系统的版本是monotone,它并不是由MokoMakefile下载及安装的。如果你的套件并没有提供软件包,你可以从http://monotone.ca 下载并安装稳定的二进制文件。


在http://www.openembedded.org/wiki/OEandYourDistro 中,你可以看到有一些套件特别隐喻指出要准备给OpenEmbedded使用的build host,但它可能有点老旧,不完整,并且不包含Openmoko需要的内容。

the section on build host prerequisites in Building Openmoko from scratch是很好的导引文章。

如果你忘记了OE本身所必须使用的东西,OE将会在你开始build 时出现提示,但是它并不会查看Openmoko的BUILD独立性,所以,你必须在开始前先安装它,或者在build失败之后安装它们。OpenEmbedded 会在你上次中断build的地方重新开始。

[edit] 依套件而衍生的软件包需求

你的套件必须能提供以下的指令,以便于OpenEmbedded开始建立build:

subversion texi2html texinfo help2man

Openmoko须要开发套件(搭配header档案、开发链接库及工具) 以利于完成BUILD:

ncurses zlib (or libz) OpenSSL GTK++

因为在与QEMU及GCC-4互动时产生问题,你也必须安装gcc-3.x 。


[edit] Debian / Ubuntu

apt-get install subversion monotone build-essential help2man diffstat texi2html texinfo cvs gawk cogito

apt-get install libncurses5-dev zlib1g-dev libssl-dev libgtk2.0-dev

  1. To prevent errors in host validation

apt-get install ca-certificates

  1. For Openmoko 2007.2 using BitBake-1.8.8:

apt-get install python-pysqlite2 sqlite3 sqlite3-doc python-pysqlite2-dbg

  1. For building faster

apt-get install quilt python-psyco ccache

  1. For qemu, install a second compiler for bug avoidance; MokoMakefile knows to look for it.

apt-get install gcc-3.4 g++-3.4 libsdl1.2-dev lynx netpbm dosfstools

[edit] SuSE

要在10.3上建立Openmoko,你必须要使用:

gcc-c++ ncurses-devel zlib-devel libopenssl-devel gtk2-devel subversion diffstat texinfo help2man and monotone

为了让MokoMakefile不要在编译QUMU-USER时失败,你必须使用gcc33:

wget download.opensuse.org/repositories/devel:/tools:/gcc/openSUSE_Factory/i586/{cpp,gcc}33-3.3.3-41.8.i586.rpm rpm -Uhv {cpp,gcc}33-3.3.3-41.8.i586.rpm

你可以在Talk page on Building on SuSE Linux 10.3-AMD64中找到它的内容。

10.1 及 10.2: 它与10.3套件相同,但是会安装 openssl-devel 而不是libopenssl-devel。针对monotone,请使用10.2 or 10.1

[edit] 针对所有的套件

如QEMU-based neo1973 仿真器也可以像由MokoMakefils开始建立映像档的其中一部份,所以,你需要gcc-3.3及其它的软件套件来建立QEMU安装。你可以参考在在MokoMakefile中使用UEMU中的 建立映像档基本需求 中所提到需求软件讯息。

在编译 QEMU 的过程若你有任何问题,或者是你不需要用到它,你可以藉由在build/conf/local.conf 档案中加入下列的指令,来停用QEMU。

ENABLE_BINARY_LOCALE_GENERATION = "0"

[edit] 使用MokoMakefile建立Openmoko套件

1 - 建立你的 $OMDIR 目录 (请注意你可以将 ~/moko 目录修改为任何你喜欢的目录。如果你已经从不同的档案系统挂载了 ~moko 目录,请确认你有编辑 /etc/mtab目录,为档案系统加入'执行'权限,否则 bitbake则会出现错误讯息:

mkdir ~/moko ; cd ~/moko 2 - 取得MokoMakefile:

wget http://www.rwhitby.net/files/openmoko/Makefile

如果它无法使用的话,请试着使用下面的指令:

wget http://svn.projects.openmoko.org/svnroot/mokomakefile/trunk/Makefile

note: 如果你想要从旧版的 2007.1 开始编译,而不是使用新版的内容编译Makefile,请从如下的内容开始编辑: OPENMOKO_GENERATION = 2007.1

  1. OPENMOKO_GENERATION = 2007.2
NOTE: 为了要建立2007.2,MokoMakefile使用的BitBake 1.8.8必须使用需要python-sqlite2 及 sqlite-3.3或之后的版本。SUSE Linux 10.1的使用者可以从 这里更新openSUSE 10.2


3 - 设定环境: make setup 4 - 开始building。在程序开始之前,请查看Tips一节,取得Make multicore aware。你可能想要修改build/conf/local.conf 档案到你的目的地 (emulation/chroot) 环境:

make openmoko-devel-image

Hint: 使用这个指令建立的映像文件可以在下面的路径下找到{$OMDIR}/build/tmp/deploy/images/neo1973

它将会设定在从scratch中建立Openmoko建议的路径结构,它会下载所有需要的档案(从正确的地方取得正确的版本),它将会立刻开始建立影像文件。

一旦你做好了它,你可以选择继续使用MokoMakefile来启始你拉下来的build,或者你可以进入build 目录,并且手动执行bitbake指令。你可以自行选择自己要的方法。

[edit] 更新环境

为了要更为容易的维护你所建立的环境,下面的指令是很有用的。

1 - 将MokoMakefile更新到最近的版本:

make update-makefile

2 - 确认建立的目录架构是否有任何新的变更:

make setup

3 - 要更新放置Openmoko原始码及档案的储存位置及MokoMakefile patches到最近的版本:

make update

以最后变更的项目来重建新映像档的最快方法:

make update-makefile && make setup update openmoko-devel-image

[edit] 与制作映像档相关的问题

首先,确认在执行下面指令后,问题是可以重新制作:

make update-makefile && make setup && make update

之后,执行:

make clean-package-<foo>

( <foo> 替代为失败的软件名称)

最后,

make openmoko-devel-image

如果好运的话--你应该会在 $omdir/build/tmp/deploy/glibc/images/neo1973/ 目录下找到映像文件。 接着,你可以参考 |Flashing openmoko更新这些内容

若是没有找到映像档的话,你可以在执行此一系列的命令列(包含更新及安装操作)之后得到约三次的错误讯息,之后就可以将报告放到IRC中。

[edit] 已知的MokoMakefile错误

从OM-2007.1 更新到 OM-2007.2,你会历经下列过程:

Patch bitbake-1.6.6-om3.patch does not apply (enforce with -f)

然后,键入 "make clobber-patches" 修复它。若在MokoMakefile中有BUG的话,它可能会进行约24小时。一旦patches遭到破坏,他们将会重新下载,并且这个问题就不会再发生。

如果你看到下列讯息:

ERROR: No providers of build target u-boot-openmoko (for [])

查看日志记录来查看你是否遇到了与建立openmoko-devel-image 相同的错误,上面的错误是MokoMakefile的逻辑性的边际效应,只要将"uboot-openmoko" 重新以 "u-boot-openmoko"命名即可。

[edit] 修正套件/特定环境或独立性问题

暂时性或独立的问题时,都可以在讨论页中找到相关的内容。当他们被修复之后,他们将会从那个页面中被移除。

[edit] Tips

  • 你可以藉由下列指令,减少消耗的磁盘空间:

INHERIT += "rm_work"

将这行指令加到 local.conf (e.g. ~/moko/build/conf/local.conf)。 在相对应的软件套件正确建立后,它将会移除T每一个映像文件中的/tmp/work/*/<package> 目录。在10/16/07中,预设的情况下,它会出现在local.conf中。

  • 如果你在monotone中遇到了如下的错误:

mtn: misuse: database /home/username/moko/OE.mtn is laid out according to an old schema

接着,你须要升级OE.mtn。在~/moko中使用以下的内容:

  1. mtn --db OE.mtn db migrate
  • 如果特定的软件包,因为下载中断或者是试图移动原始码及重建它而没有进行建立映像档的工作:

rm sources/<package>* cd build . ../setup-env bitbake -crebuild <package>

之后,你的BUILD可能必须重新运作一次。

  • 针对拥有多个CPU的使用者(或者dual-core)而言,这个小的patch对于加速建立映像档的工作,会有些作用。

编辑local.conf 并且加入下列指令列: PARALLEL_MAKE = "-j 4" BB_NUMBER_THREADS = "4"

变更PARALLEL_MAKE 及 BB_NUMBER_THREADS 值,以配合装置。

  • 针对amd64 主机的使用者,你必须从http://bugs.openembedded.org/show_bug.cgi?id=1765 修补到db3-native
  • 如果遇到与 qemu-native 软件相关的错误,并且没有从qemu编译,你可以编辑 build/conf/local.conf 档案,并且启用ENABLE_BINARY_LOCALE_GENERATION = "0" 指令列来避免这个错误。
  • 要避免locales过大,在local.conf中加入以下的指令:

GLIBC_GENERATE_LOCALES = "en_US.UTF-8 nl_NL.UTF-8"

  • 为了不要建立二位的locale,请加入以下的内容到local.conf:

ENABLE_BINARY_LOCALE_GENERATION = "0"

  • 若你想要重建软件的索引 (如,在编译新版的软件时)而不要建立 openmoko-devel-image,请执行run make build-package-package-index

User:Wurp 将会更新它,让它变为易于理解的,但也许它同时也可以帮忙很多人。

  • 如果MokoMakefile经常在zlib的部份失败,请找出它的二位档案,将它下载或手动加到原始的目录下(有必要的话,建立.md5),并且重试。

[edit] 好用的指令列

以下是MokoMakefile中较有用的指令清单(actually make targets) 及针对这些指令的一些简单的介绍。它应该在$OMDIR 中执行。

make openmoko-devel-image :建立完整的开发映像档。
make openmoko-devel-tools :建立静态连结的dfu-utilopenocd二位文件
make openmoko-toolchain : 建立toolchain
make qemu:建立qemu,从正式的下载点下载更新映像档,更新qemu模拟的Neo1973并且执行仿真器(请参考Openmoko under QEMU)。
make qemu-local :与make qemu,但是使用本机建立的映像档,而不是官方的映像档。
make run-qemu : 使用usb 键盘执行qemu(note: qemu 必须先建立好!)。它主要是启动预先定义选项的仿真器。如果你需要以其它的选项(如enable、telnet)来启动它的话,请参考QEMU_command_line
make build-package-<package name> 
建立 <package name> 套件
make update-makefile 
更新MokoMakefile
make clean-package-<foo>
清除 "<foo>" 套件
make setup 
确认目录结构中任何最近的更新是否被套用。
make update 
要更新Openmoko repository checkout and the MokoMakefile patches to the latest version

[edit] 使用MokoMakefile开发程序

NOTE: 如果将MokoMakefile用在OM2007.2上,并且参考$OMDIR/openmoko,它应该用$OMDIR/openembedded取代与置换。Also references to tmp/work/armv4t-linux should be replaced with tmp/work/fic-gta01-angstrom-linux-gnueabi


针对下列的解释 $OMDIR 是Makefile放置所有东西的位置。

要让in-tree 变更,并且让它们可以被qemu使用:

cd $OMDIR/openmoko quilt new descriptive-patch-name.patch quilt add trunk/src/name-of-file-to-change # do this for every file you are about to modify ...make the changes... quilt refresh # this creates a file in $OMDIR/patches/openmoko-HEAD/ and updates the quilt series file there

Note: DoNOT absolute paths as this confuses quilt and will get you a diff of the file against /dev/null!

要建立变更内容,并且 让他们可以被qemu使用:

make build-qemu make flash-qemu-local make run-qemu

如果你想要修改应用程序,而不是Openmoko toolchain,它是你必须做的工作(如:openmoko-messages):

cd $OMDIR/build . ../setup-env bitbake -c unpack openmoko-messages cd tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages/ ...make the changes... cd - bitbake openmoko-messages

然后,继续使用MokoMakefile。

如果你想要在Openmoko套件中加入应用程序,请进行下列工作: 所有的档案编辑都应该使用quilt。这样patch就可以轻松的送到openmoko项目当中。 首先,建立一个与套件相对应的路径,并且编辑这个路径下的 .bb 档案。 cd $OMDIR/openmoko/ quilt new mycoolpackage.patch mkdir trunk/oe/packages/mycoolpackage quilt add trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb quilt edit trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb

这个档案应该有下面的内容:

DESCRIPTION = "This is a cool package" SECTION = "username/mycoolpackage" PV = "1"

inherit autotools

SRC_URI = "http://www.example.com/download/mycoolpackage-1.tar.gz"

Explanation:

  • DESCRIPTION - 解释套件用途的简短说明。
  • SECTION - 现在,我会使用username/mycoolpackage
  • PV - 套件版本
  • inherit autotools - 这个套件可以被'./configure && make && make install' 编译,所以我们可以让MokoMakefile用这个方法运作。
  • SRC_URI = ... - 这是软件下载的位置,tar.gz包含了名为packagename-packageversion的目录,(在这个案例中,为 mycoolpackage-1),因此MokoMakefile可以自动找到它,或者这个build会失败。

这并不是全部,我们也会需要告诉MokoMakfile它需要被建立,并且在映像文件中包含软件套件。要完成这个工作,请执行下面的指令:

$OMDIR/openmoko# quilt edit trunk/oe/packages/tasks/task-openmoko.bb

在这里,在读入# update-alternatives \. 程序行前,加入 PRmycoolpackage \ (使用\符号)

现在,执行

quilt refresh cd .. make update openmoko-devel-image

如果每一件事都顺利的话,你应该建立好了可以更新到手机的Openmoko映像档,并且可以在qemu 执行。

[edit] Hello World 应用程序范例

Hello World范例程序!手册可以在这里下载。

[edit] 感谢状

MokoMakefile被#openmoko开发人员所推崇: "因为某些原因,我无法手动安装每个套件,让(bb 抱怨我的 bbpath ) ... 但是使用你的makefile,它可以顺利的运作。 " "MokoMakefile rocks!" "Wow this build system is nice - it just seems more polished than my gumstix toolchain buildroot system", and "make openmoko-devel-image :) - no magic there".

专案网页: http://mokomakefile.projects.openmoko.org/

Personal tools

MokoMakefile is a Makefile which saves lots of work when setting up an OpenMoko build environment. By automating the setup process of a new OpenMoko build environment, it provides an environment which is configured the same for all the existing developers and should therefore be preferred over manual procedures or individual setup procedures. It brings the same repeatability to build environment creation and maintenance as that which the BitBake scripts bring to OpenEmbedded ease and standardize the process of building OpenEmbedded.

Unlike the manual process described at Building OpenMoko from scratch, MokoMakefile does not install anything into your system (it can and should be started as normal user). MokoMakefile is a wrapper around all that to make it easy to set up and maintain a development environment that fully complies with the setup instructions published by OpenMoko.

MokoMakefile is developed by Rod Whitby - it is not an official product of OpenMoko (although I would be happy for them to pick it up and use it internally). If there is any discrepancy between the official OpenMoko build instructions, and the operation of the MokoMakefile, then you should consider the official instructions to be correct.

The MokoMakefile is able to build either OM-2007.1 or OM-2007.2 images. The core team chooses the default, but you can select one or the other at the top of the Makefile.

MokoMakefile also builds the QEMU-based Neo1973 emulator as part of the build process and has make targets to install the OpenMoko images into it and run it. These commands can also be used without downloading and building the whole OpenMoko OpenEmbedded distribution. This part is described in Using QEMU with MokoMakefile.

生成OPENMOKO的要求

Independent on whether MokoMakefile or a manual process is used to setup an OpenMoko build environment, there are several requirements which must be fulfilled in order for the OpenMoko build to succeed:

  • RAM: The build host needs to have at least 512MB of RAM, and about the same amount of swap. Some packages built by OpenEmbedded like busybox are built by compiling all source files into one binary which causes gcc to grow beyond 300MB of size and no part of this memory may be on swap for the compile to finish in predictable time. For busybox, this can be turned off, but turning this off means that busybox will not as well optimized by gcc.
  • Disk space: You need about 12 GB of available disk space for the OpenMoko build to succeed (see below for a tip on how to reduce this).
  • Time: The initial build takes at least 5 hours (on 2GHz core2duo without multiprocessor optimization) and may take several days on slower machines.

软件要求

The version control system used by OpenEmbedded is monotone, it is not downloaded and installed by MokoMakefile. If your distribution does not provide a package, you can download and install a static binary from http://monotone.ca

Some distribution specific hints on preparing your build host for building OpenEmbedded are on http://www.openembedded.org/wiki/OEandYourDistro but they may be outdated, incomplete and do not cover everything which OpenMoko needs to build.

A good guide is the section on build host prerequisites in Building OpenMoko from scratch

If you forgot anything which OE needs itself, OE will tell you shortly after you start building, but it does not check build dependencies of OpenMoko, so you either have to install them before starting or install them after the build failed. OpenEmbedded will continue where it stopped when you restart the build afterwards.

Package requirements by distribution

Your distribution needs to provide these commands in order for OpenEmbedded to start building:

subversion texi2html texinfo help2man

OpenMoko needs the development packages (with header files, development libraries and tools) in order to finish building:

ncurses zlib (or libz) OpenSSL GTK++

Because there are bugs in the interaction of QEMU and GCC-4, you'll need a copy of gcc-3.x installed as well.

Debian / Ubuntu
 apt-get install subversion monotone build-essential help2man diffstat texi2html texinfo cvs gawk
 apt-get install libncurses5-dev zlib1g-dev libssl-dev libgtk2.0-dev 
 # To prevent errors in host validation
 apt-get install ca-certificates
 # For OpenMoko 2007.2 using BitBake-1.8.8:
 apt-get install python-pysqlite2 sqlite3 sqlite3-doc python-pysqlite2-dbg
 # For building faster
 apt-get install quilt python-psyco ccache
 # For qemu, install a second compiler for bug avoidance; MokoMakefile knows to look for it.
 apt-get install gcc-3.4 g++-3.4 libsdl1.2-dev lynx netpbm dosfstools
SuSE

For building OpenMoko on 10.3, you need

gcc-c++ ncurses-devel zlib-devel libopenssl-devel gtk2-devel subversion diffstat texinfo help2man and monotone

For MokoMakefile to not fail on compiling qemu-user, you need to use gcc33:

wget download.opensuse.org/repositories/devel:/tools:/gcc/openSUSE_Factory/i586/{cpp,gcc}33-3.3.3-41.8.i586.rpm
rpm -Uhv {cpp,gcc}33-3.3.3-41.8.i586.rpm

See also the Talk page on Building on SuSE Linux 10.3-AMD64

10.1 and 10.2: same packages as 10.3, but install openssl-devel instead of libopenssl-devel. Use monotone for 10.2 or 10.1

For all distributions

As the QEMU-based neo1973 emulator is also built as part of the build process started by MokoMakefile, so you need gcc-3.3 and other packages for building QEMU installed. See the build requirements section in Using QEMU with MokoMakefile for information on the required software.

If you are having problems compiling QEMU and do not need it, you can disable building of QEMU by adding following line to build/conf/local.conf file:

ENABLE_BINARY_LOCALE_GENERATION = "0"

用 MokoMakefile 生成 Openmoko

1 - Create your $OMDIR directory (note that you can change ~/moko to any directory you like. If you have your ~moko dir mounted from a different file system, be sure to edit /etc/mtab to add the 'exec' permission to the file system, else bitbake will fail with error messages stating that /usr/bin/env is an invalid interpreter):

  mkdir ~/moko ; cd ~/moko

2 - Grab MokoMakefile:

  wget http://www.rwhitby.net/files/openmoko/Makefile

If that doesn't work, try

  wget http://svn.nslu2-linux.org/svnroot/mokomakefile/trunk/Makefile
  note: If you want to compile for the old version 2007.1 instead of the new
        version edit the top of the Makefile. Edit the lines at the top to 
        look like this:
            OPENMOKO_GENERATION = 2007.1
            #OPENMOKO_GENERATION = 2007.2
NOTE: For building 2007.2, MokoMakefile uses BitBake 1.8.8 which requires python-sqlite2 and sqlite-3.3 or later. Users of SUSE Linux 10.1 can update to the version of openSUSE 10.2


3 - Set up the environment:

  make setup

4 - Start building. Before starting a lengthy make process, check the Tips section below for how to make Make multicore aware. You may want to modify the build/conf/local.conf file for your target (emulation/chroot) environment:

  make openmoko-devel-image

Hint: The images build with this command can be found under {$OMDIR}/build/tmp/deploy/images/neo1973

This will set up the recommended directory structure as described in Building OpenMoko from scratch, will download all the required software (from the right places with the right versions), and will immediately start building an image.

Once you have done this, you can choose to continue using the MokoMakefile to initiate your subsequent builds, or you can go into the build directory and run bitbake commands manually. The choice is yours.

Updating the environment

For easy maintenance of your build environment the following commands are available.

1 - To update the MokoMakefile to the latest version:

  make update-makefile 

2 - To make sure that any recent changes to the build directory structure have been applied:

  make setup 

3 - To update the OpenMoko repository checkout and the MokoMakefile patches to the latest version:

  make update

A quick way to rebuild a new image with the latest updates:

  make update-makefile && make setup update openmoko-devel-image

Build issues

First, make sure that the problem is reproducible after running

make update-makefile && make setup && make update

then run

make clean-package-<foo>

(where you replace <foo> with the name of the package which is failing)

and finally

make openmoko-devel-image

If you can get the error to occur three times in a row after running that sequence of commands (including the update and setup steps) three times, then feel free to report it to rwhitby in #openmoko on IRC.

MokoMakefile 的错误信息

If you experience the following after changing from OM-2007.1 to OM-2007.2:

Patch bitbake-1.6.6-om3.patch does not apply (enforce with -f)

then type "make clobber-patches" to fix it. There was a period of 24 hours when there was a bug in the MokoMakefile which causes this problem. Once the patches have been clobbered, they will re-download and the problem will not reoccur.

If you see:

ERROR: No providers of build target u-boot-openmoko (for [])

then look back in the log to see if you encountered an earlier error while building the openmoko-devel-image target. The above error is a side-effect of MokoMakefile's logic to handle the re-naming of "uboot-openmoko" to "u-boot-openmoko".

Fixes for distribution/environment-specific or isolated issues

Work-arounds for temporary or isolated problems can be found and should be added to the Discussion page which is associated with this page. As they are fixed, they will be removed from that page.

提示

  • You can reduce the amount of consumed disk space significantly by adding
  INHERIT += "rm_work"

in your local.conf (e.g. ~/moko/build/conf/local.conf). This will remove the contents of each build/tmp/work/*/<package> directory after the corresponding package builds correctly. As of 10/16/07, this appears to be present in local.conf by default.

  • If you an encounter an error with monotone similar to the following:
  mtn: misuse: database /home/username/moko/OE.mtn is laid out according to an old schema

Then you need to upgrade OE.mtn Use the following command while in ~/moko:

  # mtn --db OE.mtn db migrate
  • If a certain package does not build due to corrupted download or some such try to remove the sources and rebuild it.
rm sources/<package>*
cd build
. ../setup-env
bitbake -crebuild <package>

after that your build might just work again.

  • For people with multiple CPU's (or dual-core ones) this small patch might be useful to build things faster.

Edit the local.conf and add the following lines:

PARALLEL_MAKE = "-j 4"
BB_NUMBER_THREADS = "4"

Change the PARALLEL_MAKE and BB_NUMBER_THREADS values to something that suits better if it chokes your machine.

  • If you encounter an error related with the qemu-native package and not compiling for the qemu, you can edit the build/conf/local.conf file and add ENABLE_BINARY_LOCALE_GENERATION = "0" line to avoid the error.
  • To prevent building tons of locales, add a line like this to local.conf:
GLIBC_GENERATE_LOCALES = "en_US.UTF-8 nl_NL.UTF-8"
  • To not build any binary locales at all, add this to local.conf:
ENABLE_BINARY_LOCALE_GENERATION = "0"
  • If you want to rebuild the package indexes (for instance, after compiling a new version of a package) without building openmoko-devel-image, run make build-package-package-index.

User:Wurp will update this to be a little more comprehensible, but maybe it can help someone as-is in the meantime:

  • If MokoMakefile always fails on some fetch in zlib, just find the binary somewhere, add it to the downloads or sources directory manually (create the .md5 matching file if necessary), and retry.

有用的命令

Here is the list (not complete) of useful MokoMakefile commands (actually make targets) and a short description of each one. These should be run inside $OMDIR directory.

make openmoko-devel-image 
build the full development image
make openmoko-devel-tools 
build statically-linked dfu-util and openocd binaries
make openmoko-toolchain 
builds toolchain
make qemu 
builds qemu, downloads flash images from official repository, flashes qemu emulated Neo1973 and runs emulator (see also OpenMoko under QEMU).
make qemu-local 
same as make qemu, but uses locally built images instead of official ones.
make run-qemu 
runs qemu with usb keyboard (note: qemu must first be built!). This target starts the emulator with some predefined set of options. If you need to start it with other options (enable telnet, etc), see QEMU_command_line.
make build-package-<package name> 
buids <package name> package
make update-makefile 
updates MokoMakefile
make clean-package-<foo>
cleans the "<foo>" package
make setup 
to make sure that any recent changes to the build directory structure have been applied
make update 
to update the OpenMoko repository checkout and the MokoMakefile patches to the latest version

Developing with MokoMakefile

NOTE: If using MokoMakefile with OM2007.2 then references to $OMDIR/openmoko should be replaced with $OMDIR/openembedded. Also references to tmp/work/armv4t-linux should be replaced with tmp/work/fic-gta01-angstrom-linux-gnueabi


For the following explanations $OMDIR is the directory where there Makefile puts all the stuff.

To make in-tree changes and have them built and used by qemu:

 cd $OMDIR/openmoko
 quilt new descriptive-patch-name.patch
 quilt add trunk/src/name-of-file-to-change # do this for every file you are about to modify
 ...make the changes...
 quilt refresh # this creates a file in $OMDIR/patches/openmoko-HEAD/ and updates the quilt series file there

Note: Do NOT use absolute paths as this confuses quilt and will get you a diff of the file against /dev/null!

To build the changes and have them used by qemu:

 make build-qemu
 make flash-qemu-local
 make run-qemu

If you want to modify applications instead of the openmoko toolchain, this is what you have to do (example: openmoko-messages):

 cd $OMDIR/build
 . ../setup-env
 bitbake -c unpack openmoko-messages
 cd ../build/tmp/work/armv4t-linux/openmoko-messages-0.0.1+svnnow-r2_2276/openmoko-messages/
 ...make the changes...
 cd -
 bitbake openmoko-messages

Then continue with MokoMakefile usage.

If you want to add an application to your openmoko distribution, do this: All file edits should be done using quilt as described above. That way a patch can easily be submitted to the openmoko project. First, create a directory that will correspond to your package and edit a .bb file in there:

 cd $OMDIR/openmoko/
 quilt new mycoolpackage.patch
 mkdir trunk/oe/packages/mycoolpackage
 quilt add trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb
 quilt edit trunk/oe/packages/mycoolpackage/mycoolpackage_1.bb

The file should have the following content:

 DESCRIPTION = "This is a cool package"
 SECTION = "username/mycoolpackage"
 PV = "1"
 
 inherit autotools
 
 SRC_URI = "http://www.example.com/download/mycoolpackage-1.tar.gz"

Explanation:

  • DESCRIPTION - Just a short text explaining the package
  • SECTION - I have no clue, but I'll use username/mycoolpackage for now
  • PV - Package Version
  • inherit autotools - The package can be compiled by './configure && make && make install' so we tell MokoMakefile to do it this way.
  • SRC_URI = ... - This is the download location of the package source. It's imperative that the tar.gz contains a directory called packagename-packageversion (in this case: mycoolpackage-1) so that MokoMakefile can find it automatically or the build will fail.

This is not all. We also need to tell MokoMakfile that it needs to build and include the package in the image. To do this, do

 $OMDIR/openmoko# quilt edit trunk/oe/packages/tasks/task-openmoko.bb

Here, increase the value PR by one and add mycoolpackage \ (with the backslash!) just before the line reading # update-alternatives \.

Now run

 quilt refresh
 cd ..
 make update openmoko-devel-image

And if everything's alright you should now have an OpenMoko image to flash to your phone or run in qemu as described above.

Hello World 程序

There is a Hello World! tutorial available too.

Testimonials

MokoMakefile is recommended by 4 out of 4 new developers on #openmoko, with testimonials such as "For some reason last night I couldn't get my manual install of everything to work (bb complained about my bbpath I think) ... but with your makefile, it works great!", "MokoMakefile rocks!", "Wow this build system is nice - it just seems more polished than my gumstix toolchain buildroot system", and "make openmoko-devel-image :) - no magic there".

Project page: http://mokomakefile.projects.openmoko.org/