build/nmk: simplify try-cc and return true/false

- simplify: don't use temporary file -- use /dev/null instead
- return 'true' or 'false' -- this way we can use it inside rules
without external call to bash to compare return with 'y', see
the next patch for a use case.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Dmitry Safonov 2016-08-08 15:57:12 +03:00 committed by Pavel Emelyanov
parent ce5a01f70e
commit 34996312c2

View file

@ -2,11 +2,9 @@ ifndef ____nmk_defined__utils
#
# Usage: option = $(call try-cc,source-to-build,cc-options,cc-defines)
try-cc = $(shell sh -c \
'TMP="$(OUTPUT)$(TMPOUT).$$$$"; \
echo "$(1)" | \
$(CC) $(3) -x c - $(2) -o "$$TMP" > /dev/null 2>&1 && echo y; \
rm -f "$$TMP"')
try-cc = $(shell sh -c 'echo "$(1)" | \
$(CC) $(3) -x c - $(2) -o /dev/null > /dev/null 2>&1 && \
echo true || echo false')
# pkg-config-check
# Usage: ifeq ($(call pkg-config-check, library),y)