]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
cmd.mk, install-man.mk: Allow installing link pages as symlinks
authorAlejandro Colomar <alx@kernel.org>
Wed, 8 Mar 2023 01:02:31 +0000 (02:02 +0100)
committerAlejandro Colomar <alx@kernel.org>
Wed, 8 Mar 2023 23:05:40 +0000 (00:05 +0100)
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'.

Example:

    $ make install LINK_PAGES=symlink

Signed-off-by: Alejandro Colomar <alx@kernel.org>
INSTALL
lib/cmd.mk
lib/install-man.mk

diff --git a/INSTALL b/INSTALL
index da1e53e6b325d0834e45dd10ffcea9603d790c62..63bbf169b06e701eaa87ca0225838878cae9f631 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -85,6 +85,7 @@ Description
 
           -  For installing:
              -  install(1)
+             -  ln(1)
 
           -  For uninstalling / cleaning:
              -  rm(1)
index 17f3a8ee556a418ea141841fa0f2b8e9b2903a09..9cd09fe895e65608820861925d14862af2e3468d 100644 (file)
@@ -16,6 +16,7 @@ GREP       := grep
 GZIP       := gzip
 HEAD       := head
 INSTALL    := install
+LN         := ln
 LOCALE     := locale
 PKG-CONFIG := pkg-config
 SED        := sed
index 174f503ca95c3595a2cfea59d481c1756387394d..a919c408656c994659c2308637d53ca7949ab605 100644 (file)
@@ -8,10 +8,20 @@ ifndef MAKEFILE_INSTALL_MAN_INCLUDED
 MAKEFILE_INSTALL_MAN_INCLUDED := 1
 
 
+include $(srcdir)/lib/cmd.mk
 include $(srcdir)/lib/install.mk
 include $(srcdir)/lib/src.mk
 
 
+LINK_PAGES := .so
+ifeq ($(LINK_PAGES),.so)
+else ifeq ($(LINK_PAGES),symlink)
+else
+$(warning "LINK_PAGES": "$(LINK_PAGES)")
+$(error Valid values for "LINK_PAGES": [".so", "symlink"])
+endif
+
+
 mandir      := $(datarootdir)/man
 man1dir     := $(mandir)/man1
 man2dir     := $(mandir)/man2
@@ -147,6 +157,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)/.