Version 5 (modified by daisuke, 10 years ago) (diff) |
---|
bcond_with または bcond_without を使うことで、条件ビルドの spec への記述が書きやすくなり、 rpmbuild への --with/--without スイッチで機能の追加削除の選択ができるようになります。
例:
以下の例ではデフォルトでビルドした場合は bar のみが定義されます。
%bcond_with foo %bcond_without bar %if %{with foo} BuildRequires: foo-devel %endif %if %{with bar} BuildRequires: bar-devel %endif %configure .... \ %{?with_foo:--with-foo} \ %{?with_bar:--with-bar}
%if における条件式内の論理積と論理和は、 それぞれ &&, || を用います。 シェルスクリプトの if 文における条件式内の論理積 -a、 論理和 -o と間違って使いかねないので、注意が必要です。
%if %{?_dist_release} == "vl5" || %{?_dist_release} == "vl6" Requires: mesa-libGL Requires(post): xorg-x11-devel Requires(post): mesa-libGL-devel %endif %if %{?_dist_release} == "vl4" Requires: XOrg-gl Requires(post): XOrg-devel Requires(post): XOrg-gl-devel %endif %if "%{?_dist_release}" >= "vl7" BuildRequires: vala-devel >= 0.18 %endif