重命名Makefile中生成的文件 [英] Rename generated files in Makefile
本文介绍了重命名Makefile中生成的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须修改Makefile,以便在构建.o.
文件之前将扩展名为.cc
的中间文件移至.cpp
.我修改后的Makefile如下所示.
I have to modify a Makefile such that the intermediate files with extension .cc
are moved to .cpp
before building the .o.
files. My modified Makefile looks like below.
PROTOC=protoc
all: client_grpc pb
client_grpc: abc.pb.o abc.grpc.pb.o client_grpc.o
$(CXX) $^ $(LDFLAGS) -o $@
pb: %.pb.cc
mv $^ $@
%.grpc.pb.cc: %.proto
$(PROTOC) --grpc_out=. --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
%.pb.cc: %.proto
$(PROTOC) --cpp_out=. $<
clean:
rm -f *.o *.pb.cc *.pb.h client_gqegrpc
protoc
是生成.cc
文件的编译器.如何生成目标,以便在生成.cc
文件之后将其移动到.cpp
,然后使用.cpp
文件构建client_grpc
?
protoc
is a compiler that generates .cc
files. How to make targets so that after generating the .cc
files those are move to .cpp
and then the client_grpc
is built using the .cpp
files ?
推荐答案
通常的方法是让您的规则生成.cpp文件:
The usual way to do this would be to have your rule produce .cpp files:
%.pb.cpp: %.proto
$(PROTOC) --cpp_out=. $<
mv $*.pb.cc $*.pb.cpp
这篇关于重命名Makefile中生成的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文