Compilation 如何在makefile中更改gcc编译消息

Compilation 如何在makefile中更改gcc编译消息,compilation,makefile,message,Compilation,Makefile,Message,我是编程新手 我需要帮助我在makefile中隐藏消息。 让我告诉你: 编译这组文件时(grid.cc attribute.cc targa.cc) 我看到这个消息:gcc5-Wall-O2-pipe-mtune=i686-c attribute.cc 我想为我辩护,比如:编译targa.cc 我想为自己辩护,比如:Compilation attribute.cc 等 等等 我希望你明白我的意思 这是我的makefile: BIN=../libgame.a CXX=gcc5 CFLAGS=-壁

我是编程新手

我需要帮助我在makefile中隐藏消息。 让我告诉你:

编译这组文件时(grid.cc attribute.cc targa.cc)

我看到这个消息:gcc5-Wall-O2-pipe-mtune=i686-c attribute.cc

我想为我辩护,比如:编译targa.cc 我想为自己辩护,比如:Compilation attribute.cc 等 等等

我希望你明白我的意思

这是我的makefile:

BIN=../libgame.a
CXX=gcc5
CFLAGS=-壁面-O2-管道-mtune=i686
OBJFILES=grid.o attribute.o targa.o
########################################################################################################
违约:
$(CXX)$(CFLAGS)-c grid.cc
$(CXX)$(CFLAGS)-c attribute.cc
$(CXX)$(CFLAGS)-c targa.cc
ar cru$(BIN)$(OBJFILES)
ranlib$(BIN)

rm-f*.o
您可以使用自动生成样式的静默规则技巧来控制命令的输出

要直接执行此操作,请执行以下操作:

BIN = ../libgame.a

CXX = gcc5
CFLAGS = -Wall -O2 -pipe -mtune=i686

OBJFILES = grid.o attribute.o targa.o
########################################################################################################

default:
    @echo 'Compiling grid.cc';$(CXX) $(CFLAGS) -c grid.cc
    @echo 'Compiling attribute.cc';$(CXX) $(CFLAGS) -c attribute.cc
    @echo 'Compiling targa.cc';$(CXX) $(CFLAGS) -c targa.cc
    ar cru $(BIN) $(OBJFILES)
    ranlib $(BIN)
    rm -f *.o
或者,您可以使用my和使用:


要获取
编译grid.cc
编译attribute.cc
编译targa.cc
消息。(如果您为目标文件使用了正确的目标,您可以使用默认的
$(GEN)
静默规则自动获取
GEN xxx.o
输出。

是的,但我不理解在每一行的开头粘贴
@echo'Compiling$@;
。或者使用并添加
$(GEN)
或者添加您自己的编译静默规则并使用它。Etan Reisner谢谢,您的回答是正确的。它很有效。祝您愉快:您为什么在这里使用make?您基本上只是在makefile中编写一个shell脚本,将所有命令放在一个规则中。这是无用的;如果您希望每次都运行相同的命令集,直接编写一个shell脚本就可以了,这样更容易理解。
 $(eval $(call vrule,Compile,Compiling $$(value 1))

 $(call Compile,grid.cc);$(CXX) $(CFLAGS) -c grid.cc
 $(call Compile,attribute.cc);$(CXX) $(CFLAGS) -c attribute.cc
 $(call Compile,targa.cc);$(CXX) $(CFLAGS) -c targa.cc