【发布时间】:2018-12-05 15:08:39
【问题描述】:
这是一个 Makefile:
.PHONY: all
ifeq ($(OS),Windows_NT)
DETECTED_OS := Windows
else
DETECTED_OS := $(shell uname -s)
endif
$(info DETECTED_OS is set to '$(DETECTED_OS)')
当使用制表符缩进时,它会打印
DETECTED_OS is set to ''
但是当缩进 0 个或多个空格时,它会打印出来
DETECTED_OS is set to 'Linux'
但是如果你删除第一行 .PHONY: all 它会打印出来
DETECTED_OS is set to 'Linux'
不考虑制表符或空格。
所以第一个版本被破坏了,因为它将DETECTED_OS 设置为空。这是为什么呢?
我的make版本:
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
【问题讨论】: