public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: linux-man@vger.kernel.org,
	"G. Branden Robinson" <g.branden.robinson@gmail.com>
Cc: Alejandro Colomar <alx@kernel.org>, Marcos Fouces <marcos@debian.org>
Subject: [PATCH] cmd.mk, install-man.mk: Allow installing link pages as symlinks
Date: Wed,  8 Mar 2023 02:04:19 +0100	[thread overview]
Message-ID: <20230308010418.174517-1-alx@kernel.org> (raw)

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


             reply	other threads:[~2023-03-08  1:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08  1:04 Alejandro Colomar [this message]
2023-03-08  1:08 ` [PATCH] cmd.mk, install-man.mk: Allow installing link pages as symlinks Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230308010418.174517-1-alx@kernel.org \
    --to=alx.manpages@gmail.com \
    --cc=alx@kernel.org \
    --cc=g.branden.robinson@gmail.com \
    --cc=linux-man@vger.kernel.org \
    --cc=marcos@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox