public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd.mk, install-man.mk: Allow installing link pages as symlinks
@ 2023-03-08  1:04 Alejandro Colomar
  2023-03-08  1:08 ` Alejandro Colomar
  0 siblings, 1 reply; 2+ messages in thread
From: Alejandro Colomar @ 2023-03-08  1:04 UTC (permalink / raw)
  To: linux-man, G. Branden Robinson; +Cc: Alejandro Colomar, Marcos Fouces

We keep them as .so "includes" in our source code, but if some
distribution wants to have them as symlinks in their filesystem, make it
easy for them to install as such, by specifying 'LINK_PAGES=symlink'.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
---

Hi!

I'm going to add support for installing link pages as symlinks.  Debian
installs them this way, so I think it makes sense to help distributors
use our upstream build system to install in their preferred way, since
otherwise, to be more useful.

Here's the implementation I came up with, but I'd like to hear comments
about the interface (the LINK_PAGES variable).  Would you make it
different?

Thanks!

Alex


 lib/cmd.mk         | 1 +
 lib/install-man.mk | 9 +++++++++
 2 files changed, 10 insertions(+)

diff --git a/lib/cmd.mk b/lib/cmd.mk
index 17f3a8ee5..9cd09fe89 100644
--- a/lib/cmd.mk
+++ b/lib/cmd.mk
@@ -16,6 +16,7 @@ GREP       := grep
 GZIP       := gzip
 HEAD       := head
 INSTALL    := install
+LN         := ln
 LOCALE     := locale
 PKG-CONFIG := pkg-config
 SED        := sed
diff --git a/lib/install-man.mk b/lib/install-man.mk
index 174f503ca..aaa545290 100644
--- a/lib/install-man.mk
+++ b/lib/install-man.mk
@@ -12,6 +12,9 @@ include $(srcdir)/lib/install.mk
 include $(srcdir)/lib/src.mk
 
 
+LINK_PAGES := so  # Alternatives: "so", "symlink"
+
+
 mandir      := $(datarootdir)/man
 man1dir     := $(mandir)/man1
 man2dir     := $(mandir)/man2
@@ -147,6 +150,12 @@ $(_manpages):
 		-e '/^\.so /s, man7/\(.*\)\.7$$, $(notdir $(man7dir))/\1$(man7ext),' \
 		-e '/^\.so /s, man8/\(.*\)\.8$$, $(notdir $(man8dir))/\1$(man8ext),' \
 		$@
+ifeq ($(LINK_PAGES),symlink)
+	if $(GREP) '^\.so ' <$@ >/dev/null; then \
+		$(SED) 's,^\.so \(.*\),../\1,' <$@ \
+		| $(XARGS) -I tgt $(LN) -fsT tgt $@; \
+	fi
+endif
 
 $(_mandirs): %/.: | $$(dir %). $(_mandir)/.
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cmd.mk, install-man.mk: Allow installing link pages as symlinks
  2023-03-08  1:04 [PATCH] cmd.mk, install-man.mk: Allow installing link pages as symlinks Alejandro Colomar
@ 2023-03-08  1:08 ` Alejandro Colomar
  0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2023-03-08  1:08 UTC (permalink / raw)
  To: linux-man, G. Branden Robinson; +Cc: Alejandro Colomar, Marcos Fouces


[-- Attachment #1.1: Type: text/plain, Size: 2322 bytes --]



On 3/8/23 02:04, Alejandro Colomar wrote:
> We keep them as .so "includes" in our source code, but if some
> distribution wants to have them as symlinks in their filesystem, make it
> easy for them to install as such, by specifying 'LINK_PAGES=symlink'.
> 
> Signed-off-by: Alejandro Colomar <alx@kernel.org>
> ---
> 
> Hi!
> 
> I'm going to add support for installing link pages as symlinks.  Debian
> installs them this way, so I think it makes sense to help distributors
> use our upstream build system to install in their preferred way, since
> otherwise, to be more useful.

to be more useful, since otherwise, our build system is something that only
we find useful, but nobody really uses.  :)

> 
> Here's the implementation I came up with, but I'd like to hear comments
> about the interface (the LINK_PAGES variable).  Would you make it
> different?
> 
> Thanks!
> 
> Alex
> 
> 
>  lib/cmd.mk         | 1 +
>  lib/install-man.mk | 9 +++++++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/lib/cmd.mk b/lib/cmd.mk
> index 17f3a8ee5..9cd09fe89 100644
> --- a/lib/cmd.mk
> +++ b/lib/cmd.mk
> @@ -16,6 +16,7 @@ GREP       := grep
>  GZIP       := gzip
>  HEAD       := head
>  INSTALL    := install
> +LN         := ln
>  LOCALE     := locale
>  PKG-CONFIG := pkg-config
>  SED        := sed
> diff --git a/lib/install-man.mk b/lib/install-man.mk
> index 174f503ca..aaa545290 100644
> --- a/lib/install-man.mk
> +++ b/lib/install-man.mk
> @@ -12,6 +12,9 @@ include $(srcdir)/lib/install.mk
>  include $(srcdir)/lib/src.mk
>  
>  
> +LINK_PAGES := so  # Alternatives: "so", "symlink"
> +
> +
>  mandir      := $(datarootdir)/man
>  man1dir     := $(mandir)/man1
>  man2dir     := $(mandir)/man2
> @@ -147,6 +150,12 @@ $(_manpages):
>  		-e '/^\.so /s, man7/\(.*\)\.7$$, $(notdir $(man7dir))/\1$(man7ext),' \
>  		-e '/^\.so /s, man8/\(.*\)\.8$$, $(notdir $(man8dir))/\1$(man8ext),' \
>  		$@
> +ifeq ($(LINK_PAGES),symlink)
> +	if $(GREP) '^\.so ' <$@ >/dev/null; then \
> +		$(SED) 's,^\.so \(.*\),../\1,' <$@ \
> +		| $(XARGS) -I tgt $(LN) -fsT tgt $@; \
> +	fi
> +endif
>  
>  $(_mandirs): %/.: | $$(dir %). $(_mandir)/.
>  

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-08  1:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-08  1:04 [PATCH] cmd.mk, install-man.mk: Allow installing link pages as symlinks Alejandro Colomar
2023-03-08  1:08 ` Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox