Makefile that calls itself without hardcoding file name

If you have to call makefile multiple times. And you don’t want to hardcode file name you can make it following way:

makefilelocation = $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))

        $(warning "I will call myself")
        $(MAKE) -f $(makefilelocation) message

        $(warning "Hello message")

Remember that targets are indented with tabs :)

Then, just call it following way:

make -f makefile.test

or, if you put the file inside makefile, just call it like this