Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to work my way around with the BuildPrereq flag in the spec files. I want a few pre-requisites to be included if the OS is of a particular version. something like

if os == fedora 4
 BuildPrereq >= apr0.9

if os == feodra 10
 BuildPrereq >= apr2.0

Is there any way to achieve the above ? Also I would like to hear some alternatives on this. The problem being i have a section of the code which is not required to be compiled on a few versions of OS. So i am looking at mixing conditional compilation and the above.


share|improve this question
up vote 3 down vote accepted

To translate what you wrote directly into specfile macros:

%if 0%{?fedora} == 4
BuildPrereq >= apr0.9
%if 0%{?fedora} == 10
BuildPrereq >= apr2.0

You could probably change the first %endif to an %else but I wanted to keep my rewrite as similar as possible in case there are other circumstances involved.

If you want to support versions of fedora between fc4 and f10 or later, you can use >= and <= as well. If you care about RHEL, there's a %{rhel} that evaluates as 4 for RHEL4 and 5 for RHEL5.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.