Hi Paul, On 2023-08-26 18:48, Paul Smith wrote: > I added a new appendix to the GNU make manual for troubleshooting help; > I haven't pushed it yet. See below. Comments welcome. > > I think the outline you provided earlier, Bruno, has the problem that a > lot of it isn't really about troubleshooting per se, it's about how to > write makefiles in general. I tried to restrict this specifically to > describing the types of problems you might see and the steps you might > take to troubleshoot them. > > I'm thinking of adding another chapter on hints and tips for writing > good makefiles. > > ----------------- > Appendix C Troubleshooting Make and Makefiles > ********************************************* > > Troubleshooting 'make' and makefiles can be tricky. There are two > reasons: first, makefiles are not procedural programs and many users are > used to procedural languages and scripts. Second, makefiles consist of > two different syntaxes in one file: makefile syntax, that 'make' reads, > and shell syntax, which is sent to a shell program for parsing and > execution. > > If you have problems with GNU Make, first consider the type of > problem you are having. Problems will generally be in one of these > categories: > > * A syntax or other error was reported when 'make' attempted to parse > your makefiles. > > * A command that 'make' invoked failed (exited with a non-0 exit > code). > > * The command that 'make' invoked was not the one you expected. > > * 'make' was not able to find a rule to build a target. > > * 'make' rebuilds a target that you didn't think was out of date. > > * Or, 'make' did not rebuild a target that you expected it to build.
Let's add one more: - Make has problems running the SHELL ``` $ cat Makefile SHELL := /usr/bin/env -S bash -Eeuo pipefail foo: $(info FOO) echo foo $ make FOO echo foo foo ``` All good so far. Let's try .ONESHELL: ``` $ cat Makefile SHELL := /usr/bin/env -S bash -Eeuo pipefail foo: $(info FOO) echo foo .ONESHELL: $ make FOO echo foo make: /usr/bin/env -S bash -Eeuo pipefail: No such file or directory make: *** [Makefile:3: foo] Error 127 ``` Kaboom. :( Okay, I know I should be using .SHELLFLAGS. Let's see. ``` $ cat Makefile SHELL := /usr/bin/env .SHELLFLAGS := -S bash -Eeuo pipefail foo: $(info FOO) echo foo .ONESHELL: $ make FOO echo foo bash: echo foo: No such file or directory make: *** [Makefile:4: foo] Error 1 ``` Ain't good either. At least now it's a 1. Anyway, let's try without .ONESHELL: ``` $ cat Makefile SHELL := /usr/bin/env .SHELLFLAGS := -S bash -Eeuo pipefail foo: $(info FOO) echo foo $ make FOO echo foo bash: echo foo: No such file or directory make: *** [Makefile:5: foo] Error 1 ``` Still kaboom. In the end, I found that the problem is that you don't pipe the scripts to the shell, but rather pass them as an argument, isn't it? I'm not sure why this became a problem to me only when starting to use .ONESHELL, though. Cheers, Alex -- <http://www.alejandro-colomar.es/> GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
OpenPGP_signature
Description: OpenPGP digital signature