tools: net: package libynl for use in selftests
Support building the C YNL userspace library into one big static file. We can then link selftests against it for easy to use C netlink interface. Signed-off-by: Mina Almasry <almasrymina@google.com> Link: https://patch.msgid.link/20240628003253.1694510-14-almasrymina@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
4dec64c52e
commit
07c3cc51a0
3 changed files with 29 additions and 2 deletions
|
@ -2,9 +2,12 @@
|
||||||
|
|
||||||
SUBDIRS = lib generated samples
|
SUBDIRS = lib generated samples
|
||||||
|
|
||||||
all: $(SUBDIRS)
|
all: $(SUBDIRS) libynl.a
|
||||||
|
|
||||||
samples: | lib generated
|
samples: | lib generated
|
||||||
|
libynl.a: | lib generated
|
||||||
|
@echo -e "\tAR $@"
|
||||||
|
@ar rcs $@ lib/ynl.o generated/*-user.o
|
||||||
|
|
||||||
$(SUBDIRS):
|
$(SUBDIRS):
|
||||||
@if [ -f "$@/Makefile" ] ; then \
|
@if [ -f "$@/Makefile" ] ; then \
|
||||||
|
@ -17,5 +20,6 @@ clean distclean:
|
||||||
$(MAKE) -C $$dir $@; \
|
$(MAKE) -C $$dir $@; \
|
||||||
fi \
|
fi \
|
||||||
done
|
done
|
||||||
|
rm -f libynl.a
|
||||||
|
|
||||||
.PHONY: all clean distclean $(SUBDIRS)
|
.PHONY: all clean distclean $(SUBDIRS)
|
||||||
|
|
|
@ -14,7 +14,9 @@ include $(wildcard *.d)
|
||||||
all: ynl.a
|
all: ynl.a
|
||||||
|
|
||||||
ynl.a: $(OBJS)
|
ynl.a: $(OBJS)
|
||||||
ar rcs $@ $(OBJS)
|
@echo -e "\tAR $@"
|
||||||
|
@ar rcs $@ $(OBJS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.d *~
|
rm -f *.o *.d *~
|
||||||
rm -rf __pycache__
|
rm -rf __pycache__
|
||||||
|
|
21
tools/testing/selftests/net/ynl.mk
Normal file
21
tools/testing/selftests/net/ynl.mk
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
# YNL selftest build snippet
|
||||||
|
|
||||||
|
# Inputs:
|
||||||
|
#
|
||||||
|
# YNL_GENS: families we need in the selftests
|
||||||
|
# YNL_PROGS: TEST_PROGS which need YNL (TODO, none exist, yet)
|
||||||
|
# YNL_GEN_FILES: TEST_GEN_FILES which need YNL
|
||||||
|
|
||||||
|
YNL_OUTPUTS := $(patsubst %,$(OUTPUT)/%,$(YNL_GEN_FILES))
|
||||||
|
|
||||||
|
$(YNL_OUTPUTS): $(OUTPUT)/libynl.a
|
||||||
|
$(YNL_OUTPUTS): CFLAGS += \
|
||||||
|
-I$(top_srcdir)/usr/include/ $(KHDR_INCLUDES) \
|
||||||
|
-I$(top_srcdir)/tools/net/ynl/lib/ \
|
||||||
|
-I$(top_srcdir)/tools/net/ynl/generated/
|
||||||
|
|
||||||
|
$(OUTPUT)/libynl.a:
|
||||||
|
$(Q)$(MAKE) -C $(top_srcdir)/tools/net/ynl GENS="$(YNL_GENS)" libynl.a
|
||||||
|
$(Q)cp $(top_srcdir)/tools/net/ynl/libynl.a $(OUTPUT)/libynl.a
|
Loading…
Reference in a new issue