Reputation: 29519
xpi_built := $(build_dir)/$(install_rdf) \
$(build_dir)/$(chrome_manifest) \
$(chrome_jar_file) \
$(default_prefs)
xpi_built_no_dir := $(subst $(build_dir)/,,$(xpi_built))
$(xpi_file): $(build_dir) $(xpi_built)
@echo "Creating XPI file."
cd $(build_dir); $(ZIP) ../$(xpi_file) $(xpi_built_no_dir)
@echo "Creating XPI file. Done!"
$(build_dir)/%: %
cp -f $< $@
$(build_dir):
@if [ ! -x $(build_dir) ]; \
then \
mkdir $(build_dir); \
fi
can anyone explain me this makefile part? particularly interested in
$(build_dir)/%: %
as well as $<
and $@
directives$(build_dir)
exists, I guess both are executed, but in which order? Upvotes: 0
Views: 258
Reputation: 99084
$(build_dir)/%: %
cp -f $< $@
This is a static pattern rule which uses automatic variables in its command; $<
expands to the leftmost prerequisite, $@
expands to the target. If you try to make $(build_dir)/foo
(whatever $(build_dir)
is), Make will treat this rule as
$(build_dir)/foo: foo
cp -f foo $(build_dir)/foo
The next rule,
$(build_dir):
@if [ ! -x $(build_dir) ]; \
then \
mkdir $(build_dir); \
fi
is for $(build_dir)
itself, and is unnecessarily complicated. It says "if $(build_dir)
doesn't exist, then mkdir it", and it could be written this way:
$(build_dir):
mkdir $@
It looks as if your primary target is $(xpi_file)
:
$(xpi_file): $(build_dir) $(xpi_built)
So Make will first make $(build_dir)
(if necessary), then the members of the list %(xpi_built)
, which includes a couple of things of the form $(build_dir)/%
. Once those are done, it will execute the commands of this rule: it will cd into $(build_dir)
, zip some things up, and echo
a couple of messages.
Upvotes: 2
Reputation: 41306
See Pattern Rules and Automatic Variables in the GNU make documentation. The first rule matches files inside $(build_dir)
, not $(build_dir)
itself. $<
expands to the list of prerequisites of the current rule, $@
is the target for the current rule.
Upvotes: 0