4 ms·
Neat! I've been putting off learning how to use those `-M` flags to automatically generate dependencies, but it looks like it's not that hard :) What I also li
by kmm 10y ago
Neat! I've been putting off learning how to use those `-M` flags to automatically generate dependencies, but it looks like it's not that hard :)
What I also like to do is hide the actual compilation command with recipes like this, inspired by the Linux kernel
%.o : %.c
@echo " CC $<"
@$(CC) -o $@ -c $(CFLAGS) $<
I think it looks a lot tidier, it turns a ton of dense uninteresting command lines into a few dozen short lines.
- qznc 10y agoA variant we use is: Q ?= @ %.o : %.c @echo 'CC $@' $(Q)$(CC) -o $@ -c $(CFLAGS) $< Now you can make the commands visible again via `make Q=`. A more subjective question is, if you echo $@ or $<.
- andrewaylett 10y agoIn a past life, the mega-but-autogenerated Makefile I helped maintain would store the executed command and only echo it if the command failed. And we logged everything to file, so you got nice output but all the info was there if we needed it. Didn't take that long to work out how to do it, once we'd decided it would be a nice thing to have.
- qznc 10y agoI like that. It lives the Unix philosophy to be silent unless an error occurs.
- m_mueller 10y agoI did the hiding for a while until I noticed that it slows my debugging down way too much when something breaks and I want to manually fiddle with some compiler flags. Now I let make use two separate colors: One for info I'm usually interested in and one for stuff I need to know when I need to get my hands dirty.