自编辑Makefile
这是我的源代码:
BUILD := 0001
VERSION := 0.00
COMPILER := g++
CFLAGS :=
LDFLAGS :=
EXECUTABLE := bin/conch$(VERSION)-$(BUILD).exe
all: src/conch.cc
$(COMPILER) $(input) -o $(EXECUTABLE)
conch: obj/conch.o
$(COMPILER) $(LDFLAGS) $(input) -o $(EXECUTABLE)
conch.o: src/conch.cc
$(COMPILER) $(CFLAGS) -c src/conch.cc -o obj/conch.o
clean:
rm -f obj/conch.o
如何制作 makefile,以便在 make conch
或 make all
时 BUILD
值递增?或者这根本不可能?
Here's my source code:
BUILD := 0001
VERSION := 0.00
COMPILER := g++
CFLAGS :=
LDFLAGS :=
EXECUTABLE := bin/conch$(VERSION)-$(BUILD).exe
all: src/conch.cc
$(COMPILER) $(input) -o $(EXECUTABLE)
conch: obj/conch.o
$(COMPILER) $(LDFLAGS) $(input) -o $(EXECUTABLE)
conch.o: src/conch.cc
$(COMPILER) $(CFLAGS) -c src/conch.cc -o obj/conch.o
clean:
rm -f obj/conch.o
How can I make the makefile so that when I make conch
or make all
the BUILD
value increments? Or is this not possible at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 将其他文件“包含”到 Makefile 中,您猜对了
include
指令。这样你就可以拥有
Makefile
buildinfo.inc
然后,你需要做的就是修改(或简单地重写)
buildinfo.inc
来增加版本号。这些变量将像现在一样在您的 Makefile 中使用。You can "include" other files into a Makefile using, you guessed it, the
include
directive.So you can have
Makefile
buildinfo.inc
Then, all you need to do is modify (or simply rewrite)
buildinfo.inc
to increment the version number. Those variables will then be usable inside yourMakefile
just as they are now.