Bug 6961 - FR: macros with parameter
Summary: FR: macros with parameter
Status: NEW
Alias: None
Product: Sisyphus
Classification: Development
Component: rpm-build (show other bugs)
Version: unstable
Hardware: all Linux
: P3 enhancement
Assignee: placeholder@altlinux.org
QA Contact: qa-sisyphus
URL:
Keywords:
: 6963 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-05-29 13:49 MSD by Evgeny Sinelnikov
Modified: 2020-03-24 10:52 MSK (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Evgeny Sinelnikov 2005-05-29 13:49:03 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:43 MSD
*** Bug 6963 has been marked as a duplicate of this bug. ***
Comment 2 Mikhail Gusarov 2008-06-13 13:00:39 MSD