Live data from Hacker News

Using Make – writing less Makefile

text.causal.agency

1–10 of 200 posts

Re: Using Make – writing less Makefile

#4

I 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

I read this on mobile and it felt pretty tedious. I wonder if maybe some minimal HTML could make the paragraphs reflow properly while still looking like a manpage everywhere.

Re: Using Make – writing less Makefile

#6
If 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

Re: Using Make – writing less Makefile

#8
With gnu make you don't even need OBJs for a simple directory in which all the .c files are compiled:

    .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

#9

I 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

What sort of keyhole are you peering through that needs to reflow 72-character text lines?

Re: Using Make – writing less Makefile

#10
post #6

If 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

In that case why call make at all?
Post reply on HN