INC = -I../include
LIB = -L../lib -lsqlite3
CFLAGS = -lgcc -pthread -ldl
DIR_OBJS = ../obj
DIR_BIN = ../bin
dirs := $(DIR_OBJS) $(DIR_BIN)
bin = server
src = $(wildcard *.c)
obj = $(patsubst %.c,%.o,$(src)) #patsubst模式字符替换函数 #obj = $(src:.c=.o)
obj := $(addprefix $(DIR_OBJS)/,$(obj))
bin := $(addprefix $(DIR_BIN)/,$(bin))
#$@ 目标(自动变量)
#$^ 依赖
all: $(dirs) $(bin)
$(dirs):
mkdir $@
$(bin):$(obj)
gcc $^ -o $@ $(CFLAGS) $(INC) $(LIB)
$(DIR_OBJS)/%.o:%.c
gcc $^ -o $@ -c $(CFLAGS) $(INC) $(LIB)
clean:
rm -rf $(dirs) $(bin)
.PHONY:all clean