Skip to content

GNU make

GNU make

Automatic variables

make requires commands to begin with tabs, so copying the examples below will not work unless you replace the leading spaces with tabs. This is probably the must frustrating thing about make.

$ cat Makefile
all: foo_one foo_two

foo_%: bar_a bar_b
    @echo $*: this is $@ and it requires $^

bar_%: baz
    @echo $*: this is $@ and it requires $^

baz:
    @echo this is baz

$ make
this is baz
a: this is bar_a and it requires baz
b: this is bar_b and it requires baz
one: this is foo_one and it requires bar_a bar_b
two: this is foo_two and it requires bar_a bar_b