Taco Steemers

A personal blog.

Notes on make

Get the present working directory from inside a make script

echo "Current working directory of the make process: $(shell pwd)" . if pwd is present. shell calls out to the shell.

Call another target from inside a target

Sometimes we can't call another target from a prerequisite because that would result in the wrong order of operations.

One way to call another target from inside make is make other_target . This will spawn another make process.

Perhaps in your case spawning another make process adds too much overhead. In that case you might want to create a higher-level target that contains the original target as a prerequisite. This will not work if make runs in parallel mode because then the order of operations is not guaranteed. This StackOverflow answer shows how it can be done without creating a new make instance and still guaranteeing the order of operations. If we turn the other target into a variable instead of a target, we can use the call method to execute it:

OTHER_TARGET = echo "Executing other_target"

    echo "Executing initial_target"
    $(call OTHER_TARGET)