【问题标题】:nmake behaviour on windowsWindows 上的 nmake 行为
【发布时间】:2014-04-13 09:31:33
【问题描述】:

概述

我想在 Windows 上使用 nmake,但是遇到了不支持 ifeq 来实现我想要实现的目标的问题。 OS detecting makefile

解决方法

为了解决 ifeq 不兼容的问题,我决定使用 $(OS) 属性。

include platf/$(OS)_make
  • windows 它应该包含 platf/Windows_NT_make
  • $(OS) 返回“”的其他平台,因此使用文件 platf/_make

目录布局

|   Makefile
+---platf
|       Makefile.linux
|       Makefile.macos
|       Makefile.win
|       Windows_NT_make
|       _make

问题

  • _make,我有来自OS detecting makefile 的相同例程,包括适用于 linux 或 mac 等的 Makefile
  • Windows_NT_make 包括 Makefile.win

这就像魅力一样,除了窗户。

#1 如果文件 platf/Windows_NT_make IS 存在,它会报错

makefile(4) : 致命错误 U1052: 找不到文件 'platf/$(OS)_make'

#2 如果文件 platf/Windows_NT_make 不存在,它会报错

makefile(4) : 致命错误 U1052: 找不到文件 'platf/Windows_NT_make'

问题

所以,如果 nmake 能够决定 $(OS) 的值是什么(从 #2 看到),为什么它会抱怨 #1

【问题讨论】:

  • 省去麻烦,使用 CMake。
  • 是的,我发现大多数人都在谈论nmake。我打算切换到ant(使用cpptasks)以避免平台依赖冲突。

标签: c++ windows makefile nmake


【解决方案1】:

问题在于从 Makefile 名称中划定 platf 目录的斜线字符。 对于 unix 系列,它需要是“/”,对于 Windows,它需要是“\”。

您需要知道哪个操作系统可以正确形成名称。这可以通过以下几种方式解决:

  1. 不使用子目录
  2. 制作单独的 CD,以便名称是本地的

我通过拥有一个 makefile 并使用可移植脚本文件来确定操作系统并适当地编辑 Makefile(使用 sed)来解决问题。使用一个脚本和一个 makefile,我可以跨所有系统移动。

【讨论】:

    猜你喜欢
    • 2012-09-15
    • 2021-01-10
    • 1970-01-01
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-29
    相关资源
    最近更新 更多