Re: Re: %if

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/17/06, Frank Cusack <fcusack@xxxxxxxxxxx> wrote:

Please quote any URL, page#, or spec file where you see '%ifdef' used or
documented.  You're probably trying to use a SuSE-specific macro on a
non-SuSE system.


Just for historical accuracy, here's a reference to %ifdef in
/usr/lib/rpm/macros:

#==============================================================================
# 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 %{defined with_...}
%with()         %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
%without()      %{expand:%%{?with_%{1}:0}%%{!?with_%{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 (spec file):
#
# (at the beginning)
# %bcond_with extra_fonts
# %bcond_without static
# (and later)
# %if %{with extra_fonts}
# ...
# %else
# ...
# %endif
# %if ! %{with static}
# ...
# %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}}

The issue of whether to add %ifdef was discussed at the time build conditionals
were added to rpm (PLD invented the concept).

It would be possible to create a %ifdef rather easily, but there are other, and
much harder problems to solve, because %if is not a macro, but rather a section
marker, that is parsed and handled entirely differently than macros.

Adding a %ifdef construct would only complicate matters because of two
different parsers imho.

The still harder problem is that
   Prefix:
parsing is going to add a definition for
   %prefix
which is going to be pushed on top of whatever %prefix is configured or
passed from the CLI.

Personally, I solve the whole problem of unifying %prefix and %_prefix
values by doing

   Prefix: /usr
   %define _prefix %{prefix}

on a per-specfile basis, which achieves the same end goal of unifying
%prefix and %_prefix values without the fuss and muss of testing for
values and existence.

73 de Jeff

_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/rpm-list

[Index of Archives]     [RPM Ecosystem]     [Linux Kernel]     [Red Hat Install]     [PAM]     [Red Hat Watch]     [Red Hat Development]     [Red Hat]     [Gimp]     [Yosemite News]     [IETF Discussion]

  Powered by Linux