diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2023-02-09 22:33:31 +0100 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2023-02-10 17:50:27 +0100 |
commit | a0437225aa799ed4685e60534fcbdc867fd26947 (patch) | |
tree | 3e3e7d1ca0c65b56bf65ca25dd3913c184c3772e /include | |
parent | a032e07578ecdb459470cced8e118ce57088d033 (diff) | |
download | lvm2-a0437225aa799ed4685e60534fcbdc867fd26947.tar.gz |
makefiles: avoid piping
Addressing problem for user of system without default bash shell.
As reported "set -o pipefail" is a bashism that causes the build to
fail when /bin/sh does not point to bash.
For example, this has been observed causing build failures
on Gentoo when /bin/sh is symlinked to /bin/dash.
Rule has been reworked and we started to use .DELETE_ON_ERROR to
ensure that with any errors during file generation, such invalid
file is automatically removed.
Rules were reworked to avoid using pipe and instead use temporary
files when necessary.
Printing lines with echo was replaced with POSIX recomended 'printf'
as proposed by reporter since handling of escape characters and
the "-n" flag for "echo" aren't portable across shells.
Also some build deps has been added.
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1822280
Gentoo-bug: https://bugs.gentoo.org/682404
Gentoo-bug: https://bugs.gentoo.org/716496
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1822280
Reported-by: Michael Orlitzky <michael@orlitzky.com>
TODO: investage if the temporary files could be handled via some
intermediate target solution - ATM I couldn't make it work equally
well as current solution use shell 'trap' to remove temp file.
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.in | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/include/Makefile.in b/include/Makefile.in index fc184ed09..60b93f495 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2018 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2023 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -18,23 +18,23 @@ top_builddir = @top_builddir@ include $(top_builddir)/make.tmpl -cmds.h: +.DELETE_ON_ERROR: +cmds.h: $(top_srcdir)/tools/command-lines.in $(top_srcdir)/tools/license.inc Makefile @echo " [GEN] $@" - $(Q) set -o pipefail && \ + $(Q) \ ( cat $(top_srcdir)/tools/license.inc && \ echo "/* Do not edit. This file is generated by the Makefile. */" && \ echo "cmd(CMD_NONE, none)" && \ - $(GREP) '^ID:' $(top_srcdir)/tools/command-lines.in | LC_ALL=C $(SORT) -u | $(AWK) '{print "cmd(" $$2 "_CMD, " $$2 ")"}' && \ + trap "$(RM) $@-t" EXIT INT QUIT TERM && \ + $(AWK) '/^ID:/ {print "cmd(" $$2 "_CMD, " $$2 ")"}' $< >$@-t && \ + LC_ALL=C $(SORT) -u $@-t && \ echo "cmd(CMD_COUNT, count)" \ ) > $@ all: cmds.h -clean: - rm -f cmds.h - DISTCLEAN_TARGETS += configure.h lvm-version.h -CLEAN_TARGETS += \ +CLEAN_TARGETS += cmds.h cmds.h-t \ .symlinks \ .symlinks_created \ activate.h \ |