Commit Graph

26 Commits

Author SHA1 Message Date
Michael Pratt
14a3eadf05
verbose.mk: fallback to standard file descriptors
In order to pass a status message at runtime,
which is usually listing subtargets
of a Makefile target or an error message,
from a child invocation of Make (submake)
through the parent process to the terminal,
the file descriptors 8 and 9 are opened to be used
by the functions MESSAGE and ERROR_MESSAGE.

However, there are situations where those functions
can be called while not in a submake or a subshell
or a child process which results in a shell error:

/bin/bash: 8: Bad file descriptor

Commit aee3594ffc
("verbose.mk: print ERROR messages in non-verbose")
has exposed this issue to more cases, but it is not the root cause.

To solve this, use the exit code of the first printf attempt
to the alternative file descriptors in order to tell whether
the standard file descriptors need to be used instead.
In order to get rid of the "Bad file descriptor" error, stderr is
redirected to null after grouping the two printf alternatives
into one command to combine outputs.

For ERROR_MESSAGE, the real message is redirected to stderr
after redirecting the error from the attempted printing to null.

For MESSAGE, without redirection, the Make function "shell"
will absorb the actual message from stdout and input the value into the Makefile,
therefore the dummy variable "_NULL", previously used merely for causing
a call to the MESSAGE function to trigger without writing target rules,
now has and a real value when defined, so rename it to "_MESSAGE"
as a placeholder for the real message when the output should be stdout.

When "_MESSAGE" has a value, use Make function "info" to
finally bring it from the Makefile to the terminal.

This also fixes what is likely a typo, in that
while file descriptor 9 is meant to redirect to stderr
for use in error messages like in the function ERROR_MESSAGE,
that function has printf redirecting to file descriptor 8 instead.

Fixes: a4c8d4e37 ("build: make the color of the 'configuration out of sync' warning red")
Signed-off-by: Michael Pratt <mcpratt@pm.me>
2024-01-05 16:25:14 +01:00
Paul Spooren
aee3594ffc verbose.mk: print ERROR messages in non-verbose
Using `make -j9` only prints a subset of messages to follow the build
process progressing. However this silently skips over errors which might
be of interested. Using `make V=s` easily floods the terminal making it
hard to find error messages between the lines.

A compromise is the usage of `$(call ERROR_MESSAGE,...)` which prints a
message in red. This function is silenced in the non-verbose mode, even
if only used at a single place in `package/Makefile` where it notifies
about a OPKG corner case.

This commit moves the `ERROR_MESSAGE` definition outside of the
`OPENWRT_VERBOSE` condition and print error messages in every mode.

With this in place further error messages are possible.

Signed-off-by: Paul Spooren <mail@aparcar.org>
2022-02-28 23:52:13 +01:00
Paul Spooren
a17b8eaa2e build: use SPDX license tags
The license folder is a core part of OpenWrt and all GPL-2.0 licensed.
Use SPDX license tags to allow machines to check licenses.

Signed-off-by: Paul Spooren <mail@aparcar.org>
[rebase, keep some Copyright lines, sharpen commit message]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-02-05 14:54:47 +01:00
Daniel Engberg
0aaa650755 include/verbose.mk: Add sc to failure message
Add sc to build error message

Signed-off-by: Daniel Engberg <daniel.engberg.lists@pyret.net>
2018-07-30 10:43:36 +02:00
李国
671999157d verbose.mk: quote SUBMAKE options
build openwrt on centos 6 I should use devtoolset-3 to get gcc 4.9, but
it fail when make menuconfig. so I have to give option HOSTCC='gcc
-Wl,--copy-dt-needed-entries' to make. But it passed to sub make to
HOSTCC=gcc as micro SUBMAKE expand to HOSTCC=gcc
-Wl,--copy-dt-needed-entries. This patch fix this issue.

make -C build menuconfig HOSTCC='gcc -Wl,--copy-dt-needed-entries' V='1'
make: Entering directory `/work/openwrt/openwrt/build'
/opt/rh/devtoolset-3/root/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/ld:
lxdialog/checklist.o: undefined reference to symbol 'acs_map'
//lib64/libtinfo.so.5: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [mconf] Error 1
make -s -C scripts/config all CC=gcc -Wl,--copy-dt-needed-entries: build
failed. Please re-run make with -j1 V=s to see what's going on
make: *** [scripts/config/mconf] Error 1
make: Leaving directory `/work/openwrt/openwrt/build'

