Bug 6963

Summary: FR: macros with parameter
Product: Sisyphus Reporter: Evgeny Sinelnikov <sin>
Component: rpm-buildAssignee: placeholder <placeholder>
Status: CLOSED DUPLICATE QA Contact: qa-sisyphus
Severity: enhancement    
Priority: P3 CC: arseny, glebfm, imz, ldv, placeholder, vt
Version: unstable   
Hardware: all   
OS: Linux   

Description Evgeny Sinelnikov 2005-05-29 20:18:39 MSD
I want to propose next improve for macroses like
%def_with, %def_enable, etc to using parameters

%define def_with_param() %{expand:%%{!?_with_%{1}: %%{!?_without_%{1}: %%{?2:
%%global _with_param_%{1} %{2}} %%global _with_%{1} --with-%{1}}}}

%define subst_with_param()
%{expand:%%{?_with_%{1}:%%{_with_%{1}}%%{?_with_param_%{1}:=%%{_with_param_%{1}}}}}
%{expand:%%{?_without_%{1}:%%{_without_%{1}}%%{?_without_param_%{1}:=%%{_without_param_%{1}}}}}

%define if_with_param() %if %{expand:%%{?_with_%{1}: %%{?2:%%(if [
"%%{_with_param_%{1}}" == "%{2}" ]; then echo 1; else echo 0;
fi)}%%{!?2:1}}%%{!?_with_%{1}:0}}

Steps to Reproduce:
1.
%def_with debug yes

2.
%if_with debug yes 
%endif

3.
%configure %{subst_with debug}

Actual Results:  
rpm -bE tes.spec:
.........
  ./configure --build=pentium4-alt-linux --host=pentium4-alt-linux \
        --prefix=/usr \
        --exec-prefix=/usr \
        --bindir=/usr/bin \
        --sbindir=/usr/sbin \
        --sysconfdir=/etc \
        --datadir=/usr/share \
        --includedir=/usr/include \
        --libdir=/usr/lib \
        --libexecdir=/usr/lib \
        --localstatedir=/var/lib \
        --sharedstatedir=/usr/com \
        --mandir=/usr/share/man \
        --infodir=/usr/share/info \
        --without-included-gettext --with-debug
.........

Expected Results:  
rpm -bE tes.spec:
.........
  ./configure --build=pentium4-alt-linux --host=pentium4-alt-linux \
        --prefix=/usr \
        --exec-prefix=/usr \
        --bindir=/usr/bin \
        --sbindir=/usr/sbin \
        --sysconfdir=/etc \
        --datadir=/usr/share \
        --includedir=/usr/include \
        --libdir=/usr/lib \
        --libexecdir=/usr/lib \
        --localstatedir=/var/lib \
        --sharedstatedir=/usr/com \
        --mandir=/usr/share/man \
        --infodir=/usr/share/info \
        --without-included-gettext --with-debug=yes
.........
Comment 1 Dmitry V. Levin 2005-06-16 22:03:42 MSD

*** This bug has been marked as a duplicate of 6961 ***