Adding a new program(GeeXbox)(En&zh_TW)
时间:2006-08-21 来源:ming_nuaa
Adding a new program is really easy thanks to the use of our toolchain that do most of the hard stuff for you.
This way you don't even need to care about the compiler to use or compilation flags to be passed, neither about how to link against the uClibc library. Everything is done automatically.
Thus, simply follow the instructions from the Adding a new package page.
Here's an example for adding the nvtv program (yes, it already has been added ;-)
Build Rules
The following lines are taken from the build script of the nvtv package :
#!/bin/sh . config/options
It includes the GeeXboX toolchain configuration.
$SCRIPTS/build toolchain $SCRIPTS/build pciutils
Ensures that the toolchain and pciutils packages have been build before as they're required to build nvtv.
cd $BUILD/nvtv* ./configure --host=$TARGET_NAME \ --build=$HOST_NAME \ --without-x \ --without-gtk \ --with-wx-config=nowx \ --without-xbox \ --without-client-backend make
Configure the build script and starts the compilation.
It is highly recommended that you add each configure option to a single line (appended with a trailing \ character) as it's a patch-friendly representation.
Note the use of the $TARGET_NAME and $HOST_NAME variables to be passed to configure.
It has to be done for each package to tell it that we want to build against the uClibc.
You can have a look at the config/path file for a complete list of exported variables that can be passed to compilation scripts.
Install Rules
The following lines are taken from the install script of the nvtv package :
#!/bin/sh . config/options
It includes the GeeXboX toolchain configuration.
cp $BUILD/nvtv*/src/nvtv $INSTALL/usr/bin
This is where the compiled binary is finally copied to the ISO.
As GeeXboX is a minimalistic distribution, only the really required files are copied to the ISO.
There's no place for documentation files or man pages.
Call for Install
Your package install script has to be called from somewhere in order to take place in the ISO when you'll finally do the overall make command.
Most of the times, the ./scripts/gentree' is the right place to add such packages install scripts calls.
This file contains for example :
$SCRIPTS/install linux modules $1 $SCRIPTS/install alsa $1 $SCRIPTS/install tvout $1 ...
But you can also call for an install from other install scripts.
In our example, the nvtv package installation is done by the tvout package install script :
$SCRIPTS/install atitvout $SCRIPTS/install nvtv $SCRIPTS/install s3switch $SCRIPTS/install i810tvout
which is a meta-package dedicated to TV-Out gathering all tvout related packages.
In conclusion, whatever the place you call from the install script of your package, it has to be done somewhere in order to have it included it the resulting ISO.
Retrieved from "http://www.geexbox.org/wiki/index.php/Adding_a_new_program"新增一個新程式真的很容易,這得感謝我們提供了大部份較難工作的工具集給你使用。(新增一个应用程序是很容易的,因为我们提供的工具链代替你做了大部分较为繁琐的工作)
用工具集你甚至不需要考虑編譯器怎麼用、編譯旗標怎麼傳入,也不需要知道怎麼連結 uClibc 函式庫,每件事都會自動完成。
如此一來,只需簡單的照著 新增套件 頁的指示做即可。
底下是新增 nvtv 程式的範例(是的, 這其實已經在 GeeXboX 裡了)
Build 規則
底下兩行是從 nvtv 套件的 build script 取出來的:
#!/bin/sh . config/options
它引用了 GeeXboX 工具集設定,是非常重要的,所有 script 都要引用。
$SCRIPTS/build toolchain $SCRIPTS/build pciutils
在繼續建立 nvtv 之前,要求確認 toolchain 及 pciutils 套件已經建立。
cd $BUILD/nvtv* ./configure --host=$TARGET_NAME \ --build=$HOST_NAME \ --without-x \ --without-gtk \ --with-wx-config=nowx \ --without-xbox \ --without-client-backend make
設定 build script 需要的組態,並開始編譯。
高度建議你將每一個 configure 選項單獨成一行,行末加 \ 字元即可令其視為一行,這樣一來在補丁時會較容易閱讀。
注意 $TARGET_NAME 與 $HOST_NAME 這兩個變數用來傳入 configure。
對每一個套件,這用來告訴它我們要在 uClibc 下建立套件。
你可以瞧瞧 config/path 檔,裡頭有完整的匯出變數列表可以用來傳入編譯 scripts 中。
Install 規則
底下兩行是從 nvtv 套件的 build script 取出來的:
#!/bin/sh . config/options
它引用了 GeeXboX 工具集設定。
cp $BUILD/nvtv*/src/nvtv $INSTALL/usr/bin
這是編譯好的二進位檔最後要複製到 ISO 檔的地方。
因為 GeeXboX 是一個最小化的散布,只有必須的檔案才複製到 ISO 檔中,所以不要放文件檔或手冊頁。 (下面的叫用我们一般称为调用)
叫用 install
套件裡的 install script 必須從某處叫用以便在完成 make 命令之後,將所產生的二進位檔置入 ISO 檔。
大體而言, ./scripts/gentree' 正是這個將此套件加入叫用 install script 的地方。
舉例來說,這個檔包含下列片斷:
$SCRIPTS/install linux modules $1 $SCRIPTS/install alsa $1 $SCRIPTS/install tvout $1 ...
此外,你也可以從別的 install scripts 中叫用。
在我們的例子中,nvtv 套件的安裝是在 tvout 套件的 install script 中叫用的:
$SCRIPTS/install atitvout $SCRIPTS/install nvtv $SCRIPTS/install s3switch $SCRIPTS/install i810tvout
上面這四個都屬於 tvout 相關套件。
最後,不管你從何處叫用你的套件的 install script,它必須被叫用。如此才能將之加入 ISO 檔中。