MokoMakefile/zh tw

From Openmoko

(Difference between revisions)
Jump to: navigation, search
(依套件而衍生的套裝軟體需求)
m (linkfix)
 
(39 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
{{Languages|MokoMakefile}}
 
{{Languages|MokoMakefile}}
  
MokoMakefile 是在設立Openmoko Build環境時儲存所有工作的Makefile。藉由自動化安裝新的Openmoko build環境的過程,它提供所有的開發人員相同的設定環境。
 
  
透過設定新的Openmoko build環境設定過程,它提供為所有現有的開發人員相同的設定,但一般較喜歡透過手動或個別的設定程序設定。
+
MokoMakefile 是在設立Openmoko Build 環境時儲存所有工作的Makefile。藉由自動化安裝新的Openmoko build 環境的過程,它提供所有的開發人員相同的設定環境。
 +
 
 +
透過設定新的Openmoko build 環境設定過程,它提供現有的開發人員相同的設定,但一般較喜歡透過手動或個別的設定程序設定。
  
 
它會為BUILD 環境產物提供相同的重覆性,並且可以像BitBake script放入[[OpenEmbedded]] 般輕鬆維護,並且提供建立OpenEmbedded的標準化過程。
 
它會為BUILD 環境產物提供相同的重覆性,並且可以像BitBake script放入[[OpenEmbedded]] 般輕鬆維護,並且提供建立OpenEmbedded的標準化過程。
  
它不像是在[[Building Openmoko 2007.1 from scratch|Building Openmoko from scratch]]中所提到的手動設定過程。MokiMakefile並不會安裝任何程式到你的系統裡(即使是一般的使用者也可以使用)。
+
它不像是在[[Building Openmoko 2007.1 from scratch|Building Openmoko from scratch]]中所提到的手動設定過程。MokoMakefile並不會安裝任何程式到你的系統裡(即使是一般的使用者也可以使用)。
  
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是一個可以將所有東西包裝起來,讓開發人員能透過Openmoko設定指引的過程,完成編譯,並且在開發環境下,它易於設定及維護。
  
MokoMakefile是由[[User:RodWhitby|Rod Whitby]] 所開發--它並不是一個Openmoko正式的產品。 若它與[[OpenMoko2007.2#How_to_build|official OpenMoko build instructions]]及MokoMakefile有差異之處,你應該考慮用正式的操作來修正它。
+
MokoMakefile是由[[User:RodWhitby|Rod Whitby]] 所開發--它並不是一個Openmoko正式的產品。 若它與[[Openmoko2007.2#How_to_build|official Openmoko build instructions]]及MokoMakefile有差異之處,你應該考慮用正式的操作來修正它。
 
MokoMakefile 可以建立OM-2007.1 或OM-2007.2 影像檔。核心團隊選擇預設值,但是你可以選擇Makefile中的一些工具來使用。
 
MokoMakefile 可以建立OM-2007.1 或OM-2007.2 影像檔。核心團隊選擇預設值,但是你可以選擇Makefile中的一些工具來使用。
  
MokoMakefile也可以建立QEMU-based Neo1973 模擬器,將它視為安裝及執行Openmoko映像檔的目標裝置。這些指令也可以在沒有下載整個Openmoko OpenEmbedded套件的狀況下下載及建立映像檔。你可以在[[Using QEMU with MokoMakefile]]中找到這個部份的說明。
+
MokoMakefile也可以建立 QEMU-based Neo1973 模擬器,將它視為安裝及執行Openmoko映像檔的目標裝置。這些指令也可以在沒有下載整個Openmoko OpenEmbedded套件的狀況下下載及建立映像檔。你可以在[[Using QEMU with MokoMakefile]]中找到這個部份的說明。
  
 
== 建置Openmoko的需求 ==
 
== 建置Openmoko的需求 ==
 +
 
不論單獨或者是使用客製化的方法使用MokoMakefile來安裝Openmoko 環境,你必須符合某些需求,讓Openmoko build 可以成功運做:
 
不論單獨或者是使用客製化的方法使用MokoMakefile來安裝Openmoko 環境,你必須符合某些需求,讓Openmoko build 可以成功運做:
  
Line 22: Line 24:
 
對於busybox,這個可以關閉它,但關閉它並不會表示它能被gcc最佳化。
 
對於busybox,這個可以關閉它,但關閉它並不會表示它能被gcc最佳化。
  
* 磁碟空間:你必須擁有12 GB的可用硬碟空間,供給Openmoko build使用(你可以參考下面的文節暸解怎麼減少所需磁碟空間用量)。
+
* 磁碟空間:你必須擁有12GB的可用硬碟空間,供給Openmoko build 使用(你可以參考下面的章節暸解怎麼減少所需磁碟空間用量)。
  
 
* 時間:initial build 會花費至少5小時的時間 (在沒有最佳化的多處理器的 2GHz core2duo 硬體環境下)且,在更慢速度的環境下,它可能會花費更長的時間。
 
* 時間:initial build 會花費至少5小時的時間 (在沒有最佳化的多處理器的 2GHz core2duo 硬體環境下)且,在更慢速度的環境下,它可能會花費更長的時間。
Line 30: Line 32:
  
  
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.
+
在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]]是很好的導引文章。
+
在[[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的地方重新開始。
+
如果你忘記了OE本身所必須使用的東西,OE將會在你開始build 時出現提示,但是它並不會查看Openmoko的BUILD獨立性,所以,你必須在開始前先安裝它,或者在build失敗之後安裝它們。OpenEmbedded 會在你上次中斷build的地方重新開始。
  
 
==== 依套件而衍生的套裝軟體需求 ====
 
==== 依套件而衍生的套裝軟體需求 ====
 +
 
你的套件必須能提供以下的指令,以便於OpenEmbedded開始建立build:
 
你的套件必須能提供以下的指令,以便於OpenEmbedded開始建立build:
  
subversion texi2html texinfo help2man
+
subversion texi2html texinfo help2man
  
 
Openmoko須要開發套件(搭配header檔案、開發程式庫及工具) 以利於完成BUILD:
 
Openmoko須要開發套件(搭配header檔案、開發程式庫及工具) 以利於完成BUILD:
  
ncurses zlib (or libz) OpenSSL GTK++
+
ncurses zlib (or libz) OpenSSL GTK++
  
 
因為在與QEMU及GCC-4互動時產生問題,你也必須安裝gcc-3.x 。
 
因為在與QEMU及GCC-4互動時產生問題,你也必須安裝gcc-3.x 。
Line 49: Line 52:
  
 
===== Debian / Ubuntu =====
 
===== Debian / Ubuntu =====
  apt-get install subversion monotone build-essential help2man diffstat texi2html texinfo cvs gawk cogito
+
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"
+
  
== Building OpenMoko with MokoMakefile ==
+
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.projects.openmoko.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
  
==Updating the environment==
+
note: 如果你想要從舊版的 2007.1 開始編譯,而不是使用新版的內容編譯Makefile,請從如下的內容開始編輯:
For easy maintenance of your build environment the following commands are available.
+
OPENMOKO_GENERATION = 2007.1
 +
#OPENMOKO_GENERATION = 2007.2
  
1 - To update the MokoMakefile to the latest version:
+
{{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]}}
  make update-makefile
+
  
2 - To make sure that any recent changes to the build directory structure have been applied:
+
3 - 設定環境:
  make setup  
+
make setup
 +
4 - 開始building。在程序開始之前,請查看Tips一節,取得Make multicore aware。你可能想要修改build/conf/local.conf 檔案到你的目的地 (emulation/chroot) 環境:
  
3 - To update the OpenMoko repository checkout and the MokoMakefile patches to the latest version:
+
make openmoko-devel-image
  make update
+
  
A quick way to rebuild a new image with the latest updates:
+
''Hint:'' 使用這個指令建立的映像檔可以在下面的路徑下找到{$OMDIR}/build/tmp/deploy/images/neo1973
  make update-makefile && make setup update openmoko-devel-image
+
  
==Build issues==
+
它將會設定在[[Building Openmoko from scratch|從scratch中建立Openmoko]]建議的路徑結構,它會下載所有需要的檔案(從正確的地方取得正確的版本),它將會立刻開始建立影像檔。
First, make sure that the problem is reproducible after running
+
  
make update-makefile && make setup && make update
+
一旦你做好了它,你可以選擇繼續使用MokoMakefile來啟始你拉下來的build,或者你可以進入build 目錄,並且手動執行bitbake指令。你可以自行選擇自己要的方法。
  
then run
+
==更新環境==
  
make clean-package-<foo>
+
為了要更為容易的維護你所建立的環境,下面的指令是很有用的。
  
(where you replace <foo> with the name of the package which is failing)
+
1 - 將MokoMakefile更新到最近的版本:
  
and finally
+
make update-makefile
  
make openmoko-devel-image
+
2 - 確認建立的目錄架構是否有任何新的變更:
  
With luck - you should now have images in your $omdir/build/tmp/deploy/glibc/images/neo1973/ directory.
+
make setup
You can then [[Flashing openmoko||flash these.]]
+
  
 +
3 - 要更新放置Openmoko原始碼及檔案的儲存位置及MokoMakefile patches到最近的版本:
  
If not, and 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].
+
make update
  
===Known MokoMakefile errors ===
+
以最後變更的項目來重建新映像檔的最快方法:
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)
+
make update-makefile && make setup update openmoko-devel-image
  
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:
+
make update-makefile && make setup && make update
  
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".
+
make clean-package-<foo>
  
===Fixes for distribution/environment-specific or isolated issues===
+
( <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.
+
最後,
 +
 
 +
make openmoko-devel-image
 +
 
 +
如果好運的話--你應該會在 $omdir/build/tmp/deploy/glibc/images/neo1973/ 目錄下找到映像檔。
 +
接著,你可以參考 [[Flashing the Neo 1973||Flashing openmoko更新這些內容]]
 +
 
 +
若是沒有找到映像檔的話,你可以在執行此一系列的命令列(包含更新及安裝操作)之後得到約三次的錯誤訊息,之後就可以將報告放到[http://wiki.openmoko.org/wiki/Development_resources#IRC IRC]中。
 +
 
 +
===已知的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"命名即可。
 +
 
 +
===修正套件/特定環境或獨立性問題===
 +
 
 +
暫時性或獨立的問題時,都可以在[[Talk:MokoMakefile|討論頁]]中找到相關的內容。當他們被修復之後,他們將會從那個頁面中被移除。
  
 
==Tips==
 
==Tips==
*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:
+
INHERIT += "rm_work"
  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.
+
將這行指令加到 local.conf (e.g. ~/moko/build/conf/local.conf)。 在相對應的軟體套件正確建立後,它將會移除T每一個映像檔中的/tmp/work/*/<package> 目錄。在10/16/07中,預設的情況下,它會出現在local.conf中。
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.
+
*如果你在monotone中遇到了如下的錯誤:
Edit the local.conf and add the following lines:
+
mtn: misuse: database /home/''username''/moko/OE.mtn is laid out according to an old schema
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.
+
接著,你須要昇級OE.mtn。在~/moko中使用以下的內容:
 +
# mtn --db OE.mtn db migrate
  
*For amd64 host users you need the patch from http://bugs.openembedded.org/show_bug.cgi?id=1765 to build db3-native
+
* 如果特定的套裝軟體,因為下載中斷或者是試圖移動原始碼及重建它而沒有進行建立映像檔的工作:
 +
rm sources/<package>*
 +
cd build
 +
. ../setup-env
 +
bitbake -crebuild <package>
  
* 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.
+
之後,你的BUILD可能必須重新運作一次。
  
* To prevent building tons of locales, add a line like this to local.conf:
+
*針對擁有多個CPU的使用者(或者dual-core)而言,這個小的patch對於加速建立映像檔的工作,會有些作用。
GLIBC_GENERATE_LOCALES = "en_US.UTF-8 nl_NL.UTF-8"
+
  
* To not build any binary locales at all, add this to local.conf:
+
編輯local.conf 並且加入下列指令列:
ENABLE_BINARY_LOCALE_GENERATION = "0"
+
PARALLEL_MAKE = "-j 4"
 +
BB_NUMBER_THREADS = "4"
  
* 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>.
+
變更PARALLEL_MAKE 及 BB_NUMBER_THREADS 值,以配合裝置。
  
[[User:Wurp]] will update this to be a little more comprehensible, but maybe it can help someone as-is in the meantime:
+
*針對amd64 主機的使用者,你必須從http://bugs.openembedded.org/show_bug.cgi?id=1765 修補到db3-native
* 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.
+
  
=== Useful commands ===
+
* 如果遇到與 qemu-native 軟體相關的錯誤,並且沒有從qemu編譯,你可以編輯 build/conf/local.conf 檔案,並且啟用ENABLE_BINARY_LOCALE_GENERATION = "0" 指令列來避免這個錯誤。
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
+
* 要避免locales過大,在local.conf中加入以下的指令:
  
; make openmoko-devel-tools : build statically-linked [[dfu-util]] and [[openocd]] binaries
+
GLIBC_GENERATE_LOCALES = "en_US.UTF-8 nl_NL.UTF-8"
  
; make openmoko-toolchain : builds [[toolchain]]
+
* 為了不要建立二位元的locale,請加入以下的內容到local.conf:
 +
ENABLE_BINARY_LOCALE_GENERATION = "0"
  
; make qemu : builds qemu, downloads flash images from official repository, flashes qemu emulated Neo1973 and runs emulator (see also [[OpenMoko under QEMU]]).
+
* 若你想要重建軟體的索引 (如,在編譯新版的軟體時)而不要建立 <code>openmoko-devel-image</code>,請執行run <code>make build-package-package-index</code>。
  
; make qemu-local : same as ''make qemu'', but uses locally built images instead of official ones.
+
[[User:Wurp]] 將會更新它,讓它變為易於理解的,但也許它同時也可以幫忙很多人。
 +
* 如果MokoMakefile經常在zlib的部份失敗,請找出它的二位元檔案,將它下載或手動加到原始的目錄下(有必要的話,建立.md5),並且重試。
  
; 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]].
+
=== 好用的指令列 ===
 +
以下是MokoMakefile中較有用的指令清單(actually make targets) 及針對這些指令的一些簡單的介紹。它應該在$OMDIR 中執行。
  
; make build-package-<package name> : buids ''<package name>'' package
+
; make openmoko-devel-image :建立完整的開發映像檔。
  
; make update-makefile : updates MokoMakefile
+
; make openmoko-devel-tools :建立靜態連結的[[dfu-util]]及[[openocd]]二位元檔
  
; make clean-package-<foo>: cleans the "<foo>" package
+
; make openmoko-toolchain : 建立[[toolchain]]
  
; make setup : to make sure that any recent changes to the build directory structure have been applied
+
; make qemu:建立qemu,從正式的下載點下載更新映像檔,更新qemu模擬的Neo1973並且執行模擬器(請參考[[Openmoko under QEMU]])。
 
+
; make update : to update the OpenMoko repository checkout and the MokoMakefile patches to the latest version
+
  
==Developing with MokoMakefile==
+
; make qemu-local :與''make qemu'',但是使用本機建立的映像檔,而不是官方的映像檔。
  
{{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}}
+
; make run-qemu : 使用usb 鍵盤執行qemu''(note: qemu 必須先建立好!)''。它主要是啟動預先定義選項的模擬器。如果你需要以其它的選項(如enable、telnet)來啟動它的話,請參考[[QEMU_command_line]]。
  
For the following explanations $OMDIR is the directory where there Makefile puts all the stuff.
+
; make build-package-<package name> : 建立 ''<package name>'' 套件
  
To make in-tree changes and have them built and used by qemu:
+
; make update-makefile : 更新MokoMakefile
  
  cd $OMDIR/openmoko
+
; make clean-package-<foo>: 清除 "<foo>" 套件
  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!
+
; make setup : 確認目錄結構中任何最近的更新是否被套用。
  
To build the changes and have them used by qemu:
+
; make update : 要更新Openmoko repository checkout and the MokoMakefile patches to the latest version
  
  make build-qemu
+
==使用MokoMakefile開發程式==
  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
+
{{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}}
  . ../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
+
  
Then continue with MokoMakefile usage.
+
針對下列的解釋 $OMDIR 是Makefile放置所有東西的位置。
  
If you want to add an application to your openmoko distribution, do this:
+
要讓in-tree 變更,並且讓它們可以被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:
+
cd $OMDIR/openmoko
  DESCRIPTION = "This is a cool package"
+
quilt new descriptive-patch-name.patch
  SECTION = "username/mycoolpackage"
+
quilt add trunk/src/name-of-file-to-change # do this for every file you are about to modify
  PV = "1"
+
...make the changes...
 
+
quilt refresh # this creates a file in $OMDIR/patches/openmoko-HEAD/ and updates the quilt series file there
  inherit autotools
+
 
 
+
Note: Do'''NOT'''  absolute paths as this confuses quilt and will get you a diff of the file against /dev/null!
  SRC_URI = "http://www.example.com/download/mycoolpackage-1.tar.gz"
+
 
 +
要建立變更內容,並且 讓他們可以被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 application ===
+
現在,執行
  
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://mokomakefile.projects.openmoko.org/
+
  
 +
[http://wiki.openmoko.org/wiki/Building_a_hello_world_application Hello World範例程式!]手冊可以在這裡下載。
  
[[Category:Software]]
+
==感謝狀==
[[Category:Applications]]
+
MokoMakefile被#openmoko開發人員所推崇:
[[Category:Application Developer]]
+
"因為某些原因,我無法手動安裝每個套件,讓(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/

Latest revision as of 15:12, 22 October 2008


MokoMakefile 是在設立Openmoko Build 環境時儲存所有工作的Makefile。藉由自動化安裝新的Openmoko build 環境的過程,它提供所有的開發人員相同的設定環境。

透過設定新的Openmoko build 環境設定過程,它提供現有的開發人員相同的設定,但一般較喜歡透過手動或個別的設定程序設定。

它會為BUILD 環境產物提供相同的重覆性,並且可以像BitBake script放入OpenEmbedded 般輕鬆維護,並且提供建立OpenEmbedded的標準化過程。

它不像是在Building Openmoko from scratch中所提到的手動設定過程。MokoMakefile並不會安裝任何程式到你的系統裡(即使是一般的使用者也可以使用)。

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 是在設立Openmoko Build環境時儲存所有工作的Makefile。藉由自動化安裝新的Openmoko build環境的過程,它提供所有的開發人員相同的設定環境。

透過設定新的Openmoko build環境設定過程,它提供為所有現有的開發人員相同的設定,但一般較喜歡透過手動或個別的設定程序設定。

它會為BUILD 環境產物提供相同的重覆性,並且可以像BitBake script放入OpenEmbedded 般輕鬆維護,並且提供建立OpenEmbedded的標準化過程。

它不像是在Building Openmoko from scratch中所提到的手動設定過程。MokiMakefile並不會安裝任何程式到你的系統裡(即使是一般的使用者也可以使用)。

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是由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中找到這個部份的說明。

建置Openmoko的需求

不論單獨或者是使用客製化的方法使用MokoMakefile來安裝Openmoko 環境,你必須符合某些需求,讓Openmoko build 可以成功運做:

  • RAM:build host 必須擁有至少512MB的RAM,及與它相同大小的swap空間。有一些套件像是busybox由OpenEmbedded建立,它是藉由先編譯所有的來源檔案,使它成為二進位檔,它會讓 gcc 增加為超過 300MB 的大小,因此,會導致沒有記憶體可以用做swap之用,造成無法預期編譯時間的狀況。

對於busybox,這個可以關閉它,但關閉它並不會表示它能被gcc最佳化。

  • 磁碟空間:你必須擁有12 GB的可用硬碟空間,供給Openmoko build使用(你可以參考下面的文節暸解怎麼減少所需磁碟空間用量)。
  • 時間:initial build 會花費至少5小時的時間 (在沒有最佳化的多處理器的 2GHz core2duo 硬體環境下)且,在更慢速度的環境下,它可能會花費更長的時間。

需求軟體

OpenEmbedded 用來控制系統的版本是monotone,它並不是由MokoMakefile下載及安裝的。如果你的套件並沒有提供套裝軟體,你可以從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.

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 。


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 
 # 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"

Building OpenMoko with MokoMakefile

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.projects.openmoko.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

With luck - you should now have images in your $omdir/build/tmp/deploy/glibc/images/neo1973/ directory. You can then |flash these.


If not, and 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.

Known MokoMakefile errors

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.

Tips

  • 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.

Useful commands

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 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 application

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/