bugmake - Bugs: bug #52209, Support for ifeq function


bug #52209: Support for ifeq function

Submitted by:  None
Submitted on:  Wed 11 Oct 2017 07:59:03 PM UTC  
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  None Operating System:  Any
Fixed Release:  None Triage Status:  None

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Sun 15 Oct 2017 12:59:01 PM UTC, comment #4:

Patch added.

The rational is that this is an operation needed to support rebuilding of targets when recipes change.

Support for rebuilding of targets on recipe change requires the recipe of every target to be expanded and compared with its previously used recipe. These happens on every build, even if all targets are up-to-date, so can contribute a significant amount to the processing time of a large mostly up-to-date project. A more efficient way to compare previous and current recipes than that in the first post would help reduce processing time.

I have only created the $(ifeq ...) function and added nothing to .FEATURES, or test suite, or documentation. I can do this if the patch is accepted.

(file #42159)

Rob <robw_ty>
Thu 12 Oct 2017 06:26:11 AM UTC, comment #3:

Thanks Paul for dealing with this so quickly.

For the benefit of clarity (and the poster of comment #1), the parallel between what I propose and the existing preprocessor version is deliberate as I value consistency in design.

There has been an eq function in the source code for a long time, but it is disabled behind an experimental flag. I think the problem is that eq introduces a fixed idea of a true result as it always returns 1 for true. Introducing eq would effectively change the representation of true from non-empty to 1 on a conceptual level - and conceptual changes are always risky.

The ifeq function proposal is an attempt to allow support for testing equality without needing to change the concept of true. It also allows the same flexibility of the existing $(if..) function where an action could be taken on the result, for example to generate an error if strings don't match:

$(ifeq $(first),$(second),,$(error something broke))

I will try and contribute a patch, but I don't know when I'll have time and I wanted to make an enhancement request in the meantime.

To the poster of comment #1. Yes, I posted anonymously for reasons I don't need to explain here. It's unfortunate you think that makes me an idiot and my contribution only worth mocking and I'm very glad that Paul never thinks that way. I'm not keen on sharing my email address with the world, and your response makes me want to do that even less. This is not a point-scoring teenage forum and I'm only interested in talking technical, but after taking your own advice, if you still feel the need to insult me personally my name is below.


Thu 12 Oct 2017 03:04:18 AM UTC, comment #2:

Those (ifeq, ifneq) are not functions, they're preprocessor conditionals. Only $(if ...) (and $(or ...) and $(and ...)) are functions.

Paul D. Smith <psmith>
Project Administrator
Wed 11 Oct 2017 09:40:19 PM UTC, comment #1:

Ummm ... is this some kind of meta-April-fools joke, offset by 6 months?

On the off chance that it's serious I refer you to the descriptions of the (yes) $(ifeq ...), $(ifneq ...), and $(if ...) functions in https://www.gnu.org/software/make/manual/make.html#Conditional-Syntax

Sorry, I wouldn't normally poke fun at someone online but you're anonymous anyway so what the heck.

Wed 11 Oct 2017 07:59:03 PM UTC, original submission:

My makefiles frequently need to check for equality of two string. I'm doing this during expansion of recipes so this happens many time during every build.

Currently I need to do this:

$(if $(findstring X$(second),$(findstring X$(first),X$(second))),same,different)

this looks clumsy and the strings can be very long (10s of kbytes) so is probably inefficient as there need to be two findstrings.

Support for an ifeq function would be useful. Something like:

$(ifeq $(first),$(second),same,different)

This would allow different actions depend on the whether the string are equal. It could also be used to generate boolean results as follows:

$(ifeq $(first),$(second),1)

where a non-empty result is true and an empty is false.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #42159:  function.c.patch added by robw_ty (2KiB - text/x-patch - Add support for $(ifeq ...) function)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by robw_ty (Updated the item)
  • -email is unavailable- added by psmith (Posted a comment)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-10-15 robw_ty Attached File- => Added function.c.patch, #42159

    Back to the top

    Powered by Savane 3.3