[PATCH v1] share/mk/: Reduce the work of 'make && make install'

Alejandro Colomar <[email protected]> Thu, 18 Jul 2024 12:30:28 +0200
Newsgroups dev.linux.lists.liba2i
Message-ID <[email protected]>
--cq5ceeifqhx4gijc
Content-Type: text/plain; protected-headers=v1; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
From: Alejandro Colomar <[email protected]>
To: [email protected]
Cc: Alejandro Colomar <[email protected]>, Sam James <[email protected]>
Subject: [PATCH v1] share/mk/: Reduce the work of 'make && make install'
MIME-Version: 1.0

Distros expect 'make' to build only what they need.  While we want to
build more stuff upstream, for various reasons (mainly, for extra
diagnostics), packagers only want what they'll use, and don't want to
waste CPU time with that.

Also, distros expect 'make install' to only install what they'll use,
which is just the headers, the pc(5) file, the shared library, and the
manual pages.  They usually don't want a static library.

For that, repurpose the build and install targets to do precisely that,
and add build-all and install-all targets that do all that can be done.

Reported-by: Sam James <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
---

Hi Sam,

I'll apply this patch, which is what I think you want.  With this, and
except for environment variables being ignored (the next release of GNU
make(1) that contains the bugfix I need for solving this), I think this
should build as any build system would expect.  (Hopefully I won't be
missing any other details.  As always, I'm sorry if that happens.)

	alx@debian:~/src/alx/liba2i/contrib$ make clean
	RM -rf		.tmp
	alx@debian:~/src/alx/liba2i/contrib$ make
	MKDIR		.tmp/a2i/a2i/
	MKDIR		.tmp/a2i/str2i/
	MKDIR		.tmp/a2i/strtoi/strtoi/
	MKDIR		.tmp/a2i/strtoi/strtou/
	MKDIR		.tmp/a2i/strtoi/strtou_noneg/
	SED		.tmp/liba2i-uninstalled.pc
	LD		.tmp/liba2i.so.1.0-rc3-2-gbacec0a1b
	LN		.tmp/liba2i.so.1
	LN		.tmp/liba2i.so
	alx@debian:~/src/alx/liba2i/contrib$ make install DESTDIR=3D/tmp/asdf
	MKDIR		/tmp/asdf/usr/local/include/a2i/a2i/
	INSTALL		/tmp/asdf/usr/local/include/a2i/a2i/a2i.h
	INSTALL		/tmp/asdf/usr/local/include/a2i/a2i/a2s.h
	INSTALL		/tmp/asdf/usr/local/include/a2i/a2i/a2s_.h
	INSTALL		/tmp/asdf/usr/local/include/a2i/a2i/a2u.h
	INSTALL		/tmp/asdf/usr/local/include/a2i/a2i/a2u_.h
	INSTALL		/tmp/asdf/usr/local/include/a2i/attr.h
	INSTALL		/tmp/asdf/usr/local/include/a2i/inline.h
	INSTALL		/tmp/asdf/usr/local/include/a2i/qual.h
	MKDIR		/tmp/asdf/usr/local/include/a2i/str2i/
	INSTALL		/tmp/asdf/usr/local/include/a2i/str2i/str2i.h
	INSTALL		/tmp/asdf/usr/local/include/a2i/str2i/str2s.h
	INSTALL		/tmp/asdf/usr/local/include/a2i/str2i/str2u.h
	MKDIR		/tmp/asdf/usr/local//lib/pkgconfig/
	INSTALL		/tmp/asdf/usr/local//lib/pkgconfig/liba2i.pc
	INSTALL		/tmp/asdf/usr/local//lib/liba2i.so.1.0-rc3-2-gbacec0a1b
	LN		/tmp/asdf/usr/local//lib/liba2i.so.1
	LN		/tmp/asdf/usr/local//lib/liba2i.so
	MKDIR		.tmp/man/man3/
	SED		.tmp/man/man3/a2i.3
	MKDIR		/tmp/asdf/usr/local/share/man/man3/
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2i.3
	SED		.tmp/man/man3/a2s.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2s.3
	CP		.tmp/man/man3/a2sh.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2sh.3
	CP		.tmp/man/man3/a2shh.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2shh.3
	CP		.tmp/man/man3/a2si.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2si.3
	CP		.tmp/man/man3/a2sl.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2sl.3
	CP		.tmp/man/man3/a2sll.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2sll.3
	SED		.tmp/man/man3/a2u.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2u.3
	CP		.tmp/man/man3/a2uh.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2uh.3
	CP		.tmp/man/man3/a2uhh.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2uhh.3
	CP		.tmp/man/man3/a2ui.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2ui.3
	CP		.tmp/man/man3/a2ul.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2ul.3
	CP		.tmp/man/man3/a2ull.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/a2ull.3
	SED		.tmp/man/man3/str2i.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2i.3
	SED		.tmp/man/man3/str2s.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2s.3
	CP		.tmp/man/man3/str2sh.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2sh.3
	CP		.tmp/man/man3/str2shh.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2shh.3
	CP		.tmp/man/man3/str2si.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2si.3
	CP		.tmp/man/man3/str2sl.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2sl.3
	CP		.tmp/man/man3/str2sll.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2sll.3
	SED		.tmp/man/man3/str2u.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2u.3
	CP		.tmp/man/man3/str2uh.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2uh.3
	CP		.tmp/man/man3/str2uhh.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2uhh.3
	CP		.tmp/man/man3/str2ui.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2ui.3
	CP		.tmp/man/man3/str2ul.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2ul.3
	CP		.tmp/man/man3/str2ull.3
	INSTALL		/tmp/asdf/usr/local/share/man/man3/str2ull.3

Have a lovely day!
Alex

Range-diff against v0:
-:  --------- > 1:  bacec0a1b share/mk/: Reduce the work of 'make && make i=
nstall'

 share/mk/build/_.mk          |  9 +++++++--
 share/mk/build/lib/_.mk      |  2 +-
 share/mk/build/lib/shared.mk | 11 ++++++++++-
 share/mk/install/_.mk        |  5 ++++-
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/share/mk/build/_.mk b/share/mk/build/_.mk
index ea16d4dfc..d1fecf6d9 100644
--- a/share/mk/build/_.mk
+++ b/share/mk/build/_.mk
@@ -12,8 +12,8 @@ include $(MAKEFILEDIR)/configure/directory_variables/buil=
d.mk
 _MANDIR :=3D $(builddir)/man
=20
=20
-.PHONY: build
-build: \
+.PHONY: build-all
+build-all: \
 	build-catman \
 	build-dev \
 	build-html \
@@ -24,5 +24,10 @@ build: \
 	build-ps \
 	build-ex;
=20
+.PHONY: build
+build: \
+	build-dev \
+	build-lib-shared;
+
=20
 endif  # include guard
diff --git a/share/mk/build/lib/_.mk b/share/mk/build/lib/_.mk
index 8b3c439a9..2320279e0 100644
--- a/share/mk/build/lib/_.mk
+++ b/share/mk/build/lib/_.mk
@@ -7,7 +7,7 @@ MAKEFILE_BUILD_LIB_INCLUDED :=3D 1
=20
=20
 .PHONY: build-lib
-build-lib: build-lib-shared build-lib-static;
+build-lib: build-lib-shared build-lib-shared-allO build-lib-static;
=20
=20
 endif  # include guard
diff --git a/share/mk/build/lib/shared.mk b/share/mk/build/lib/shared.mk
index 8132f9e8b..d4387ba6c 100644
--- a/share/mk/build/lib/shared.mk
+++ b/share/mk/build/lib/shared.mk
@@ -18,12 +18,18 @@ _REALNAME   :=3D $(builddir)/$(REALNAME)
 _SONAME     :=3D $(builddir)/$(SONAME)
 _LINKERNAME :=3D $(builddir)/$(LINKERNAME)
=20
+_REALNAME_ALLO :=3D $(_REALNAME).allO.touch
=20
-$(_REALNAME): %.so.$(DISTVERSION): $(TU_h) $(TU_c) $(MK) $(LIB_pc) | $$(@D=
)/
+
+$(_REALNAME_ALLO): %.so.$(DISTVERSION).allO.touch: $(TU_h) $(TU_c) $(MK) $=
(LIB_pc) | $$(@D)/
 	$(info	$(INFO_)LD		$@)
 	for opt in g 0 1 2 s z 3 fast; do \
 	$(LD) $(LDFLAGS_) -O$$opt -o $*.O$$opt.so.$(DISTVERSION) $(TU_c) $(LDLIBS=
_); \
 	done
+
+
+$(_REALNAME): %.so.$(DISTVERSION): $(TU_h) $(TU_c) $(MK) $(LIB_pc) | $$(@D=
)/
+	$(info	$(INFO_)LD		$@)
 	$(LD) $(LDFLAGS_)         -o $@                          $(TU_c) $(LDLIBS=
_)
=20
=20
@@ -40,5 +46,8 @@ $(_LINKERNAME): $(_SONAME) $(MK) | $$(@D)/
 .PHONY: build-lib-shared
 build-lib-shared: $(_LINKERNAME);
=20
+.PHONY: build-lib-shared-allO
+build-lib-shared-allO: $(_REALNAME_ALLO);
+
=20
 endif  # include guard
diff --git a/share/mk/install/_.mk b/share/mk/install/_.mk
index 15a030361..f54b05a2d 100644
--- a/share/mk/install/_.mk
+++ b/share/mk/install/_.mk
@@ -19,8 +19,11 @@ include $(MAKEFILEDIR)/configure/build-depends/coreutils=
/rm.mk
 	$(RM) $*
=20
=20
+.PHONY: install-all
+install-all: install-dev install-lib install-man;
+
 .PHONY: install
-install: install-dev install-lib install-man;
+install: install-dev install-lib-shared install-man;
=20
 .PHONY: uninstall
 uninstall: uninstall-dev uninstall-lib uninstall-man;

base-commit: 92a9c89855347bc335f00eea3d4aa56c667edd6f
--=20
2.45.2


--cq5ceeifqhx4gijc
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmaY7sQACgkQnowa+77/
2zK6pw//WJKEgAizsXGkECGQhXFLCgpmy5DVgV9gP8HQokMBIsRhx+pH0OYcDCF3
Qs+ekmyTTSq+fZSwG3nRr8Pp04C0lofG5z3VK/2EEs93Vfq9HpApa24/0fEcMZUT
f3N3Z6HJiSJHz12Ywy9zEMC80URRUB/I22xvOAjaDjuVnRm6k689qH34ogbiIstE
7M3h93ErkMUD52d1dJLe74pioHN9ufVuQNAPYcXxxxd5o3jSqOnAu5C8/we6RMad
g5GBTfUgAihW/NIWw5Ug3VPhAw5Om625vLlDV6rCYET1eSQsQm/mBc5TfSkvd7Z9
8HnLgVLoucNGY713T8pL9+reOM59GzzwecqPrxriZLrDfRthzT8RuEGFfszk6HyL
DDFPiJ+5SzcnCOVSuSCikZdc5osDPxwA0JBsnyui47Eqa+DrNJpIc1mMmtC7j+Am
sh9M6C5SvC9kxK2FWxLJDlZurhZ6XLIc1Sjo8OeUd3m/UXbCSNQqMAUzICIJgZEX
PtVg5abX7Pb/gDJfrjvx0RZFqu/WcZoteO1FczVfrMzXz1m9t6hypx7OwXFB0mRQ
YRzotAX35/fHW+jshc/sD3lOEOeWJ5ZBdaYLooPJLnvKyDBkHcYqY50glJv1skQr
4tAnYmYySfsupwZ5Dcx/9/FKfiQIm1f+JeT8nJgwa/0yRPJWxXQ=
=Kr2Z
-----END PGP SIGNATURE-----

--cq5ceeifqhx4gijc--