条件分支判断
一定要注意 ifeq
, ifdef
不能缩进,血的教训 😭
当 foo
变量为空字符串等值时,ifdef
判断结果也是 true
# Copyright 2018 The seekplum Authors
IMAGE_COUNT=1
NOT_EXISTS=0
HOMENAME=$(shell hostname)
foo =
docker:
ifeq ($(IMAGE_COUNT),$(NOT_EXISTS))
@echo "${HOMENAME} images does not exists"
else
@echo "${HOMENAME} images exists"
endif
@echo "done!"
test:
ifdef foo
@echo yes
@ls -l /tmp
else
@echo no
@ls -l /root
endif
@echo "done!"
.PHONY: all docker test