makefile/nmake :从文件列表中删除文件夹位
我有一个 makefile (使用 nmake & VC++ 2005):
CPP_OBJS = $(CPP_SOURCE:.cpp=.obj)
$(TARGET) : $(CPP_OBJS)
$(link) $(ldebug) $(lflags) /DLL \
$(LIBPATHS) \
$out:$@ $(CPP_OBJS) $(conlibs)
问题是链接步骤失败,因为 $(CPP_OBJS) 被扩展到文件列表中,其中每个文件名前面都带有文件夹名称(这样它是从 CPP_SOURCE 生成的)。由于所有 .obj 文件都位于当前文件夹中(编译结果) - link.exe 无法找到 .objs。
我需要类似的东西:(我在这里找到它:http://uw714doc.sco.com/cgi-bin/info2html?%28make.info%29File%2520Name%2520Functions&lang=en)
`$(notdir NAMES...)' 提取 NAMES 中每个文件名除目录部分之外的所有内容。 如果文件名不包含斜杠,则保持不变。 否则,最后一个斜杠之前的所有内容都会被删除。
但是这个东西似乎不适用于 VC++ 2005 附带的 NMAKE。
非常感谢任何如何克服这个问题的想法。谢谢。
I have a makefile (using nmake & VC++ 2005):
CPP_OBJS = $(CPP_SOURCE:.cpp=.obj)
$(TARGET) : $(CPP_OBJS)
$(link) $(ldebug) $(lflags) /DLL \
$(LIBPATHS) \
$out:$@ $(CPP_OBJS) $(conlibs)
The problem is link step fails because $(CPP_OBJS) are expanded into the list of files where each filename is prepended with a folder name (that way it was generated from CPP_SOURCE) . And since all of the .obj files are in the current folder (results of the compilation) - the link.exe fails to locate .objs.
I need something like: (I found it here: http://uw714doc.sco.com/cgi-bin/info2html?%28make.info%29File%2520Name%2520Functions&lang=en)
`$(notdir NAMES...)'
Extracts all but the directory-part of each file name in NAMES.
If the file name contains no slash, it is left unchanged.
Otherwise, everything through the last slash is removed from it.
but that thing does not seem to be working for NMAKE which comes with VC++ 2005.
Any ideas how to overcome this issue are greatly appreciated. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
$(notdir)
不适合你,因为当你使用 NMAKE 时,这是一个 GNU make 功能。我并不完全清楚你想要做什么,但对你的问题的简短回答是使用带有文件修饰符的 NMAKE 自动变量。在本例中,
$(**)
是目标的所有先决条件的列表,添加F
修饰符将删除目录名称。例如:假设您有一个目录
subdir
,其中包含文件foo.obj
和bar.obj
,则打印:希望有帮助。
$(notdir)
is not working for you because that's a GNU make feature, while you are using NMAKE.It's not entirely clear to me what you're trying to do, but the short answer to your question is to use NMAKE automatic variables with file modifiers. In this case
$(**)
is the list of all prereqs to the target, and adding theF
modifier will strip out the directory names. For example:Assuming you have a directory
subdir
with filesfoo.obj
andbar.obj
, this prints:Hope that helps.
由于 nmake 不支持 '$( notdir NAMES...)' 及其宏替换 不支持从源文件名中轻松删除文件夹层次结构,是否可以更改编译以将目标文件输出到与源相同的文件夹中?
我不是 nmake 专家,但我相信这可以帮助您克服这个问题。
Since nmake doesn't support '$(notdir NAMES...)' and its macro substitution doesn't support easy removal of the folder hierarchy from the source file name(s), would it be possible to change the compilation to output the object file(s) into the same folder(s) as the source?
I'm no nmake expert, but I believe this may help you to overcome this issue.
我不太了解 NMAKE(我使用 GNU Make),但我认为你基本上有两个选择:
I don't really know NMAKE (I use GNU Make) but I think you have basically two options: