summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2022-10-18 19:20:44 +0200
committerAlejandro Colomar <alx@kernel.org>2022-10-18 19:23:19 +0200
commit8f97613a490f5b5bdb1156f4572424771e051020 (patch)
tree1d79cefcc88da3fb9e4ea7c642b18f3daf0bbb22
parent12f3af8e290a2d59679c3dfe865d0b3e7bffa5ed (diff)
Makefile, build-src.mk, dist.mk, verbose.mk, version.mk: Hide errors unless V is defined
Some commands run by the makefiles are not strictly needed by most users or packagers. Do not print errors if those fail spuriously. However, since we still want to see those errors in some cases, use the V variable to conditionally print those errors. Reported-by: Pierre Labastie <pierre.labastie@neuf.fr> Cc: Agostino Sarubbo <ago@gentoo.org> Cc: Mike Gilbert <floppym@gentoo.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
-rw-r--r--Makefile2
-rw-r--r--lib/build-src.mk9
-rw-r--r--lib/dist.mk3
-rw-r--r--lib/verbose.mk21
-rw-r--r--lib/version.mk3
5 files changed, 31 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 7dc08071e..a0dcf6fc3 100644
--- a/Makefile
+++ b/Makefile
@@ -130,7 +130,7 @@ include $(srcdir)/lib/install-man.mk
include $(srcdir)/lib/lint.mk
include $(srcdir)/lib/lint-c.mk
include $(srcdir)/lib/lint-man.mk
+include $(srcdir)/lib/verbose.mk
-$(V).SILENT:
FORCE:
diff --git a/lib/build-src.mk b/lib/build-src.mk
index fbb71503a..79c224edb 100644
--- a/lib/build-src.mk
+++ b/lib/build-src.mk
@@ -12,12 +12,13 @@ include $(srcdir)/lib/build.mk
include $(srcdir)/lib/cmd.mk
include $(srcdir)/lib/lint.mk
include $(srcdir)/lib/src.mk
+include $(srcdir)/lib/verbose.mk
PKG-CONFIG_LIBS := libbsd-overlay
-DEFAULT_CPPFLAGS := $(shell $(PKG-CONFIG) --cflags $(PKG-CONFIG_LIBS))
+DEFAULT_CPPFLAGS := $(shell $(PKG-CONFIG) --cflags $(PKG-CONFIG_LIBS) $(HIDE_ERR))
EXTRA_CPPFLAGS :=
CPPFLAGS := $(DEFAULT_CPPFLAGS) $(EXTRA_CPPFLAGS)
@@ -37,13 +38,13 @@ DEFAULT_LDFLAGS := -Wl,--as-needed
DEFAULT_LDFLAGS += -Wl,--no-allow-shlib-undefined
DEFAULT_LDFLAGS += -Wl,--no-copy-dt-needed-entries
DEFAULT_LDFLAGS += -Wl,--no-undefined
-DEFAULT_LDFLAGS += $(shell $(PKG-CONFIG) --libs-only-L $(PKG-CONFIG_LIBS))
-DEFAULT_LDFLAGS += $(shell $(PKG-CONFIG) --libs-only-other $(PKG-CONFIG_LIBS))
+DEFAULT_LDFLAGS += $(shell $(PKG-CONFIG) --libs-only-L $(PKG-CONFIG_LIBS) $(HIDE_ERR))
+DEFAULT_LDFLAGS += $(shell $(PKG-CONFIG) --libs-only-other $(PKG-CONFIG_LIBS) $(HIDE_ERR))
EXTRA_LDFLAGS :=
LDFLAGS := $(DEFAULT_LDFLAGS) $(EXTRA_LDFLAGS)
DEFAULT_LDLIBS := -lc
-DEFAULT_LDLIBS += $(shell $(PKG-CONFIG) --libs-only-l $(PKG-CONFIG_LIBS))
+DEFAULT_LDLIBS += $(shell $(PKG-CONFIG) --libs-only-l $(PKG-CONFIG_LIBS) $(HIDE_ERR))
EXTRA_LDLIBS :=
LDLIBS := $(DEFAULT_LDLIBS) $(EXTRA_LDLIBS)
diff --git a/lib/dist.mk b/lib/dist.mk
index 13f70929e..c95189fc4 100644
--- a/lib/dist.mk
+++ b/lib/dist.mk
@@ -12,12 +12,13 @@ include $(srcdir)/lib/build.mk
include $(srcdir)/lib/cmd.mk
include $(srcdir)/lib/install.mk
include $(srcdir)/lib/version.mk
+include $(srcdir)/lib/verbose.mk
_DISTDIR := $(builddir)/dist
-DISTFILES := $(shell $(GIT) ls-files 2>/dev/null | $(SED) 's,^,$(srcdir)/,')
+DISTFILES := $(shell $(GIT) ls-files $(HIDE_ERR) | $(SED) 's,^,$(srcdir)/,')
_DISTFILES := $(patsubst $(srcdir)/%,$(_DISTDIR)/%,$(DISTFILES))
_DISTPAGES := $(filter $(_DISTDIR)/man%,$(_DISTFILES))
_DISTOTHERS := $(filter-out $(_DISTDIR)/man%,$(_DISTFILES))
diff --git a/lib/verbose.mk b/lib/verbose.mk
new file mode 100644
index 000000000..edd05e9fc
--- /dev/null
+++ b/lib/verbose.mk
@@ -0,0 +1,21 @@
+########################################################################
+# Copyright (C) 2022 Alejandro Colomar <alx.manpages@gmail.com>
+# SPDX-License-Identifier: GPL-3.0
+########################################################################
+
+
+ifndef MAKEFILE_VERBOSE_INCLUDED
+MAKEFILE_VERBOSE_INCLUDED := 1
+
+
+ifdef V
+HIDE_ERR :=
+else
+HIDE_ERR := 2>/dev/null
+endif
+
+
+$(V).SILENT:
+
+
+endif # MAKEFILE_VERBOSE_INCLUDED
diff --git a/lib/version.mk b/lib/version.mk
index d0e705e90..ba02a94cb 100644
--- a/lib/version.mk
+++ b/lib/version.mk
@@ -9,9 +9,10 @@ MAKEFILE_VERSION_INCLUDED := 1
include $(srcdir)/lib/cmd.mk
+include $(srcdir)/lib/verbose.mk
-DISTNAME := $(shell $(GIT) describe 2>/dev/null)
+DISTNAME := $(shell $(GIT) describe $(HIDE_ERR))
DISTVERSION := $(patsubst man-pages-%,%,$(DISTNAME))