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

 
 

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

Submitter:  None
Submitted:  Tue 17 Jan 2017 06:59:36 AM UTC
   
 
Severity:  3 - Normal Item Group:  Documentation
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  None Operating System:  Any
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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>
Group 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 GNUMAKE_VERSION
$(error "Sorry, you are not running GNU make. I must stop...)
endif


"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>
Group 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 Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-04-16 psmith StatusNone Not A Bug
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code