Reputation: 136271
As a part of the build process, Make creates several .tgz
files:
blah_1.tgz blah_2.tgz .... blah_n.tgz
How do I invoke another command (e.g., rsync
) on each file?
In bash, I would:
for file in `ls *.tgz`' do rsync $file DESTINATION; done
Or:
ls | grep tgz | xargs rsync {} DESTINATION
But the familiar bash syntax doesn't seem to comply with Make. Any ideas?
Upvotes: 0
Views: 725
Reputation: 25503
Hmm... Something like this should work:
TGZ_FILES := blah_1.tgz blah_2.tgz .... blah_n.tgz
RSYNC_TARGETS := $(TGZ_FILES:%=rsync-%)
all : $(RSYNC_TARGETS)
.PHONY : $(RSYNC_TARGETS)
$(RSYNC_TARGETS) : rsync-% : %
rsync $* DESTINATION
# Omit the following rule
# if .tgz files are made somewhere else (outside Make),
# and you assume they are always up-to-date
$(TGZ_FILES) : %.tgz : ...
# rule to make each .tgz file
This example uses the following features of GNU Make:
$(TGZ_FILES:%=rsync-%)
)$(RSYNC_TARGETS) : rsync-% : %
).PHONY : $(RSYNC_TARGETS)
)$*
)Upvotes: 1