强制 gnu make 重建受编译器定义影响的对象
我有一个 makefile,它在命令行上采用选项,
make OPTION_1=1
它会根据值向对象子集添加额外的编译器定义。
ifeq ($(OPTION_1), 1)
CC_FLAGS += -DOPTION_1_ON
endif
定义中的更改会影响包含的头文件内容 - 存根或实现会暴露给对象文件。
我怎样才能让 make 重建受此选项更改“影响”的文件?
I have a makefile that takes options at the command line
make OPTION_1=1
Based on the value it will add additional compiler definitions to a subset of objects.
ifeq ($(OPTION_1), 1)
CC_FLAGS += -DOPTION_1_ON
endif
The change in the definition affects the included header file content - a stub or an implementation is exposed to the object files.
How can I get make to rebuild the files 'affected' by this option changing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用一个文件来记住此类选项的最后一个值,如下所示:
cmp || echo
位意味着文件compiler_flags
仅在设置更改时才会被触及,因此现在您可以编写类似的内容,每当编译器标志发生变化。每次运行make时都会执行compiler_flags的规则,但只有当
compiler_flags
文件被实际修改时才会触发$(OBJECTS)
的重建。I use a file to remember the last value of such options, like this:
The
cmp || echo
bit means the filecompiler_flags
is only touched when the setting changes, so now you can write something liketo cause a rebuild of
$(OBJECTS)
whenever the compiler flags change. The rule for compiler_flags will be executed every time you run make, but a rebuild of$(OBJECTS)
will be triggered only if thecompiler_flags
file was actually modified.