Skip to contentSkip to conversation

cmd.mk, install-man.mk: Allow installing link pages as symlinks

PATCH In review Alejandro Colomar 1 participant 2 messages Mar 8, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd.mk, install-man.mk: Allow installing link pages as symlinks

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'.

---

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(+)
lib/cmd.mk +1 -0
index 17f3a8ee5..9cd09fe89 100644
@@ -16,6 +16,7 @@ GREP       := grep
 GZIP       := gzip
 HEAD       := head
 INSTALL    := install
+LN         := ln
 LOCALE     := locale
 PKG-CONFIG := pkg-config
 SED        := sed
lib/install-man.mk +9 -0
index 174f503ca..aaa545290 100644
@@ -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)/.
 
Signature · 1 line
2.39.2
#1 lore raw
Quoted 5 lines · Alejandro Colomar

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'.

Quoted 8 lines

---

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. :)

Quoted 53 lines

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(+)
lib/cmd.mk +1 -0
index 17f3a8ee5..9cd09fe89 100644
@@ -16,6 +16,7 @@ GREP       := grep
 GZIP       := gzip
 HEAD       := head
 INSTALL    := install
+LN         := ln
 LOCALE     := locale
 PKG-CONFIG := pkg-config
 SED        := sed
lib/install-man.mk +9 -0
index 174f503ca..aaa545290 100644
@@ -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)/.
 
Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5