On Sun, May 29, 2022 at 12:09 PM Paul Smith <psm...@gnu.org> wrote: > On Sun, 2022-05-29 at 11:50 -0400, Pierre Rouleau wrote: > > On Sat, May 28, 2022 at 2:11 AM Kaz Kylheku <k...@kylheku.com> wrote: > > > What you probably want is to generate clauses joined by && > > > > > > $(foreach ....) --> patch < this && patch < that && ... && patch > > > < last > > > > > > You mean unroll the loop manually? > > Unfortunately the file I'm dealing with is part of a *large* build > > system with over 2000 make file, with make recursion and multi-layer > > decision making that end up building the list of patch files, > > storing it inside a variable. > > > > Are you also saying that adding `|| exit 1' to the statement inside > > the foreach loop would not work? > > ie as in: > > (cd $(OUTPUT_ROOT_DIR)/$(CFG_GLOBAL_LINUX_VERSION); $(foreach > > thepatch,$(KERNEL_PATCH_ONE),echo patching $(thepatch); patch > > --ignore-whitespace -p1 < $(thepatch) || exit 1;)) > > It will work. It's simple to test so did you try it and it didn't work > and that's why you're asking? >
I did try and it worked, but since I could not find documentation on it I wanted to double check. I must say I find debugging large makefile sets difficult. > > But I don't understand why the method Kaz suggests wouldn't work. If > you can change the loop to add "|| exit 1;" after each patch command > why can't you change the loop to add "&&" between each patch command? > I can, I just misunderstood Kaz reply. > It would be something like: > > $(foreach p,$(KERNEL_PATCH_ONE),echo patching $p && patch ... < $p &&) > true > > The advantage of the "&&" is that your script is shorter which means > you'll be less likely to run into a limit for lots of patches (although > the limits in modern POSIX systems are pretty large). > > In what sense is the script shorter? Is it not the same as with the ; separator except that it acts as a logic AND? > In the end do you mean that all I could do is prepend the rule with > > `set -e; ' and that would ensure termination on the first error? > > As in: > > set -e; (cd $(OUTPUT_ROOT_DIR)/$(CFG_GLOBAL_LINUX_VERSION); > > $(foreach thepatch,$(KERNEL_PATCH_ONE),echo patching $(thepatch); > > patch > > --ignore-whitespace -p1 < $(thepatch))) > > You need a semicolon after the patch command but yes, this will work as > well. > Correct, I should have kept it in there. Thanks -- /Pierre