| 1 | = SPEC の書き方 Tips = |
| 2 | |
| 3 | == with/without を使った条件分岐 == |
| 4 | |
| 5 | bcond_with または bcond_without を使うことで、条件ビルドの spec への記述が書きやすくなり、 |
| 6 | rpmbuild への --with/--without スイッチで機能の追加削除の選択ができるようになります。 |
| 7 | |
| 8 | * {{{%bcond_with foo}}} は rpmbuild で --with-foo が指定されていた場合に with_foo が定義される。 |
| 9 | * {{{%bcond_without foo}}} は rpmbuild で --without-foo が指定されて'''いない'''限り with_foo が定義される。 |
| 10 | |
| 11 | 例:[[BR]] |
| 12 | 以下の例ではデフォルトでビルドした場合は bar のみが定義されます。 |
| 13 | {{{ |
| 14 | %bcond_with foo |
| 15 | %bcond_without bar |
| 16 | |
| 17 | %if %{with foo} |
| 18 | BuildRequires: foo-devel |
| 19 | %endif |
| 20 | %if %{with bar} |
| 21 | BuildRequires: bar-devel |
| 22 | %endif |
| 23 | |
| 24 | %configure .... \ |
| 25 | %{?with_foo:--with-foo} \ |
| 26 | %{?with_bar:--with-bar} |
| 27 | |
| 28 | }}} |
| 29 | |