########### target name
# compile all .c file in $(PWD)
SRCS:=$(wildcard ./*.c)
OBJS := $(SRCS:.c=.o)
OUT := bpool
OUT_LIB := lib
OUT_SO := so
########### cross compiler and flags
CC := gcc
CFLAGS:= -g -O0
APP_CFLAGS += $(CFLAGS) -DMAINAPP
LIB_CFLAGS := $(CFLAGS)
SO_CFLAGS:=$(CFLAGS) -shared -fpic
LDFLAGS := -lrt -lpthread
### make file $(warning ) for debug
#tip1: .FORCE NO increment but fully compile whatever target or depend is changed?
#tip2: $@ $^ target and depends
#$(warning ####debug: objs=$(OBJS) )
all: $(OUT)
%.o: %.c
$(warning #### hide rules for single .c OBJS )
$(CC) $(APP_CFLAGS) -o $@ -c $^
$(OUT): $(OBJS)
@echo @@@@@@@ compile $@
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(OUT_LIB): bufferpool.c
@echo @@@@@@@ compile test.$@
$(CC) $(LIB_CFLAGS) -o $(OUT).$@ -c $^
$(OUT_SO): bufferpool.c
@echo @@@@@@@ compile test.$@
$(CC) $(SO_CFLAGS) -o $(OUT).$@ -c $^
.PHONY: clean
clean:
@rm -rf $(OBJS) $(OUT) *.lib *.so
阅读(1684) | 评论(0) | 转发(0) |