Reputation: 1996
How do I write an intermediate rule that doesn't generate a target file in Makefile in such a way that it checks dependency correctly?
So I have something like this:
install_script: xxx.sql
psql -f $?
dump.txt: install_script
psql -c 'select * from xxx;' > $@
I want to make sure that install_script
only get run when make dump.txt
if and only if xxx.sql
was modified.
Upvotes: 1
Views: 108
Reputation: 2643
You probably are looking for the phony targets in the makefile. So it should look like:
.PHONY: dump.txt
dump.txt: install_script
Upvotes: 0
Reputation: 25483
AFAIK, the simplest way for your case is to use a dummy intermediate file:
.xxx.sql.timestamp: xxx.sql
psql -f $?
@touch $@
dump.txt: .xxx.sql.timestamp
psql -c 'select * from xxx;' > $@
And if you want to force dumping the query result unconditionally (even if everything is up-to-date), then add .PHONY
target:
.PHONY : dump.txt
Upvotes: 1