srcfiles=$(wildcard *.c)
objfiles=$(patsubst %.c, %.o, $(srcfiles))
all:app app1
app:$(objfiles)
gcc -o $@ $(objfiles)
app1:$(objfiles)
gcc -o $@ $(objfiles)
# $<, $@ can only use in the rule order
# $< is the first dependent
# $@ is the target file
%.o:%.c
gcc -c $< -o $@ -I include
# The second target, use it in make target
test:
-@echo $(srcfiles)
-@echo $(objfiles)
# @ is don't show the order
# - is if the order is not correct, the behind order can exec
clean:
-@rm -rf *.o
-@rm -rf app app1
.PHONY: clean all