in TEST.example.Makefile
Example 1:
$(PROGRAMS_TO_TEST:%=test.$(TEST).%):
\
test.$(TEST).%:
Output/%.llvm.bc
@echo "========================================="
@echo "Running '$(TEST)' test on '$(TESTNAME)' program"
wc -c $<
Example 0:
foo := a.o b.o c.o
bar := $(foo:%.o=%.c)
sets ‘bar’ to ‘a.c b.c c.c’.
---------------------------------------------
$(var:a=b)= take the value of the variable var, replace every a at the end of a word with b in that value, and substitute the resulting string.
---------------------------------------------
Example 1:
all: a b
@echo all
% : %.c
@echo gcc -c $< -o $@.o</code>
$make
gcc -c a.c -o a.o
gcc -c b.c -o b.o
all
---------------------------------------------
% match任何數目的任何字符
---------------------------------------------
% match任何數目的任何字符
---------------------------------------------
Example 2:
objects = foo.o bar.o
all: $(objects)
@echo all
$(objects): %.o: %.c
@echo gcc -c $< -o $@
%.c:
@echo %c = $@
$make
%c = foo.c
gcc -c foo.c -o foo.o
%c = bar.c
gcc -c bar.c -o bar.o
all
---------------------------------------------
syntax:
<targets ...>: <target-pattern>: <prereq-patterns ...>
<commands>
---------------------------------------------
---------------------------------------------
syntax:
<targets ...>: <target-pattern>: <prereq-patterns ...>
<commands>
---------------------------------------------
沒有留言:
張貼留言