Skip to content

Commit da38f7b

Browse files
committed
Makefile: fix code blocks that need to all be ran subsequently without failing
Signed-off-by: Thierry Laurion <[email protected]>
1 parent 5226db3 commit da38f7b

File tree

1 file changed

+68
-68
lines changed

1 file changed

+68
-68
lines changed

Makefile

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -400,52 +400,52 @@ define define_module =
400400
# module-specific cleanup action to get rid of it.
401401
$(build)/$($1_base_dir)/.canary: FORCE
402402
if [ ! -e "$$@" ]; then \
403-
echo "INFO: .canary file not found. Cloning repository $($1_repo) into $(build)/$($1_base_dir)"; \
404-
git clone $($1_repo) "$(build)/$($1_base_dir)"; \
405-
echo "INFO: Resetting repository to commit $($1_commit_hash)"; \
406-
git -C "$(build)/$($1_base_dir)" reset --hard $($1_commit_hash); \
407-
echo "INFO: Creating .canary file with repo and commit hash"; \
408-
echo -n '$($1_repo)|$($1_commit_hash)' > "$$@"; \
403+
echo "INFO: .canary file not found. Cloning repository $($1_repo) into $(build)/$($1_base_dir)" && \
404+
git clone $($1_repo) "$(build)/$($1_base_dir)" && \
405+
echo "INFO: Resetting repository to commit $($1_commit_hash)" && \
406+
git -C "$(build)/$($1_base_dir)" reset --hard $($1_commit_hash) && \
407+
echo "INFO: Creating .canary file with repo and commit hash" && \
408+
echo -n '$($1_repo)|$($1_commit_hash)' > "$$@" ; \
409409
elif [ "$$$$(cat "$$@")" != '$($1_repo)|$($1_commit_hash)' ]; then \
410-
echo "INFO: Canary file differs. Switching $1 to $($1_repo) at $($1_commit_hash)"; \
410+
echo "INFO: Canary file differs. Switching $1 to $($1_repo) at $($1_commit_hash)" && \
411411
git -C "$(build)/$($1_base_dir)" reset --hard HEAD^ && \
412-
echo "INFO: Fetching commit $($1_commit_hash) from $($1_repo) (without recursing submodules)"; \
412+
echo "INFO: Fetching commit $($1_commit_hash) from $($1_repo) (without recursing submodules)" && \
413413
git -C "$(build)/$($1_base_dir)" fetch $($1_repo) $($1_commit_hash) --recurse-submodules=no && \
414-
echo "INFO: Resetting repository to commit $($1_commit_hash)"; \
415-
git -C "$(build)/$($1_base_dir)" reset --hard $($1_commit_hash); \
416-
echo "INFO: Cleaning repository directory (including payloads and util/cbmem)"; \
414+
echo "INFO: Resetting repository to commit $($1_commit_hash)" && \
415+
git -C "$(build)/$($1_base_dir)" reset --hard $($1_commit_hash) && \
416+
echo "INFO: Cleaning repository directory (including payloads and util/cbmem)" && \
417417
git -C "$(build)/$($1_base_dir)" clean -df && \
418418
git -C "$(build)/$($1_base_dir)" clean -dffx payloads util/cbmem && \
419-
echo "INFO: Synchronizing submodules"; \
419+
echo "INFO: Synchronizing submodules" && \
420420
git -C "$(build)/$($1_base_dir)" submodule sync && \
421-
echo "INFO: Updating submodules (init and checkout)"; \
421+
echo "INFO: Updating submodules (init and checkout)" && \
422422
git -C "$(build)/$($1_base_dir)" submodule update --init --checkout && \
423-
echo "INFO: Updating .canary file with new repo info"; \
424-
echo -n '$($1_repo)|$($1_commit_hash)' > "$$@"; \
423+
echo "INFO: Updating .canary file with new repo info" && \
424+
echo -n '$($1_repo)|$($1_commit_hash)' > "$$@" ; \
425425
fi
426426
if [ ! -e "$(build)/$($1_base_dir)/.patched" ]; then \
427-
echo "INFO: .patched file not found. Beginning patch application for $1"; \
427+
echo "INFO: .patched file not found. Beginning patch application for $1" && \
428428
if [ -r patches/$($1_patch_name).patch ]; then \
429-
echo "INFO: Found patch file patches/$($1_patch_name).patch. Applying patch..."; \
429+
echo "INFO: Found patch file patches/$($1_patch_name).patch. Applying patch..." && \
430430
if ! ( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ); then \
431-
echo "ERROR: Failed to apply patch patches/$($1_patch_name).patch. Reversing and reapplying."; \
432-
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || true; \
433-
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || exit 1; \
434-
fi; \
431+
echo "ERROR: Failed to apply patch patches/$($1_patch_name).patch. Reversing and reapplying." && \
432+
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || true && \
433+
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || exit 1 ; \
434+
fi ; \
435435
fi && \
436436
if [ -d patches/$($1_patch_name) ] && \
437437
[ -r patches/$($1_patch_name) ] || [ -n "$$(ls patches/$($1_patch_name)/*.patch 2>/dev/null)" ]; then \
438438
for patch in patches/$($1_patch_name)/*.patch ; do \
439-
echo "Applying patch file : $$$$patch " ; \
439+
echo "Applying patch file : $$$$patch " && \
440440
if ! ( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ); then \
441-
echo "ERROR: Failed to apply patch $$$$patch. Reversing and reapplying."; \
442-
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || true; \
443-
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || exit 1; \
444-
fi; \
441+
echo "ERROR: Failed to apply patch $$$$patch. Reversing and reapplying." && \
442+
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || true && \
443+
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || exit 1 ; \
444+
fi ; \
445445
done ; \
446446
fi && \
447-
echo "INFO: Patches applied successfully. Creating .patched file"; \
448-
touch "$(build)/$($1_base_dir)/.patched"; \
447+
echo "INFO: Patches applied successfully. Creating .patched file" && \
448+
touch "$(build)/$($1_base_dir)/.patched" ; \
449449
fi
450450
else
451451
# Versioned modules (each version a separate module) don't need to include
@@ -469,40 +469,40 @@ define define_module =
469469
mkdir -p "$$(dir $$@)"
470470
tar -xf "$(packages)/$($1_tar)" $(or $($1_tar_opt),--strip 1) -C "$$(dir $$@)"
471471
if [ -r patches/$($1_patch_name).patch ]; then \
472-
echo "INFO: Applying single patch file patches/$($1_patch_name).patch"; \
472+
echo "INFO: Applying single patch file patches/$($1_patch_name).patch" && \
473473
if ! ( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ); then \
474-
echo "ERROR: Failed to apply patch patches/$($1_patch_name).patch. Reversing and reapplying."; \
475-
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || true; \
476-
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || exit 1; \
477-
fi; \
478-
fi
474+
echo "ERROR: Failed to apply patch patches/$($1_patch_name).patch. Reversing and reapplying." && \
475+
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || true && \
476+
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || exit 1 ; \
477+
fi ; \
478+
fi ; \
479479
if [ -d patches/$($1_patch_name) ]; then \
480480
for patch in patches/$($1_patch_name)/*.patch; do \
481-
echo "INFO: Applying patch file: $$$$patch"; \
481+
echo "INFO: Applying patch file: $$$$patch" && \
482482
if ! ( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ); then \
483-
echo "ERROR: Failed to apply patch $$$$patch. Reversing and reapplying."; \
484-
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || true; \
485-
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || exit 1; \
486-
fi; \
487-
done; \
483+
echo "ERROR: Failed to apply patch $$$$patch. Reversing and reapplying." && \
484+
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || true && \
485+
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || exit 1 ; \
486+
fi ; \
487+
done ; \
488488
fi
489489
if [ ! -e "$$@" ] && [ -e "$(build)/$($1_base_dir)/.patched" ]; then \
490-
echo "INFO: .canary file not found but .patched exists. Reversing and reapplying patches for $1"; \
490+
echo "INFO: .canary file not found but .patched exists. Reversing and reapplying patches for $1" && \
491491
if [ -r patches/$($1_patch_name).patch ]; then \
492-
echo "INFO: Reversing single patch file patches/$($1_patch_name).patch."; \
493-
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || true; \
494-
echo "INFO: Reapplying single patch file patches/$($1_patch_name).patch."; \
495-
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || exit 1; \
496-
fi; \
492+
echo "INFO: Reversing single patch file patches/$($1_patch_name).patch." && \
493+
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || true && \
494+
echo "INFO: Reapplying single patch file patches/$($1_patch_name).patch." && \
495+
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < patches/$($1_patch_name).patch ) || exit 1 ; \
496+
fi ; \
497497
if [ -d patches/$($1_patch_name) ]; then \
498498
for patch in patches/$($1_patch_name)/*.patch; do \
499-
echo "INFO: Reversing patch file: $$$$patch"; \
500-
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || true; \
501-
echo "INFO: Reapplying patch file: $$$$patch"; \
502-
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || exit 1; \
503-
done; \
504-
fi; \
505-
rm -f "$(build)/$($1_base_dir)/.patched"; \
499+
echo "INFO: Reversing patch file: $$$$patch" && \
500+
( git apply --reverse --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || true && \
501+
echo "INFO: Reapplying patch file: $$$$patch" && \
502+
( git apply --verbose --reject --binary --directory build/$(CONFIG_TARGET_ARCH)/$($1_base_dir) < $$$$patch ) || exit 1 ; \
503+
done ; \
504+
fi ; \
505+
rm -f "$(build)/$($1_base_dir)/.patched" ; \
506506
fi
507507
touch "$$@"
508508
endif
@@ -929,22 +929,22 @@ define overwrite_canary_if_coreboot_git
929929
@echo "Checking for coreboot directory: build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)"
930930
if [ -d "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)" ] && \
931931
[ -d "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.git" ]; then \
932-
echo "INFO: Recreating .canary file for 'build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)' with placeholder."; \
933-
echo BOGUS_COMMIT_ID > "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.canary"; \
934-
echo "NOTE: If a patch fails to apply, some files might need to be deleted manually to resolve conflicts."; \
935-
echo "INFO: Reversing patches dynamically in reverse order."; \
932+
echo "INFO: Recreating .canary file for 'build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)' with placeholder." && \
933+
echo BOGUS_COMMIT_ID > "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.canary" && \
934+
echo "NOTE: If a patch fails to apply, some files might need to be deleted manually to resolve conflicts." && \
935+
echo "INFO: Reversing patches dynamically in reverse order." && \
936936
for patch in $$(ls patches/coreboot-$(CONFIG_COREBOOT_VERSION)/*.patch 2>/dev/null | sort -r); do \
937-
echo "INFO: Reversing patch file: $$patch"; \
938-
( git apply --reverse --verbose --reject --binary --directory build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION) < $$patch ) || true; \
939-
done; \
937+
echo "INFO: Reversing patch file: $$patch" && \
938+
( git apply --reverse --verbose --reject --binary --directory build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION) < $$patch ) || true ; \
939+
done && \
940940
if [ -r patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch ]; then \
941-
echo "INFO: Reversing main patch file patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch."; \
942-
( git apply --reverse --verbose --reject --binary --directory build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION) < patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch ) || true; \
943-
fi; \
944-
echo "INFO: Removing .patched file to allow reapplication of patches."; \
945-
rm -f "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.patched"; \
941+
echo "INFO: Reversing main patch file patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch." && \
942+
( git apply --reverse --verbose --reject --binary --directory build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION) < patches/coreboot-$(CONFIG_COREBOOT_VERSION).patch ) || true ; \
943+
fi && \
944+
echo "INFO: Removing .patched file to allow reapplication of patches." && \
945+
rm -f "build/${CONFIG_TARGET_ARCH}/coreboot-$(CONFIG_COREBOOT_VERSION)/.patched" ; \
946946
else \
947-
echo "INFO: Coreboot directory or .git not found, skipping .canary overwrite."; \
947+
echo "INFO: Coreboot directory or .git not found, skipping .canary overwrite." ; \
948948
fi
949949
endef
950950

@@ -955,8 +955,8 @@ real.clean:
955955
$(kernel_headers) \
956956
; do \
957957
if [ ! -z "$$dir" ]; then \
958-
rm -rf "build/${CONFIG_TARGET_ARCH}/$$dir"; \
959-
fi; \
958+
rm -rf "build/${CONFIG_TARGET_ARCH}/$$dir" ; \
959+
fi ; \
960960
done
961961
cd install && rm -rf -- *
962962
$(call overwrite_canary_if_coreboot_git)

0 commit comments

Comments
 (0)