diff mbox series

[v3,4/4] tools: ynl: add main install target

Message ID 6e41a47b9ea5ede099d9ae7768fbceb553c6614d.1734345017.git.jstancek@redhat.com (mailing list archive)
State Changes Requested
Headers show
Series tools: ynl: add install target | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success Errors and warnings before: 0 (+1) this patch: 0 (+1)
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 135 this patch: 135
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-16--15-00 (tests: 794)

Commit Message

Jan Stancek Dec. 16, 2024, 10:41 a.m. UTC
This will install C library, specs, rsts and pyynl. The initial
structure is:

	$ mkdir /tmp/myroot
	$ make DESTDIR=/tmp/myroot install

	/usr
	/usr/lib64
	/usr/lib64/libynl.a
	/usr/lib/python3.XX/site-packages/pyynl/*
	/usr/lib/python3.XX/site-packages/pyynl-0.0.1.dist-info/*
	/usr/bin
	/usr/bin/ynl
	/usr/bin/ynl-ethtool
	/usr/bin/ynl-gen-c
	/usr/bin/ynl-gen-rst
        /usr/include/ynl/*.h
	/usr/share
	/usr/share/doc
	/usr/share/doc/ynl
	/usr/share/doc/ynl/*.rst
	/usr/share/ynl
	/usr/share/ynl/genetlink-c.yaml
	/usr/share/ynl/genetlink-legacy.yaml
	/usr/share/ynl/genetlink.yaml
	/usr/share/ynl/netlink-raw.yaml
	/usr/share/ynl/specs
	/usr/share/ynl/specs/devlink.yaml
	/usr/share/ynl/specs/dpll.yaml
	/usr/share/ynl/specs/ethtool.yaml
	/usr/share/ynl/specs/fou.yaml
	/usr/share/ynl/specs/handshake.yaml
	/usr/share/ynl/specs/mptcp_pm.yaml
	/usr/share/ynl/specs/netdev.yaml
	/usr/share/ynl/specs/net_shaper.yaml
	/usr/share/ynl/specs/nfsd.yaml
	/usr/share/ynl/specs/nftables.yaml
	/usr/share/ynl/specs/nlctrl.yaml
	/usr/share/ynl/specs/ovs_datapath.yaml
	/usr/share/ynl/specs/ovs_flow.yaml
	/usr/share/ynl/specs/ovs_vport.yaml
	/usr/share/ynl/specs/rt_addr.yaml
	/usr/share/ynl/specs/rt_link.yaml
	/usr/share/ynl/specs/rt_neigh.yaml
	/usr/share/ynl/specs/rt_route.yaml
	/usr/share/ynl/specs/rt_rule.yaml
	/usr/share/ynl/specs/tcp_metrics.yaml
	/usr/share/ynl/specs/tc.yaml
	/usr/share/ynl/specs/team.yaml

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 tools/net/ynl/Makefile | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

Comments

Donald Hunter Dec. 16, 2024, 2:09 p.m. UTC | #1
Jan Stancek <jstancek@redhat.com> writes:

> This will install C library, specs, rsts and pyynl. The initial
> structure is:
>
> 	$ mkdir /tmp/myroot
> 	$ make DESTDIR=/tmp/myroot install
>
> 	/usr
> 	/usr/lib64
> 	/usr/lib64/libynl.a
> 	/usr/lib/python3.XX/site-packages/pyynl/*
> 	/usr/lib/python3.XX/site-packages/pyynl-0.0.1.dist-info/*
> 	/usr/bin
> 	/usr/bin/ynl
> 	/usr/bin/ynl-ethtool
> 	/usr/bin/ynl-gen-c
> 	/usr/bin/ynl-gen-rst
>         /usr/include/ynl/*.h
> 	/usr/share
> 	/usr/share/doc
> 	/usr/share/doc/ynl
> 	/usr/share/doc/ynl/*.rst
> 	/usr/share/ynl
> 	/usr/share/ynl/genetlink-c.yaml
> 	/usr/share/ynl/genetlink-legacy.yaml
> 	/usr/share/ynl/genetlink.yaml
> 	/usr/share/ynl/netlink-raw.yaml
> 	/usr/share/ynl/specs
> 	/usr/share/ynl/specs/devlink.yaml
> 	/usr/share/ynl/specs/dpll.yaml
> 	/usr/share/ynl/specs/ethtool.yaml
> 	/usr/share/ynl/specs/fou.yaml
> 	/usr/share/ynl/specs/handshake.yaml
> 	/usr/share/ynl/specs/mptcp_pm.yaml
> 	/usr/share/ynl/specs/netdev.yaml
> 	/usr/share/ynl/specs/net_shaper.yaml
> 	/usr/share/ynl/specs/nfsd.yaml
> 	/usr/share/ynl/specs/nftables.yaml
> 	/usr/share/ynl/specs/nlctrl.yaml
> 	/usr/share/ynl/specs/ovs_datapath.yaml
> 	/usr/share/ynl/specs/ovs_flow.yaml
> 	/usr/share/ynl/specs/ovs_vport.yaml
> 	/usr/share/ynl/specs/rt_addr.yaml
> 	/usr/share/ynl/specs/rt_link.yaml
> 	/usr/share/ynl/specs/rt_neigh.yaml
> 	/usr/share/ynl/specs/rt_route.yaml
> 	/usr/share/ynl/specs/rt_rule.yaml
> 	/usr/share/ynl/specs/tcp_metrics.yaml
> 	/usr/share/ynl/specs/tc.yaml
> 	/usr/share/ynl/specs/team.yaml
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Joe Damato Dec. 16, 2024, 10:58 p.m. UTC | #2
On Mon, Dec 16, 2024 at 11:41:44AM +0100, Jan Stancek wrote:
> This will install C library, specs, rsts and pyynl. The initial
> structure is:
> 
> 	$ mkdir /tmp/myroot
> 	$ make DESTDIR=/tmp/myroot install
> 
> 	/usr
> 	/usr/lib64
> 	/usr/lib64/libynl.a
> 	/usr/lib/python3.XX/site-packages/pyynl/*
> 	/usr/lib/python3.XX/site-packages/pyynl-0.0.1.dist-info/*
> 	/usr/bin
> 	/usr/bin/ynl
> 	/usr/bin/ynl-ethtool
> 	/usr/bin/ynl-gen-c
> 	/usr/bin/ynl-gen-rst
>         /usr/include/ynl/*.h

[...]

Thanks for including the headers and doing all of this work.

I tested this on my machine using one of the sample C files and it
seemed to work:

mkdir -p /tmp/myroot/local-inc/linux
make DESTDIR=/tmp/myroot -C tools/net/ynl/ install
cp /usr/src/linux-headers-`uname -r`/include/uapi/linux/netdev.h \
   /tmp/myroot/local-inc/linux
cp tools/net/ynl/samples/netdev.c  /tmp/

cd /tmp
gcc -I./myroot/local-inc/ -I myroot/usr/include/ynl/ -o netdev netdev.c -L/tmp/myroot/usr/lib64/ -lynl

./netdev
Select ifc ($ifindex; or 0 = dump; or -2 ntf check):

Reviewed-by: Joe Damato <jdamato@fastly.com>
diff mbox series

Patch

diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile
index 5268b91bf7ed..211df5a93ad9 100644
--- a/tools/net/ynl/Makefile
+++ b/tools/net/ynl/Makefile
@@ -1,5 +1,17 @@ 
 # SPDX-License-Identifier: GPL-2.0
 
+include ../../scripts/Makefile.arch
+
+INSTALL	?= install
+prefix  ?= /usr
+ifeq ($(LP64), 1)
+  libdir_relative = lib64
+else
+  libdir_relative = lib
+endif
+libdir  ?= $(prefix)/$(libdir_relative)
+includedir ?= $(prefix)/include
+
 SUBDIRS = lib generated samples
 
 all: $(SUBDIRS) libynl.a
@@ -23,5 +35,18 @@  clean distclean:
 	rm -f libynl.a
 	rm -rf pyynl/__pycache__
 	rm -rf pyynl/lib/__pycache__
+	rm -rf pyynl.egg-info
+	rm -rf build
+
+install: libynl.a lib/*.h
+	@echo -e "\tINSTALL libynl.a"
+	@$(INSTALL) -d $(DESTDIR)$(libdir)
+	@$(INSTALL) -m 0644 libynl.a $(DESTDIR)$(libdir)/libynl.a
+	@echo -e "\tINSTALL libynl headers"
+	@$(INSTALL) -d $(DESTDIR)$(includedir)/ynl
+	@$(INSTALL) -m 0644 lib/*.h $(DESTDIR)$(includedir)/ynl/
+	@echo -e "\tINSTALL pyynl"
+	@pip install --prefix=$(DESTDIR)$(prefix) .
+	@make -C generated install
 
-.PHONY: all clean distclean $(SUBDIRS)
+.PHONY: all clean distclean install $(SUBDIRS)