Talking with respect to GNU make, what is the difference between PHONY targets all:
and default:
.
CC=g++
default: hello
hello: hello.cpp
$(CC) -o hello hello.cpp
and
CC=g++
all: hello
hello: hello.cpp
$(CC) -o hello hello.cpp
Both of them do the same job.
By default, the goal is the first target in the makefile (not counting targets that start with a period). Therefore, makefiles are usually written so that the first target is for compiling the entire program or programs they describe.
all target is usually the first in the makefile, since if you just write make in command line, without specifying the target, it will build the first target. And you expect it to be all . all is usually also a . PHONY target.
'make all' simply tells the make tool to build the target 'all' in the makefile (usually called ' Makefile '). You may have a look at such file in order to understand how the source code will be processed. As about the error you are getting, it looks the compile_mg1g1. ksh shell script is missing.
The order of rules is not significant, except for determining the default goal : the target for make to consider, if you do not otherwise specify one. The default goal is the target of the first rule in the first makefile. If the first rule has multiple targets, only the first target is taken as the default.
You can call them shirley
if you like; neither of the labels you mention has any special semantics. The default behavior of make
is to run the first target in the Makefile
if you don't specify a target as a command-line argument. If you like to override this behavior, there is the .DEFAULT:
special target.
There is a convention to have a target named all
which builds everything, but this is just human convention, not a special case or a requirement as far as Make is concerned.
Similarly, there is a (weak) convention to call the default target default
, but similarly, this is just a human label (and somewhat overlaps and possibly conflicts with the all
convention).
So the following Makefile does exactly the same thing:
.PHONY: shirley all default
default: hello
all: hello
shirley: hello
hello: hello.cpp
# (Make already knows how to build an executable out of a .cpp file)
You can omit any or all of the phony targets above, and the only difference will be that humans won't be able to say make shirley
when they (effectively) mean make hello
.
Bottom line: Construct your Makefile so that make
does what a reasonable end-user expects without reading too much README
files or inspecting the Makefile
. Often that will be make all
(and you should probably have a target with this name, just to satisfy human conventions, even if it's not the default) but this obviously depends on your project and your users' expectations.
Don't call me Shirley.
The only difference, is that all
is recommended in the GNU Make manual, to be the first (default) target, and default
has no such special recommendation.
One is spelled "all" and the other is spelled "default". There's no other difference between them. Maybe if you explained why you're asking we'd be able to help more.
Note that in your example above neither of the targets are actually phony. You'd have to declare them as such:
.PHONY: all
etc.
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