Search code examples
makefile

Getting the name of the makefile from the makefile


How to get the name of the makefile in the makefile?

Thanks.

Note:

I would need that because I would like my makefile to call itself, but the makefile is not called Makefile, so I'd like to write something like this:

target:
    $(MAKE) -f $(MAKEFILENAME) other_target

Solution

  • location = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
    WHERE_ART_THOU := $(location)
    $(warning $(WHERE_ART_THOU))
    

    I also believe this is GNU make-specific, but I'm not too sure.