nmk: Provide try-asm build check function

I need to add feature test written in assembly to check
if the feature can be compiled.

Add a make function for this purpose.

Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Dmitry Safonov 2017-05-31 23:23:38 +03:00 committed by Andrei Vagin
parent 7d8adbee2b
commit f32ffdef90

View file

@ -1,11 +1,19 @@
ifndef ____nmk_defined__utils
#
# Usage: option = $(call try-cc,source-to-build,cc-options,cc-defines)
try-cc = $(shell sh -c 'echo "$(1)" | \
$(CC) $(3) -x c - $(2) -o /dev/null > /dev/null 2>&1 && \
# Usage: option := $(call try-compile,language,source-to-build,cc-options,cc-defines)
try-compile = $(shell sh -c 'echo "$(2)" | \
$(CC) $(4) -x $(1) - $(3) -o /dev/null > /dev/null 2>&1 && \
echo true || echo false')
#
# Usage: option := $(call try-cc,source-to-build,cc-options,cc-defines)
try-cc = $(call try-compile,c,$(1),$(2),$(3))
#
# Usage: option := $(call try-cc,source-to-build,cc-options,cc-defines)
try-asm = $(call try-compile,assembler-with-cpp,$(1),$(2),$(3))
# pkg-config-check
# Usage: ifeq ($(call pkg-config-check, library),y)
pkg-config-check = $(shell sh -c 'pkg-config $(1) && echo y')