mattintosh note

どこかのエンジニアモドキの備忘録

Mavericks で jhbuild(gtk-osx-build)

gtk-osx-build を使って Mavericks に GTK+ 環境を構築する。

リポジトリを複製してセットアップ。フレームワーク系のファイルは必要ないので消す。

git clone https://github.com/jralls/gtk-osx-build.git
cd gtk-osx-build
./gtk-osx-build-setup.sh
rm ~/.jhbuild-*fw*

jhbuild コマンドは $HOME/.local/bin にインストールされるので、シェルの設定ファイルにエイリアスなどを追加しておく。PATH~/.jhbuild-custom の中で再設定するのでとりあえず $HOME/.local/bin/jhbuild が呼べればそれでいい。リストの表示がいつも見づらいのでソートするようにしておく。

jhbuild ()
(
  PATH=\
$HOME/.local/bin:\
/opt/gtk/bin:/opt/gtk/sbin:\
/usr/bin:/bin:/usr/sbin:/sbin

  case $1 in
  (list)
    command jhbuild "$@" \
    | sort \
    | rs -tez
    return
  ;;
  esac

  command jhbuild "$@"
)

~/.jhbuild-custom を書き換える。ターゲット判定の部分が古かったので多少変更。

_target = None;
if   _osx_version >= 9.0:
    _target = "10.9"
elif _osx_version >= 8.0:
    _target = "10.8"
elif _osx_version >= 7.0:
    _target = "10.7"
elif _osx_version >= 6.0:
    _target = "10.6"
elif _osx_version >= 5.0:
    _target = "10.5"
elif _osx_version >= 4.0:
    _target = "10.4"

モジュールセットはローカルのものを使う。1回で最後までビルドするのは難しいので ccache を併用。デフォルトのインストール先 ~/gtk はあまり好きじゃないのでインストールは /opt/gtk へ。何故か cups のビルドをしようとする(しかもダウンロードサーバエラーで失敗する)のでスキップ項目に追加。

moduleset    = "/usr/local/src/repos/gtk-osx-build/modulesets-stable/gtk-osx.modules"
prefix       = "/opt/gtk"
checkoutroot = "/opt/gtk/var/source"

os.environ["CC"]  = "gcc"
os.environ["CXX"] = "g++"
os.environ["PATH"] = ":".join([
    os.path.expanduser("~/.local/bin"),
    "/opt/local/libexec/ccache",
    "/opt/gtk/bin:/opt/gtk/sbin",
    "/usr/bin:/bin:/usr/sbin:/sbin",
])
skip = [
    "cups",
    "readline",
]

ディレクトリの初期化。

sudo mkdir -p /opt/gtk
sudo chown -R 501:20 /opt/gtk

前は bootstrap ターゲットに --ignore-system っていうオプションがあった気がするんだけど無くなった?システムの Python は libxml2 モジュールを持っていないので jhbuild で新しく導入しておく。

jhbuild bootstrap
jhbuild build python
jhbuild build meta-gtk-osx-bootstrap
jhbuild build meta-gtk-osx-core
jhbuild build meta-gtk-osx-gtkmm
jhbuild build meta-gtk-osx-themes
jhbuild build gtk-engines
jhbuild build shared-mime-info
jhbuild build lcms