GNU Make 4.2.1 as shipped in Ubuntu 20.04 has a problem with secondary expansion and variable names containing the '/' character. Make 4.3 and 4.4 don't have the problem. Instead of using the variable name from riscv/sbi-deps and matching it from the riscv/sbi.* target name, name the variable sbi-deps and match it by stripping the riscv/ directory name off the riscv/sbi.* target name. Reported-by: Joel Stanley Signed-off-by: Nicholas Piggin --- riscv/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/riscv/Makefile b/riscv/Makefile index beaeaefa..64720c38 100644 --- a/riscv/Makefile +++ b/riscv/Makefile @@ -18,12 +18,12 @@ tests += $(TEST_DIR)/isa-dbltrp.$(exe) all: $(tests) -$(TEST_DIR)/sbi-deps += $(TEST_DIR)/sbi-asm.o -$(TEST_DIR)/sbi-deps += $(TEST_DIR)/sbi-dbtr.o -$(TEST_DIR)/sbi-deps += $(TEST_DIR)/sbi-fwft.o -$(TEST_DIR)/sbi-deps += $(TEST_DIR)/sbi-sse.o +sbi-deps += $(TEST_DIR)/sbi-asm.o +sbi-deps += $(TEST_DIR)/sbi-dbtr.o +sbi-deps += $(TEST_DIR)/sbi-fwft.o +sbi-deps += $(TEST_DIR)/sbi-sse.o -all_deps += $($(TEST_DIR)/sbi-deps) +all_deps += $(sbi-deps) # When built for EFI sieve needs extra memory, run with e.g. '-m 256' on QEMU $(TEST_DIR)/sieve.$(exe): AUXFLAGS = 0x1 @@ -113,7 +113,7 @@ cflatobjs += lib/efi.o .PRECIOUS: %.so %.so: EFI_LDFLAGS += -defsym=EFI_SUBSYSTEM=0xa --no-undefined -%.so: %.o $(FLATLIBS) $(SRCDIR)/riscv/efi/elf_riscv64_efi.lds $(cstart.o) %.aux.o $$($$*-deps) +%.so: %.o $(FLATLIBS) $(SRCDIR)/riscv/efi/elf_riscv64_efi.lds $(cstart.o) %.aux.o $$($$(notdir $$*)-deps) $(LD) $(EFI_LDFLAGS) -o $@ -T $(SRCDIR)/riscv/efi/elf_riscv64_efi.lds \ $(filter %.o, $^) $(FLATLIBS) $(EFI_LIBS) @@ -129,7 +129,7 @@ cflatobjs += lib/efi.o -O binary $^ $@ else %.elf: LDFLAGS += -pie -n -z notext -%.elf: %.o $(FLATLIBS) $(SRCDIR)/riscv/flat.lds $(cstart.o) %.aux.o $$($$*-deps) +%.elf: %.o $(FLATLIBS) $(SRCDIR)/riscv/flat.lds $(cstart.o) %.aux.o $$($$(notdir $$*)-deps) $(LD) $(LDFLAGS) -o $@ -T $(SRCDIR)/riscv/flat.lds \ $(filter %.o, $^) $(FLATLIBS) @chmod a-x $@ -- 2.51.0 Shellcheck warnings SC2327,SC2328 complain that a command substitution will be empty if the output is redirected, which is a valid warning but shellcheck is not smart enough to see when output is redirected into a command that outputs what the command substitution wanted. Add comments and shellcheck directives to these cases. Signed-off-by: Nicholas Piggin --- scripts/arch-run.bash | 9 +++++++++ scripts/runtime.bash | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash index 58e4f93f..9c089f88 100644 --- a/scripts/arch-run.bash +++ b/scripts/arch-run.bash @@ -9,6 +9,11 @@ run_test () # stdout to {stdout}, stderr to $errors and stderr exec {stdout}>&1 + # SC complains that redirection without tee takes output way from + # command substitution, but that is what we want here (stderr output + # does go to command substitution because tee is used, but stdout does + # not). + # shellcheck disable=SC2327,SC2328 errors=$("${@}" $INITRD >(tee /dev/stderr) > /dev/fd/$stdout) ret=$? exec {stdout}>&- @@ -23,6 +28,10 @@ run_test_status () local stdout ret exec {stdout}>&1 + # SC complains that redirection without tee takes output way from + # command substitution, but that is what we want here (tee is used + # inside the parenthesis). + # shellcheck disable=SC2327,SC2328 lines=$(run_test "$@" > >(tee /dev/fd/$stdout)) ret=$? exec {stdout}>&- diff --git a/scripts/runtime.bash b/scripts/runtime.bash index 289e52bb..12ac0f38 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -190,6 +190,12 @@ function run() # qemu_params/extra_params in the config file may contain backticks that # need to be expanded, so use eval to start qemu. Use "> >(foo)" instead of # a pipe to preserve the exit status. + # + # SC complains that redirection without tee takes output way from command + # substitution, but that is what we want here (tee is used inside the + # parenthesis and output piped to extract_summary which is captured by + # command substitution). + # shellcheck disable=SC2327,SC2328 summary=$(eval "$cmdline" 2> >(RUNTIME_log_stderr $testname) \ > >(tee >(RUNTIME_log_stdout $testname $kernel) | extract_summary)) ret=$? -- 2.51.0