gnu make - Makefile: all vs default targets -
talking respect gnu make, difference between phony targets all:
, 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 same job.
you can call them shirley
if like; neither of labels mention has special semantics. default behavior of make
run first target in makefile
if don't specify target command-line argument. if override behavior, there .default:
special target.
there convention have target named all
builds everything, human convention, not special case or requirement far make concerned.
similarly, there (weak) convention call default target default
, similarly, human label (and overlaps , possibly conflicts all
convention).
so following makefile same thing:
.phony: shirley default default: hello all: hello shirley: hello hello: hello.cpp # (make knows how build executable out of .cpp file)
you can omit or of phony targets above, , difference humans won't able make shirley
when (effectively) mean make hello
.
bottom line: construct makefile make
reasonable end-user expects without reading readme
files or inspecting makefile
. make all
(and should have target name, satisfy human conventions, if it's not default) depends on project , users' expectations.
don't call me shirley.
Comments
Post a Comment