bugmake - Bugs: bug #50062, Variable needed to check that...

 
 

bug #50062: Variable needed to check that Makefile is run by GNU make?

Submitted by:  None
Submitted on:  Tue 17 Jan 2017 06:59:36 AM UTC  
 
Severity: 3 - NormalItem Group: Documentation
Status: Not A BugPrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: NoneOperating System: Any
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Sun 16 Apr 2017 06:21:47 PM UTC, comment #4:

I'm closing this as I don't think there's anything we can do about it. If anyone has any suggestions add a comment and I can reopen if warranted.

Paul D. Smith <psmith>
Project Administrator
Tue 14 Feb 2017 12:40:33 PM UTC, comment #3:

If you really need some features only supported by GNU Make, why not rename this makefile to "GNUmakfile"?

Ben Feng <fyb>
Tue 17 Jan 2017 04:56:52 PM UTC, comment #2:

Similarly, the $(error ...) function and indeed functions like this themselves are features only found in GNU make... so even if you were using some other implementation of make that happened to support "ifndef" the same way GNU make did, it could very well simply treat that function call as a variable reference, to a non-existent variable which expands to the empty string, and just ignore the entire check and continue on its way.

Basically, you're trying to use GNU make-only constructs to test whether you're running GNU make and fail if not. That is a catch-22.

Paul D. Smith <psmith>
Project Administrator
Tue 17 Jan 2017 04:54:25 PM UTC, comment #1:

I don't really know of any way to determine whether or not you're running a particular version of make, in a makefile portable enough that it would provide useful output if you weren't using that version of make.

For instance in your example:

"ifndef" is a GNU make-specific capability itself: I know of no other variant of make that supports this. So, if you weren't using GNU make you'd get a syntax error from your version of make as soon as you hit that line, regardless of whether GNUMAKE_VERSION was defined or not.

Paul D. Smith <psmith>
Project Administrator
Tue 17 Jan 2017 06:59:36 AM UTC, original submission:

When one wants to check that it is really GNU make that is run for a given Makefile, the standard solution is to
rely on $(shell make --version), or to read $(MAKE_VERSION). See e.g. http://unix.stackexchange.com/questions/218692

The second solution is simpler and more efficient but nothing prevents other, non-GNU, make's to support a variable called MAKE_VERSION.

A solution would be to have another variable, e.g. $(GNUMAKE_VERSION), that could be just a synonym for $(MAKE_VERSION), but that would probably never be used by other make's.

Then one would not even read it, just check that it is defined:

ifndef GNUMAKE_VERSION
$(error "Sorry, you are not running GNU make. I must stop...)
endif

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by fyb (Posted a comment)
  • -unavailable- added by psmith (Posted a comment)
  •  

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

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 16 Apr 2017 06:21:47 PM UTCpsmithStatusNone=>Not A Bug
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1