pretty print makefiles

ε祈祈猫儿з 提交于 2019-12-20 09:39:19

问题


The linux kernel (and various other projects including git) have very nice makefiles 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?


回答1:


You can prepend @ to calls in the makefile targets.

E.g.:

%.o: %.c
    @$(CC) $(CFLAGS) -c -o $@ $<
    @echo "CC $<"



回答2:


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.



来源:https://stackoverflow.com/questions/2969912/pretty-print-makefiles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!