Cross-Compiling Mozilla
出典: MDC
クロスコンパイルに関する一般的な情報は、The GNU configure and build system というドキュメントの Cross Compilation Tools の章を参照してください。
If you are trying to compile 32-bit Firefox on a 64-bit Linux OS, you don't need to do a full cross-compile... see these simpler instructions.
目次 |
[編集] クロスコンパイル用のビルド環境を作る
このガイドには、クロスコンパイル用のビルド環境を作るために基本的なことは含まれていません。私はこれで出来ましたが、環境によって手順が違うかもしれません。(「どこで○○を手に入れられるのか」「××が動かない」などの質問には答えられません。)
以下の定義が、例の中で使われています:
xtarget_arch | 目的のシステム名 (例えば i686-linux) |
xprefix | クロスコンパイルのディレクトリ階層 (例えば /usr/sparc-linux) |
PATH に ${xprefix}/bin を追加してください。
[編集] binutils をクロスコンパイルする
binutils をダウンロードし、ビルド済みのライブラリをインストールするのを簡単にするために、パッチ binutils-cross-libpath.patch を当てます。以下のコマンドを使って configure を実行します:
env CROSS_LIB_PATH="${xprefix}/${xtarget_arch}/lib:${xprefix}/${xtarget_arch}/usr/lib" ./configure --prefix=${xprefix} --target=${xtarget_arch}
パッケージをビルドして、インストールします。
[編集] ターゲットシステムのヘッダとライブラリをインストールする
GCC と binutils はシステムヘッダとライブラリを ${xprefix}/${xtarget_arch} にあるものとして探します。よって、これらのファイルはターゲットのシステムからコピーして、ディレクトリの構造を変えないように必要なスクリプトを変更する必要があります。また、X11 のライブラリとインクルードディレクトリも必要です。
/usr/lib/libc.so ファイル (実際はスクリプト) を、注意深く変更しなくてはなりません。もしもターゲットのシステムに rpms がインストールしてあり、かつ rpm がビルド用システムにインストールされている場合、この ショートカットスクリプト を利用して、rpm2cpio を使って rpms を $xprefix/$xtarget_arch へとインストールできます。
[編集] gcc をクロスコンパイルする
gcc をダウンロードし、次のコマンドで configure を実行します:
./configure --prefix=${xprefix} --with-gnu-ld --with-gnu-as --target=${xtarget_arch} --disable-nls --enable-languages=c++,objc
パッケージをビルドして、インストールします。
[編集] 確認
ここまででクロスコンパイル用の環境は整ったはずです。ちゃんと動くかどうか確認してください。Hello World から初めて、基本的な X11 アプリケーションを作ってみてください。
ほとんどのパッケージは ./configure --target=${xtarget_arch} で十分ビルドできます。
出来ない場合は、ビルド用のツールを明示的に設定する必要があるかもしれません。
env CC=${xtarget_arch}-gcc CXX=${xtarget_arch}-g++ LD=${xtarget_arch}-ld AS=${xtarget_arch}-as ./configure --prefix=${xprefix} --target=${xtarget_arch}
[編集] glib、libIDL、gtk+ をクロスコンパイルする
これらのビルド済みパッケージをインストールしていなかった場合のみ必要なステップです。上記のステップを利用して、これらをビルド、インストールします。
[編集] トカゲをクロスコンパイルする
上記ステップの順を追って、正しくクロスコンパイル用の環境を整えたとすれば、Mozilla のクロスコンパイルは簡単です。ただし、NSS はクロスコンパイルに正しく対応していません (bug 104541)。
重要なのは、--target=${xtarget_arch} が configure に渡されたとき、configure はコンパイラのツールチェインを ${xtarget_arch}-TOOL (TOOL の部分には gcc、g++、runlib など) にあるとして動作する、ということです。
configure に以下の環境変数を渡す必要があります:
CROSS_COMPILE=1 HOST_LIBIDL_CONFIG=/path/to/build/system/libIDL-config GLIB_CONFIG=/path/to/target/system/glib-config GTK_CONFIG=/path/to/target/system/gtk-config LIBIDL_CONFIG=/path/to/target/system/libIDL-config
そして、以下をコマンドラインの引数として configure に渡します:
--target=${xtarget_arch}
--x-includes=/path/to/target/system/x/includedir
--x-libraries=/path/to/target/system/x/libdir
以下は、mipsEEel-linux をターゲットとした、クロスコンパイル用の mozconfig ファイルの一例です:
# sh # Build configuration script # # See http://www.mozilla.org/build/unix.html for build instructions. # CROSS_COMPILE=1 GLIB_CONFIG=/usr/mipsEEel-linux/mipsEEel-linux/usr/bin/glib-config GTK_CONFIG=/usr/mipsEEel-linux/mipsEEel-linux/usr/bin/gtk-config LIBIDL_CONFIG=/usr/mipsEEel-linux/mipsEEel-linux/usr/bin/libIDL-config HOST_LIBIDL_CONFIG=/usr/bin/libIDL-config ac_add_options --prefix=/usr/mipsEEel-linux ac_add_options --target=mipsEEel-linux ac_add_options --x-includes=/usr/mipsEEel-linux/mipsEEel-linux/usr/X11R6/include ac_add_options --x-libraries=/usr/mipsEEel-linux/mipsEEel-linux/usr/X11R6/lib # Options for 'configure' (same as command-line options). # all are listed so that one can manually tweak this config file. ac_add_options --enable-mathml ac_add_options --enable-svg ac_add_options --enable-extensions #ac_add_options --enable-crypto ac_add_options --enable-logrefcnt ac_add_options --without-system-nspr ac_add_options --without-system-zlib ac_add_options --without-system-jpeg ac_add_options --without-system-png ac_add_options --without-system-mng
[編集] 原文書の情報
- 著者: Chris Seawood
- 最終更新日: June 22, 2002
- 著作権: Portions of this content are © 1998–2007 by individual mozilla.org contributors; content available under a Creative Commons license | 詳細