- 选择特定文件作为工程管理文件(默认选择Makefile或makefile文件)
make -f filename
- 选择某一目录下的Makefile文件
make -C dir
- 自动编译当前目录下每一个 .c 文件为可执行文件
CFLAGS = -std=c11 -O3
LDFLAGS = -pthread
CC = gcc
target = thread #当前要编译链接生成的可执行文件名
all:
for i in `echo $(target)`; \
do \
$(CC) $(CFLAGS) $(LDFLAGS) "$$i.c" -o "$$i"; \ #取变量i的值用$$
done
.PHONY:clean
clean:
for i in `echo $(target)`; \
do \
rm -rf "$$i"; \
done