if
/else
foo = ok
all:
ifeq ($(foo), ok)
@echo "foo equals ok"
else
@echo "nope"
endif
nullstring =
foo = $(nullstring) # end of line; there is a space here
all:
ifeq ($(strip $(foo)),)
@echo "foo is empty after being stripped"
endif
ifeq ($(nullstring),)
@echo "nullstring doesn't even have spaces"
endif
bar =
foo = $(bar)
all:
ifdef foo
@echo "foo is defined"
endif
ifndef bar
@echo "but bar is not"
endif
$(makeflags)
이하의 예제는 MAKEFLAGS
와 findstring
를 통해 어떻게 make
의 플래그를 검사하는지를 보여준다. 이하의 예제를 make -i
와 함께 실행하고 echo
구문의 출력 결과를 보라:
bar =
foo = $(bar)
all:
# Search for the "-i" flag. MAKEFLGS is just a list of single characters, one per flag. So look for "i" in this case.
ifneq (,$(findstring i, $(MAKEFLAGS)))
echo "i was passed to MAKEFLAGS"
endif