Search code examples
makefilegnu-make

What does this do in make?


I've been reading the make manual to try to decypher an existing Makefile. I'm stuck on the filter-out in this line:

KERNEL_ELF_DEPS = $(filter-out %: ,$(file < $(KERNEL_ELF).d)) $(KERNEL_MANIFEST) $(LAST_BUILD_CONFIG)

where:

KERNEL_ELF = target/aarch64-unknown-none-softfloat/release/kernel

making the filter-out part:

$(filter-out %: ,$(file < target/aarch64-unknown-none-softfloat/release/kernel.d))

From my reading, I think this should read in the file target/aarch64-unknown-none-softfloat/release/kernel.d and filter out any string that terminates in a : .

The file contains

/Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/target/aarch64-unknown-none-softfloat/release/kernel: /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/build.rs /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/src/_arch/aarch64/cpu/boot.rs /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/src/_arch/aarch64/cpu/boot.s /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/src/bsp/raspberrypi/kernel.ld /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/src/bsp/raspberrypi.rs /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/src/bsp.rs /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/src/cpu/boot.rs /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/src/cpu.rs /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/src/main.rs /Users/simgar/projects/rust-raspberrypi-OS-tutorials/01_wait_forever/src/panic_wait.rs

so I was expecting to get all of the paths except the first one but I don't get anything. What should I expect? Where has my reasoning gone wrong?

UPDATE

make --version is 3.81


Solution

  • GNU Make 3.81 was released almost 19 years ago (April 2006).

    The ability for the file function to read files was added in GNU Make 4.2, which was released almost 9 years ago (May 2016): See https://git.savannah.gnu.org/cgit/make.git/tree/NEWS?h=4.4.1#n366

    You will have to upgrade your GNU Make to run this makefile.