I'd like to add targets to the .PHONY
targets list.
However, when I redefine .PHONY
in Makefile.am
it overrides the previous one in the autogenerated Makefile
. I just want to extend it.
Is there an elegant way to do this?
I'd like to add targets to the .PHONY
targets list.
However, when I redefine .PHONY
in Makefile.am
it overrides the previous one in the autogenerated Makefile
. I just want to extend it.
Is there an elegant way to do this?
simply do it.
.PHONY
is a target (rather than a variable) and as such you don't override, but you add to it:
consider the simple Makefile:
default: foo bar baz
@touch $^
.PHONY: foo
foo:
@echo "foo"
.PHONY: bar
bar:
@echo "bar"
baz:
@echo "baz"
as you can see, there are two independent .PHONY
definitions.
on the first run, this will print out "foo", "bar", and "baz" and then touch (create) 3 files named like that. on the second run it will only print "foo" and "bar", since these are PHONY, so the targets are run even though the files exist.
now consider the Makefile.am`:
bin_PROGRAMS = foonly
foonly_SOURCES = main.c
## an additional phony target:
.PHONY: test
test:
echo "test"
inspecting the resulting Makefile
, you will again see multiple .PHONY
targets. they will behave like in the 1st example: adding up, rather than overriding each other.