From: Alejandro Colomar Date: Wed, 8 Mar 2023 01:02:31 +0000 (+0100) Subject: cmd.mk, install-man.mk: Allow installing link pages as symlinks X-Git-Tag: man-pages-6.04~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=335acbfbbd151b824e53d94c5aec85d2ee5a051a;p=thirdparty%2Fman-pages.git 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'. Example: $ make install LINK_PAGES=symlink Signed-off-by: Alejandro Colomar --- diff --git a/INSTALL b/INSTALL index da1e53e6b3..63bbf169b0 100644 --- a/INSTALL +++ b/INSTALL @@ -85,6 +85,7 @@ Description - For installing: - install(1) + - ln(1) - For uninstalling / cleaning: - rm(1) diff --git a/lib/cmd.mk b/lib/cmd.mk index 17f3a8ee55..9cd09fe895 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 174f503ca9..a919c40865 100644 --- a/lib/install-man.mk +++ b/lib/install-man.mk @@ -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)/.