Menu

Commit [r13008]  Maximize  Restore  History

Detect optional build tools with "command -v", not "type"

Reported building r13007 on Ubuntu 26.04: the build stops in
lib/libui/ui_xml/uilib because it tries to run flexml, which is not installed.

It should never have tried. uilib/Makefile already falls back to the
checked-in xml/pregenerated/ copies of triggers.c, triggers_act.c and
triggers.h when flexml is missing:

HASFLEXML:=$(shell type flexml 2> /dev/null)
ifeq "$(HASFLEXML)" ""
TRIGGERS_O=xml/pregenerated/triggers.o xml/pregenerated/triggers_act.o

but the probe is not safe. "type" is a shell builtin whose behaviour for a
missing command differs: bash writes "flexml: not found" to stderr, so the
redirect hides it and HASFLEXML ends up empty, while dash - which is /bin/sh
on Debian and Ubuntu - writes it to stdout, where the redirect does not touch
it. HASFLEXML is then the non-empty string "flexml: not found", the makefile
concludes flexml is available, and make runs it and fails:

$ dash -c 'type flexml 2> /dev/null'
flexml: not found
$ dash -c 'command -v flexml 2>/dev/null'
$

"command -v" is the POSIX way to ask this and prints a path on stdout only
when the command exists, on either shell.

Fixed in all ten probes of this shape, not just the one that bit:
lib/libui/ui_xml/uilib/Makefile and uilib/xml/Makefile (flexml),
lib/libpacker/xml_best, xml_best2 and xml_best_plsql (flexml and a pregenerated
flex), and lib/extra_libs/mantisconnect (soapcpp2). All had the same latent
failure - each would have tried to run a tool that is not there.

Not reproduced end to end here: this box has bash as /bin/sh and GNU Make 4.3,
where the old probe happens to come back empty and the pregenerated files are
used, which is why the tree built fine for me at r13006. What is demonstrated
is the probe itself being unsafe under dash, and that both shells now select
xml/pregenerated/. The exact combination on the reporter's machine (dash plus a
newer make) is inferred.

The warnings quoted alongside the failure - comms.c sign-compare and unused
'p', uilib.c type-limits, attr.c redundant xml_yylex - are untouched; they are
warnings, not the reason the build stopped.

mikeaubury 1 day ago

changed /aubit4glsrc/trunk/lib/extra_libs/mantisconnect/Makefile
changed /aubit4glsrc/trunk/lib/libpacker/xml_best/Makefile
changed /aubit4glsrc/trunk/lib/libui/ui_xml/uilib/Makefile
changed /aubit4glsrc/trunk/lib/libui/ui_xml/uilib/xml/Makefile
/aubit4glsrc/trunk/lib/extra_libs/mantisconnect/Makefile Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/lib/libpacker/xml_best/Makefile Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/lib/libui/ui_xml/uilib/Makefile Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/lib/libui/ui_xml/uilib/xml/Makefile Diff Switch to side-by-side view
Loading...