1# SPDX-License-Identifier: GPL-2.0 2 3# Try to include uAPI headers from the kernel uapi/ path. 4# Most code under tools/ requires the respective kernel uAPI headers 5# to be copied to tools/include. The duplication is annoying. 6# All the family headers should be self-contained. We avoid the copying 7# by selectively including just the uAPI header of the family directly 8# from the kernel sources. 9 10UAPI_PATH:=../../../../include/uapi/ 11 12# If the header does not exist at all in the system path - let the 13# compiler fall back to the kernel header via -Idirafter. 14# GCC seems to ignore header guard if the header is different, so we need 15# to specify the -D$(hdr_guard). 16# And we need to define HASH indirectly because GNU Make 4.2 wants it escaped 17# and Gnu Make 4.4 wants it without escaping. 18 19HASH := \# 20 21get_hdr_inc=$(if $(shell echo "$(HASH)include <linux/$(2)>" | \ 22 cpp >>/dev/null 2>/dev/null && echo yes),\ 23 -D$(1) -include $(UAPI_PATH)/linux/$(2)) 24 25CFLAGS_devlink:=$(call get_hdr_inc,_UAPI_LINUX_DEVLINK_H_,devlink.h) 26CFLAGS_ethtool:=$(call get_hdr_inc,_LINUX_ETHTOOL_NETLINK_H_,ethtool_netlink.h) 27CFLAGS_handshake:=$(call get_hdr_inc,_UAPI_LINUX_HANDSHAKE_H,handshake.h) 28CFLAGS_netdev:=$(call get_hdr_inc,_UAPI_LINUX_NETDEV_H,netdev.h) 29