-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (44 loc) · 923 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
### 基本参数定义
BIN := islib.so
SRC += islib.c
SRC += istime.c
SRC += isstr.c
SRC += islog.c
SRC += istcp.c
SRC += isfile.c
SRC += isipc.c
SRC += isatom.c
# 定义基本路径
OBJDIR := obj
# makefile 查找路径
vpath %.c src
vpath %.h src
RM = rm -i
#LIBS := -lm -lpthread
CFLAGS += -Wall -std=c99 -fPIC -g
#CFLAGS += -I$(OBJDIR)/include
LDFLAGS += -shared
.SUFFIXES: .c .so .o
### 操作系统特殊定义
#find the OS
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
ifeq ($(uname_S), Linux)
else
endif
OBJ := $(patsubst %.c,$(OBJDIR)/%.o,$(SRC))
.PHONY: all
all: $(BIN)
$(BIN): $(OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
cp islib.so test/islib.so
.PHONY:test
test:
cd ./test && make && cd -
.PHONY: clean
clean:
$(RM) -f $(BIN) obj/* test/$(BIN)
@cd ./test && make clean && cd -
$(OBJDIR):
@mkdir -p $@
$(OBJDIR)/%.o : %.c %.h
$(CC) $(CFLAGS) -c -o $@ $<