dpdk-fm10k/mk/rte.helper.mk
Jerin Jacob 53a39551db mk: introduce helper to check compiler argument
Introduce rte_cc_has_argument() Makefile helper to
check a given argument is support by the compiler.

Example Usage:

include $(RTE_SDK)/mk/rte.helper.mk
MACHINE_CFLAGS += $(call rte_cc_has_argument, -mcpu=octeontx2)

This would allow adding -mcpu=octeontx2 in MACHINE_CFLAGS
if it is only supported by the compiler. The use case for such
scheme is to enable the mcpu optimization if the compiler
supports else it needs to compile the source code without
any errors.

This patch also moves inclusion of toolchain's rte.vars.mk
to before the machine's rte.vars.mk inclusion to make
correct CC available for the cross compile case.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
2019-04-15 22:55:56 +02:00

11 lines
356 B
Makefile

# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2018 Marvell International Ltd
# rte_cc_has_argument
# Usage: MACHINE_CFLAGS += $(call rte_cc_has_argument, -mno-avx512f)
# Return the argument if the argument is supported by the compiler.
#
define rte_cc_has_argument
$(shell $(CC) -E $(1) -xc /dev/null 1>/dev/null 2>/dev/null && echo $(1))
endef