Signed-off-by: 李国 <uxgood.org@gmail.com>
2018-07-12 10:24:36 +02:00
Felix Fietkau
a0ced5164a build: tell users to do non-paralle builds on errors
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 45457
2015-04-16 12:18:26 +00:00
Luka Perkov
7002f6326e include: remove trailing whitespaces
Signed-off-by: Luka Perkov <luka@openwrt.org>

SVN-Revision: 45127
2015-03-29 07:29:18 +00:00
Felix Fietkau
a4c8d4e377 build: make the color of the 'configuration out of sync' warning red to make it harder for users to overlook
SVN-Revision: 36082
2013-03-17 21:12:02 +00:00
Felix Fietkau
6af6c0ae76 build: fix bad file descriptor issues with the verbosity changes
SVN-Revision: 31486
2012-04-26 18:13:17 +00:00
Felix Fietkau
34ffb526a2 build: rework verbosity level selection
V=99 and V=1 are now deprecated in favor of a new verbosity class system,
though the old flags are still supported.
You can set the V variable on the command line (or OPENWRT_VERBOSE in the
environment) to one or more of the following characters:

- s: stdout+stderr (equal to the old V=99)
- c: commands (for build systems that suppress commands by default, e.g. kbuild)
- w: warnings/errors only (equal to the old V=1)

SVN-Revision: 31484
2012-04-26 17:53:56 +00:00
Lars-Peter Clausen
6f3db147b6 Allow colored output to be disabled when running a non-verbose build by setting NO_COLOR=1
SVN-Revision: 19560
2010-02-08 22:28:19 +00:00
Mike Baker
129a1e0714 disable stdin unless make V=99; fixes bug where compilation can stall waiting for input
SVN-Revision: 19511
2010-02-04 04:43:17 +00:00
Felix Fietkau
4af8308788 make sure that processed directories are printed on make V=99
SVN-Revision: 19174
2010-01-16 22:18:56 +00:00
Felix Fietkau
34939cad39 get rid of $Id$ - it has never helped us and it has broken too many patches ;)
SVN-Revision: 15242
2009-04-17 14:09:46 +00:00
Felix Fietkau
dea3f68b35 use file descriptors 8 and 9 for build system internal log messages, as apparently bash does not like fds greater than 9 in shell commands on some systems
SVN-Revision: 11515
2008-06-16 21:57:57 +00:00
Felix Fietkau
4c665e6ca4 large improvement for parallel builds. works without V=99 now and without warnings. tested with -j on an 2x dual core opteron machine
SVN-Revision: 11414
2008-06-09 15:38:45 +00:00
Felix Fietkau
31a3a503cc add a flag "IGNORE_ERRORS", which can be used to ignore build errors in packages
SVN-Revision: 11059
2008-05-07 16:45:00 +00:00
Andy Boyett
ec849ba7c8 use printf instead of echo
SVN-Revision: 9932
2007-12-26 20:54:39 +00:00
Felix Fietkau
40840d495f add shell compatibility patch from #2659
SVN-Revision: 9643
2007-11-30 21:58:18 +00:00
Felix Fietkau
49e628f765 next round of build system cleanup - convert package/ to new structure
SVN-Revision: 8236
2007-07-30 18:22:01 +00:00
Felix Fietkau
e23c6c4b6b fix verbose output with dash as /bin/sh
SVN-Revision: 8227
2007-07-30 14:50:15 +00:00
Felix Fietkau
9c88ba80b9 more build system cleanup
SVN-Revision: 8206
2007-07-28 13:00:43 +00:00
Mike Baker
9b62c7eb9d minor tweaks to the verbose system
SVN-Revision: 6936
2007-04-11 22:59:42 +00:00
Mike Baker
9fffc68101 fix colors when compiling with some newer versions of bash
SVN-Revision: 6231
2007-01-30 18:30:20 +00:00
Felix Fietkau
cf10a1dd5e another optimization
SVN-Revision: 5507
2006-11-12 01:55:28 +00:00
Felix Fietkau
60c1f0f64d finally move buildroot-ng to trunk 2016-03-20 17:29:15 +01:00