Respect CC
, CFLAGS
, CPPFLAGS
, and LDLIBS
.
CC
defaults togcc
CFLAGS
defaults to-std=c99 -g -O2
, appended by-Wall -Wextra -pedantic
PACKAGE
,VERSION
, andPROGRAM
PREFIX
defaults to/usr/local
, andDESTDIR
debug
defaults to0
,1
to add-DDEBUG -O0
toCPPFLAGS
clean
andclobber
install
,install-strip
, anduninstall
depend
for genearting.depends
bymakedepend
I don't like the following fashion for declaring phony targets, they all squeeze into a single line, it's messy.
.PHONY: all clean install
It's very likely that you would forget to add to the list or take one off if you remove a target. However, I did use it for some time until I discovered another, which I couldn't remember where I first saw this:
.PHONY: all
all: main
# do something
.PHONY: clean
clean:
$(RM) *.o
It's cleaner in my opinion, nothing wrong about it, but when I saw cmake generated in this way, I jumped the ship right away:
all: main
# do something
.PHONY: all
clean:
$(RM) *.o
.PHONY: clean
Truly, there is nothing particularly special about it, it simply moves all the declarations right after the ends of respective targets. To me, it's like closing tag of HTML, the targets line is the opening tag. It's kind of like what you see some people would add a comment after }
to indicate which block to end in C:
int
foobar(void)
{
/* something */
if (dummy == c)
{
/* something */
} /* dummy == c */
} /* foobar */
This is why I feel it's like closing tag.