From 617b726692594a70e0e5aa41fefdbc9766f1c547 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 20 May 2003 21:26:28 +0000 Subject: [PATCH] - new macros: %defined, %undefined, %ifdef, %ifndef, %bcond_with and %bcond_without (last two from wiget, others from jbj) Changed files: rpm.macros -> 1.116 --- rpm.macros | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/rpm.macros b/rpm.macros index 66f9c4b..a247fc6 100644 --- a/rpm.macros +++ b/rpm.macros @@ -93,6 +93,49 @@ --infodir=%{_infodir} \ } +# ------------------------------------------------------------------------ +# Conditional build stuff. + +# Check if symbol is defined. +# Example usage: %if %{defined with_foo} && %{undefined with_bar} ... +%defined() %{expand:%%{?%{1}:1}%%{!?%{1}:0}} +%undefined() %{expand:%%{?%{1}:0}%%{!?%{1}:1}} + +# Shorthand for %if %{defined ...} +%ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}} +%ifndef() %if %{expand:%%{?%{1}:0}%%{!?%{1}:1}} + +# Handle conditional builds. %bcond_with is for case when feature is +# default off and needs to be activated with --with ... command line +# switch. %bcond_without is for the dual case. +# +# %bcond_with foo defines symbol with_foo if --with foo was specified on +# command line. +# %bcond_without foo defines symbol with_foo if --without foo was *not* +# specified on command line. +# +# For example: +# +# %bcond_with extra_fonts +# %bcond_without static +# %ifdef with_extra_fonts +# ... +# %endif +# %ifdef with_static +# ... +# %endif +# %{?with_static: ... } +# %{!?with_static: ... } +# %{?with_extra_fonts: ... } +# %{!?with_extra_fonts: ... } +# +# The bottom line: never use without_foo, _with_foo nor _without_foo, only +# with_foo. This way changing default set of bconds for given spec is just +# a matter of changing single line in it and syntax is more readable. +%bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}} +%bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}} +# ------------------------------------------------------------------------ + # Location of autoconf macros %_aclocaldir %(aclocal --print-ac-dir) -- 2.44.0