package_version := $(version)x0d$(date)
what is the x0d part between version and date vars开发者_JAVA百科? is it just string?
What $(dotin_files:.in=) does below
code
dotin_files := $(shell find . -type f -name \*.in)
dotin_files := $(dotin_files:.in=)
- what this means $(dotin_files:=.in)
code
$(dotin_files): $(dotin_files:=.in)
$(substitute) $@.in > $@
can target contain multiple files?
what is the meaning of declaring target variable as PHONY?
code
.PHONY: $(dotin_files)
- In the regex replacement code below
code
substitute := perl -p -e 's/@([^@]+)@/defined $$ENV{$$1} ? $$ENV{$$1} : $$&/ge'
what are $$ENV{$$1}
and $$&
? I guess it's Perl scope...
thanks for your time
Variable Expansion
$()
is variable expansion in make, this should just be string substitution - if your makefile is
version=1
date=1.1.10
package_version:=$(version)x0d$(date)
then the variable package_version
will expand to 1x0d1.1.10
.
Substitution
The syntax $(var:a=b)
is a substitution reference and will expand to var
with a suffix a
substituted with b
.
For example, in
foobar:= foo bar
faabar:=$(foobar:oo=aa)
$(faabar)
will expand to the string faa bar
.
Multiple Targets
Multiple targets in a make rule is equivalent to having n rules with a single target, eg
foo bar:foo.c bar.c
$(CC) -o $@ $^
is equivalent to
foo:foo.c bar.c
$(CC) -o $@ $^
bar:foo.c bar.c
$(CC) -o $@ $^
remember that any variables here are expanded.
Phony Targets
The .PHONY
target declares that a rule doesn't produce an actual file, so it will always be built. As always, variables are expanded first. In your case this will expand to something like
.PHONY: foo bar
Escaping
A dollar sign is an escape character in makefiles, the $$
in your perl example is a literal $
, eg substitute
will be the string
perl -p -e 's/@([^@]+)@/defined $ENV{$1} ? $ENV{$1} : $&/ge'
The dollar signs here are processed by perl, and probably give environment variables (I don't know perl).
x0d part between version and date vars, is it just string?
Yes.What $(dotin_files:.in=) does below
Removes the .in from the filenames found with the shell find.what this means $(dotin_files:=.in)
I think you meant $(dotin_files:.in=). As already answered, within the variable dotin_files it replaces any occurrence of ".in" with an empty string(the part between the "=" and ")".can target contain multiple files?
Yeswhat is the meaning of declaring target variable as PHONY?
make will ignore targets time-stamp and consider them as new thus rebuilding them each time.In the regex replacement code below what are $$ENV{$$1} and $$&?
To avoid expansion of $ENV, the $ is doubled, think of '%' in C format strings, thus the string
perl -p -e 's/@([^@]+)@/defined $$ENV{$$1} ? $$ENV{$$1} : $$&/ge'
when called as a shell command will become:
perl -p -e 's/@([^@]+)@/defined $ENV{$1} ? $ENV{$1} : $&/ge'
$ENV is the perl Environment hash, $1 I think it's a backreference in the s/// regexp group.
Michael, you've been asking a lot of basic Makefile questions, and the ones you're asking now are ones you should be able to answer for yourself by experiment.
can target contain multiple files?
Try it:
dotin_files := foo.in bar.in
$(dotin_files):
@echo $@
Now try make foo.in
and make bar.in
. What happens?
What $(dotin_files:.in=) does
It's a substitution reference. Try it yourself and see what happens, like this:
dotin_files := foo.in bar.in
dotin_files := $(dotin_files:.in=)
all:
@echo $(dotin_files)
What did it do?
substitute := perl -p -e 's/@([^@]+)@/defined $$ENV{$$1} ? $$ENV{$$1} : $$&/ge'
what are $$ENV{$$1} and $$&? I guess it's Perl scope...
Let's take a look:
all:
@echo $(substitute)
If you want to know more about Perl, or regexs, or find, or make, or whatever, feel free to ask here, but please take a little time to try to figure it out first.
精彩评论