[PATCH v2 5/5] tools: ynl: add main install target

Jan Stancek posted 5 patches 1 year ago
There is a newer version of this series
[PATCH v2 5/5] tools: ynl: add main install target
Posted by Jan Stancek 1 year ago
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/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 | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile
index 5268b91bf7ed..116a7fcfc540 100644
--- a/tools/net/ynl/Makefile
+++ b/tools/net/ynl/Makefile
@@ -1,5 +1,16 @@
 # 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)
+
 SUBDIRS = lib generated samples
 
 all: $(SUBDIRS) libynl.a
@@ -23,5 +34,15 @@ 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
+	@echo -e "\tINSTALL libynl.a"
+	@$(INSTALL) -d $(DESTDIR)$(libdir)
+	@$(INSTALL) -m 0644 libynl.a $(DESTDIR)$(libdir)/libynl.a
+	@echo -e "\tINSTALL pyynl"
+	@pip install --prefix=$(DESTDIR)$(prefix) .
+	@make -C generated install
 
-.PHONY: all clean distclean $(SUBDIRS)
+.PHONY: all clean distclean install $(SUBDIRS)
-- 
2.43.0
Re: [PATCH v2 5/5] tools: ynl: add main install target
Posted by Joe Damato 1 year ago
On Mon, Dec 09, 2024 at 03:47:17PM +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

This is super useful thanks for doing this work. I could be missing
something, but it looks like the install target does not install the
generated C headers that user code can include at build time.

Am I reading that right? Is that intentional? I was thinking that it
would be really useful to have the headers installed, too.

> 	/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/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>

[...]
Re: [PATCH v2 5/5] tools: ynl: add main install target
Posted by Jan Stancek 1 year ago
On Mon, Dec 9, 2024 at 10:30 PM Joe Damato <jdamato@fastly.com> wrote:
>
> On Mon, Dec 09, 2024 at 03:47:17PM +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
>
> This is super useful thanks for doing this work. I could be missing
> something, but it looks like the install target does not install the
> generated C headers that user code can include at build time.
>
> Am I reading that right? Is that intentional? I was thinking that it
> would be really useful to have the headers installed, too.

It's not intentional, just noone asked for it yet. We can add those.
Would /usr/include/ynl/ work? Or do you/others have a different suggestion?

Regards,
Jan

>
> >       /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/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>
>
> [...]
>
Re: [PATCH v2 5/5] tools: ynl: add main install target
Posted by Joe Damato 1 year ago
On Tue, Dec 10, 2024 at 02:56:05PM +0100, Jan Stancek wrote:
> On Mon, Dec 9, 2024 at 10:30 PM Joe Damato <jdamato@fastly.com> wrote:
> >
> > On Mon, Dec 09, 2024 at 03:47:17PM +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
> >
> > This is super useful thanks for doing this work. I could be missing
> > something, but it looks like the install target does not install the
> > generated C headers that user code can include at build time.
> >
> > Am I reading that right? Is that intentional? I was thinking that it
> > would be really useful to have the headers installed, too.
> 
> It's not intentional, just noone asked for it yet. We can add those.
> Would /usr/include/ynl/ work? Or do you/others have a different suggestion?

/usr/include/ynl sounds good to me, but happy to see if other folks
have suggestions.

Thanks for being open to adding this; it'll make developing user
apps with libynl much easier.