Using Make – writing less Makefile
text.causal.agency
Using Make – writing less Makefile
1–10 of 200 posts
Re: Using Make – writing less Makefile
#2Re: Using Make – writing less Makefile
#3I like the man page format each post has on this website. A little hard to read, but very unique.
Re: Using Make – writing less Makefile
#4I like the man page format each post has on this website. A little hard to read, but very unique.
Yeah, 2023 and reflowing documents still isn't a thing. Yay
Re: Using Make – writing less Makefile
#5Re: Using Make – writing less Makefile
#6You can use make in this form without a makefile even:
~ % echo '#include \nvoid main() { printf("OHAI\\n"); }' > ohai.c
~ % make CFLAGS=-DDEFINE_ME_A_MAKEFILE ohai
cc -DDEFINE_ME_A_MAKEFILE ohai.c -o ohai
~ % ./ohai
OHAIRe: Using Make – writing less Makefile
#7Re: Using Make – writing less Makefile
#8 .SECONDEXPANSION
foo: $$(patsubst %.c,%.o,$$(wildcard *.c))
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
Admittedly you can end up with short, very general Makefiles that look like they were a Prolog program written in TECO. But the advantage is that they are general so don't need to be fiddled with as your project grows.I make small Makefiles like this that ensure my local build environment is correct for the package, then call cmake.
Re: Using Make – writing less Makefile
#9Re: Using Make – writing less Makefile
#10If you want to write less makefile, you don't need to define foo. `foo` is an implicit target if foo.c is present. You can use make in this form without a makefile even: ~ % echo '#include \nvoid main() { printf("OHAI\\n"); }' > ohai.c ~ % make CFLAGS=-DDEFINE_ME_A_MAKEFILE ohai cc -DDEFINE_ME_A_MAKEFILE ohai.c -o ohai ~ % ./ohai OHAI