Search code examples
makefile

error when run with Makefile, but no error when command given directly on the shell


I was trying something using Makefile. This is the Makefile.

.PHONY : runuboot

runuboot :
    qemu-6.2.0/build/aarch64-softmmu/qemu-system-aarch64 -machine virt -kernel u-boot.v2022.07/u-boot

When I do 'make runuboot', I get this result.

ckim@ckim-ubuntu:~/prj1/U-BOOT/temp$ make runuboot
qemu-6.2.0/build/aarch64-softmmu/qemu-system-aarch64 -machine virt -kernel u-boot.v2022.07/u-boot
make: *** [Makefile:4: runuboot] Error 1

But when I give the command in the bash shell, there is no error.

ckim@ckim-ubuntu:~/prj1/U-BOOT/temp$ qemu-6.2.0/build/aarch64-softmmu/qemu-system-aarch64 -machine virt -kernel u-boot.v2022.07/u-boot

I don't know what's wrong in running it with Makefile.


Solution

  • This line:

    make: *** [Makefile:4: runuboot] Error 1
    

    means that the runuboot command exited with an error code of 1. It almost certainly exited with that same error code when you ran it from the command line, but you didn't check so you didn't realize it:

    $ qemu-6.2.0/build/aarch64-softmmu/qemu-system-aarch64 -machine virt -kernel u-boot.v2022.07/u-boot
    $ echo $?
    1
    

    Or, more or less what make does:

    $ qemu-6.2.0/build/aarch64-softmmu/qemu-system-aarch64 -machine virt -kernel u-boot.v2022.07/u-boot || echo failed
    failed
    

    It's a poor tool that exits with a non-0 exit code (failure) but doesn't print any information on what actually failed, but there you go.