Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7664899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:25:18+00:00 2026-05-31T14:25:18+00:00

How do you perform a logical OR using make’s ifeq operator? e.g., I have

  • 0

How do you perform a logical OR using make’s ifeq operator?

e.g., I have (simplified):

ifeq ($(GCC_MINOR), 4)
    CFLAGS += -fno-strict-overflow
endif
ifeq ($(GCC_MINOR), 5)
    CFLAGS += -fno-strict-overflow
endif

but would like to consolidate these lines.

(yes, yes, autotools, configure, etc etc; too heavy-handed for the current situation, would like to keep everything within the Makefile here)

[logical opposite of this question: How to Use of Multiple condition in 'ifeq' statement ]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:25:19+00:00Added an answer on May 31, 2026 at 2:25 pm

    As found on the mailing list archive,

    • http://osdir.com/ml/gnu.make.windows/2004-03/msg00063.html
    • http://osdir.com/ml/gnu.make.general/2005-10/msg00064.html

    one can use the filter function.

    For example

    ifeq ($(GCC_MINOR),$(filter $(GCC_MINOR),4 5))
    

    filter X, A B will return those of A,B that are equal to X.
    Note, while this is not relevant in the above example, this is a XOR operation. I.e. if you instead have something like:

    ifeq (4, $(filter 4, $(VAR1) $(VAR2)))
    

    And then do e.g. make VAR1=4 VAR2=4, the filter will return 4 4, which is not equal to 4.

    A variation that performs an OR operation instead is:

    ifneq (,$(filter $(GCC_MINOR),4 5))
    

    where a negative comparison against an empty string is used instead (filter will return en empty string if GCC_MINOR doesn’t match the arguments). Using the VAR1/VAR2 example it would look like this:

    ifneq (, $(filter 4, $(VAR1) $(VAR2)))
    

    The downside to those methods is that you have to be sure that these arguments will always be single words. For example, if VAR1 is 4 foo, the filter result is still 4, and the ifneq expression is still true. If VAR1 is 4 5, the filter result is 4 5 and the ifneq expression is true.

    One easy alternative is to just put the same operation in both the ifeq and else ifeq branch, e.g. like this:

    ifeq ($(GCC_MINOR),4)
        @echo Supported version
    else ifeq ($(GCC_MINOR),5)
        @echo Supported version
    else
        @echo Unsupported version
    endif
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL query I have to perform based on Operator Input. I
I have a problem using data from a tab delimited data file imported with
I have a business model with many classes in, some logical entities within this
Like VB has operators AndAlso and OrElse , that perform short-circuiting logical conjunction, where
I have developed a WordPress plugin which needs to perform additional processing when a
I have a rather complex logical query I'm trying to execute. Essentially there are
I have a Session which I am using to hold items in a form
This is a general question. Using an example below, suppose that I have a
Two related questions in one: Can Clojure's core.logic module perform arithmetic, logical comparison, etc,
I perform an AJAX request to a PHP script in JavaScript and by using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.