我希望在 Linux 和 Windows 上构建相同的 Makefile。我在 Linux 上 使用默认的GNU make ,在 Windows 上使用mingw32-make(也是GNU make)。
我希望 Makefile 检测它是在 Windows 还是 Linux 上运行。
例如make clean
,Windows 上的命令如下所示:
clean:
del $(DESTDIR_TARGET)
但在 Linux 上:
clean:
rm $(DESTDIR_TARGET)
我还想在 Windows ( \
) 和 Linux ( /
) 上使用不同的目录分隔符。
可以在 Makefile 中检测 Windows 操作系统吗?
PS:我不想在 Windows 上模拟 Linux(cygwin 等)
有类似的问题:操作系统检测 makefile,但我没有在这里找到答案。