Some parameter descriptions in makefile

#obj = main.o sub.o add.o div.o mul.o
src = $(wildcard *.c) #Search
for .c files and add paths

obj = $(patsubst %.c, %.o, $(src)) #Character
matching and replacement, replace all .c suffixed strings in src with .o suffixed strings

target = app

#target :dependency
$(target):$(obj)
  gcc $^ -o $@
  #gcc $(obj) -o $(target)

%.o:%.c
  gcc -c $< -o $@

# $<: The first dependency in the rule
# $^: All dependencies in the rule
# $@: The target in the rule

#Anonymous target prevents name collision.PHONY
:clean
clean:
rm $(obj) $(target) -f

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325890043&siteId=291194637