wiki:MakingRPM/Tips

Version 1 (modified by daisuke, 15 years ago) (diff)

--

SPEC の書き方 Tips

with/without を使った条件分岐

bcond_with または bcond_without を使うことで、条件ビルドの spec への記述が書きやすくなり、 rpmbuild への --with/--without スイッチで機能の追加削除の選択ができるようになります。

  • %bcond_with foo は rpmbuild で --with-foo が指定されていた場合に with_foo が定義される。
  • %bcond_without foo は rpmbuild で --without-foo が指定されていない限り with_foo が定義される。

例:
以下の例ではデフォルトでビルドした場合は 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}