pretty print makefiles
The linux kernel (and various other projects including git) have very nice makefi开发者_如何学运维les that hide the giant cc calls into nice little acronyms.
For example:
gcc -O2 -o cool.o cool.c -llib
gcc -O2 -o neat.o neat.c -llib
would become:
CC cool.c
CC neat.c
Which is really nice if you have a project with a large number of files and long compiler flags. I recall that this had to do with suppressing the default output and making a custom one. How do you do it?
You can prepend @ to calls in the makefile targets.
E.g.:
%.o: %.c
@$(CC) $(CFLAGS) -c -o $@ $<
@echo "CC $<"
For a much more complicated makefile, you could use a Python script to capture the output in realtime and process it however you like, and then print them in realtime: example.
精彩评论