I am reading a makefile for a Qt-created project that has the following:
{backend}.cpp{release\}.obj::
$(CXX) -c $(CXXFLAGS) $(INCPATH) -Forelease\ @<<
$<
<<
(above code is using \t for recipe and is as written in makefile)
Both the rule and the recipe confuse me.
I'll start with {backend}
in the rule. Obviously the same confusion for {release}
as well. I assume this is a reference to a particular sub-directory named backend
. I guess that ..\backend\release\bar.obj
would be found as a legitimate target? But what part of make says this is legitimate syntax and what exactly happens here?
FWIW: This is in a section commented as: ##### implicit rules
.
Version: GNU Make 4.2.1 Built for x86_64-unknown-cygwin
Bonus points:
Explain the use of @<<
and <<
in the recipe... (Yes, I'm lacking in bash shell finesse...). Is this referencing the first prerequisite with $<
and silently redirecting it? Why isn't it $$<
?
Thanks.
That is an NMAKE batch-mode rule
https://docs.microsoft.com/en-us/cpp/build/batch-mode-rules?view=vs-2017
The equivalent GNU Make rule would be something like
With the difference that, as the name suggests, these rules will invoke their recipes only once for all valid targets and expect the rule to create all of the targets in a single pass with the
$<
macro.The
<<
syntax is NMAKE's inline file featurehttps://docs.microsoft.com/en-us/cpp/build/inline-files-in-a-makefile?view=vs-2017
This expands and captures everything between the angle brackets and saves it to a file, in this case a temporary file as no filename is specified after the brackets. The file is then passed to the compiler as a response file on the first line of the recipe through the
@
option.