xref: /linux/tools/testing/selftests/net/ynl.mk (revision 7f71507851fc7764b36a3221839607d3a45c2025)
1# SPDX-License-Identifier: GPL-2.0
2
3# YNL selftest build snippet
4
5# Inputs:
6#
7# YNL_GENS:      families we need in the selftests
8# YNL_PROGS:     TEST_PROGS which need YNL (TODO, none exist, yet)
9# YNL_GEN_FILES: TEST_GEN_FILES which need YNL
10
11YNL_OUTPUTS := $(patsubst %,$(OUTPUT)/%,$(YNL_GEN_FILES))
12YNL_SPECS := \
13	$(patsubst %,$(top_srcdir)/Documentation/netlink/specs/%.yaml,$(YNL_GENS))
14
15$(YNL_OUTPUTS): $(OUTPUT)/libynl.a
16$(YNL_OUTPUTS): CFLAGS += \
17	-I$(top_srcdir)/usr/include/ $(KHDR_INCLUDES) \
18	-I$(top_srcdir)/tools/net/ynl/lib/ \
19	-I$(top_srcdir)/tools/net/ynl/generated/
20
21# Make sure we rebuild libynl if user added a new family. We can't easily
22# depend on the contents of a variable so create a fake file with a hash.
23YNL_GENS_HASH := $(shell echo $(YNL_GENS) | sha1sum | cut -c1-8)
24$(OUTPUT)/.libynl-$(YNL_GENS_HASH).sig:
25	$(Q)rm -f $(OUTPUT)/.libynl-*.sig
26	$(Q)touch $(OUTPUT)/.libynl-$(YNL_GENS_HASH).sig
27
28$(OUTPUT)/libynl.a: $(YNL_SPECS) $(OUTPUT)/.libynl-$(YNL_GENS_HASH).sig
29	$(Q)rm -f $(top_srcdir)/tools/net/ynl/libynl.a
30	$(Q)$(MAKE) -C $(top_srcdir)/tools/net/ynl GENS="$(YNL_GENS)" libynl.a
31	$(Q)cp $(top_srcdir)/tools/net/ynl/libynl.a $(OUTPUT)/libynl.a
32
33EXTRA_CLEAN += \
34	$(top_srcdir)/tools/net/ynl/lib/__pycache__ \
35	$(top_srcdir)/tools/net/ynl/lib/*.[ado] \
36	$(OUTPUT)/.libynl-*.sig \
37	$(OUTPUT)/libynl.a
38