@ Macro
OBJF = test1.o test2.o test3.o
test: $(OBJF)
gcc -o test $(OBJF)
test1.o: test1.c a.h
gcc -c test1.c
test2.o: test2.c a.h b.h
gcc -c test2.c
test3.o: test3.c b.h c.h
gcc -c test3.c
clean:
rm $(OBJF)
@ Inner Macro
# $@ : Current Rule, Target Name
# $* : Current Rule, Target Name (Except extension)
# $^ : Current Rule, All dependency Files
# $< : Current Rule, First dependency File Name
OBJF = test1.o test2.o test3.o
test: $(OBJF)
gcc -o $@ $^
test1.o: test1.c a.h
gcc -c $<
test2.o: test2.c a.h b.h
gcc -c $*.c
test3.o: test3.c b.h c.h
gcc -c $*.c
clean:
rm $(OBJF)
@ Macro Modification
OBJF = test1.o test2.o
OBJF := $(OBJF) test3.o
test: $(OBJF)
gcc -o $@ $^
test1.o: test1.c a.h
gcc -c $<
test2.o: test2.c a.h b.h
gcc -c $*.c
test3.o: test3.c b.h c.h
gcc -c $*.c
clean:
rm $(OBJF)
@ Implicit Rules
OBJF = test1.o test2.o test3.o
test: $(OBJF)
gcc -o $@ $(OBJF)
clean:
rm $(OBJF)
@ Suffix Rules
OBJF = test1.o test2.o test3.o
test: $(OBJF)
gcc -o $@ $(OBJF)
.c.o:
gcc -c $(CFLAGS) $<
clean:
rm $(OBJF)
@ Pattern Rules
OBJF = test1_obj.o test2_obj.o test3_obj.o
test: $(OBJF)
gcc -o $@ $(OBJF)
%_obj.o: %.c
gcc -c $< -o $@
clean:
rm $(OBJF)
OBJF = test1.o test2.o test3.o
test: $(OBJF)
gcc -o test $(OBJF)
test1.o: test1.c a.h
gcc -c test1.c
test2.o: test2.c a.h b.h
gcc -c test2.c
test3.o: test3.c b.h c.h
gcc -c test3.c
clean:
rm $(OBJF)
@ Inner Macro
# $@ : Current Rule, Target Name
# $* : Current Rule, Target Name (Except extension)
# $^ : Current Rule, All dependency Files
# $< : Current Rule, First dependency File Name
OBJF = test1.o test2.o test3.o
test: $(OBJF)
gcc -o $@ $^
test1.o: test1.c a.h
gcc -c $<
test2.o: test2.c a.h b.h
gcc -c $*.c
test3.o: test3.c b.h c.h
gcc -c $*.c
clean:
rm $(OBJF)
@ Macro Modification
OBJF = test1.o test2.o
OBJF := $(OBJF) test3.o
test: $(OBJF)
gcc -o $@ $^
test1.o: test1.c a.h
gcc -c $<
test2.o: test2.c a.h b.h
gcc -c $*.c
test3.o: test3.c b.h c.h
gcc -c $*.c
clean:
rm $(OBJF)
@ Implicit Rules
OBJF = test1.o test2.o test3.o
test: $(OBJF)
gcc -o $@ $(OBJF)
clean:
rm $(OBJF)
@ Suffix Rules
OBJF = test1.o test2.o test3.o
test: $(OBJF)
gcc -o $@ $(OBJF)
.c.o:
gcc -c $(CFLAGS) $<
clean:
rm $(OBJF)
@ Pattern Rules
OBJF = test1_obj.o test2_obj.o test3_obj.o
test: $(OBJF)
gcc -o $@ $(OBJF)
%_obj.o: %.c
gcc -c $< -o $@
clean:
rm $(OBJF)
No comments:
Post a Comment