开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