I saw the following Makefile online (here):
hello:
clean:
$(RM) hello
When there is a hello.c file in the same directory with the Makefile, make
command in Terminal builds hello
executable. When make clean
is run, hello
executable is removed by rm -f hello
instead. So, $(RM) hello
means rm -f hello
here.
And in your scenario, $MAKE is used in commands part (recipe) of makefile. It means whenever there is a change in dependency, make executes the command make --no-print-directory post-build in whichever directory you are on.
The $@ and $< are called automatic variables. The variable $@ represents the name of the target and $< represents the first prerequisite required to create the output file. For example: hello.o: hello.c hello.h gcc -c $< -o $@ Here, hello.o is the output file.
$$ means be interpreted as a $ by the shell. the $(UNZIP_PATH) gets expanded by make before being interpreted by the shell.
A simple makefile consists of “rules” with the following shape: target … : prerequisites … recipe … … A target is usually the name of a file that is generated by a program; examples of targets are executable or object files. A target can also be the name of an action to carry out, such as ' clean ' (see Phony Targets).
It's a Makefile variable. There are explicit variables (which are defined inside a Makefile) and implicit variables (defined by make, can be overriden by you).
You can see a list of implicit variables with this flag:
make -p
some of the most common variables can be found at: 10.3 Variables Used by Implicit Rules
You can expand a variable with the syntax $(NAME)
or ${NAME}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With