help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

not sure about value of "$(lastword $(MAKEFILE_LIST))" in this example


From: Robert P. J. Day
Subject: not sure about value of "$(lastword $(MAKEFILE_LIST))" in this example
Date: Tue, 15 Oct 2019 11:59:23 -0400 (EDT)
User-agent: Alpine 2.21 (LFD 202 2017-01-01)

  a Makefile i was handed (that lives two subdirs down in the total
code base, and which is meant to be run after cd'ing down to its
containing directory), contains early on:

  THIS_FILE := $(lastword $(MAKEFILE_LIST))

  include $(TOP_ROOT)/config.include
  include $(OTHER_DIR)/config.include
  include config.include

now, since this makefile is invoked from that very directory with:

  $ make <target>

i checked and, unsurprisingly, the variable THIS_FILE contains the
string "Makefile". so far, so good.

  the makefile is slightly complicated in that it's a dual-purpose
makefile, being invoked either natively or running a docker container
that invokes targets from the same makefile. again, no big deal.

  what i find odd is that a number of recipes which turn around and
re-invoke make explicitly reference that THIS_FILE variable as
follows:

  @$(MAKE) -f $(THIS_FILE) version

i'm not sure what to make of this since there is only one Makefile in
play in this directory, and the docker container has its working
directory set to this directory, and all of the targets being invoked
are defined in the same Makefile.

  so, while adding "-f $(THIS_FILE)" to those make commands doesn't
hurt, i can't see what value that adds. am i missing something subtle
regarding that variable? i realize that bringing docker containers
into it does complicate things, but as long as all work is done from
the same directory, is that "-f" option really necessary?

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                         http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



reply via email to

[Prev in Thread] Current Thread [Next in Thread]