-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
39 lines (30 loc) · 1.02 KB
/
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
# find the OS
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
# Compile flags for linux / osx
ifeq ($(uname_S),Linux)
SHOBJ_CFLAGS ?= -W -Wall -fno-common -g -ggdb -std=c99 -O2
SHOBJ_LDFLAGS ?= -shared
ifeq ($(GCOV_MODE),TRUE)
SHOBJ_CFLAGS += -fprofile-arcs -ftest-coverage -DGCOV_MODE
LDFLAGS += -lgcov -lgcc -lm -lc
endif
else
SHOBJ_CFLAGS ?= -W -Wall -dynamic -fno-common -g -ggdb -std=c99 -O2
SHOBJ_LDFLAGS ?= -bundle -undefined dynamic_lookup
endif
TOPDIR := $(shell pwd)
SRCDIR := ${TOPDIR}/src
CJSONDIR := ${SRCDIR}/cJSON
SOURCE_FILES_C := ${CJSONDIR}/cJSON.c ${CJSONDIR}/cJSON_Utils.c ${SRCDIR}/tairdoc.c
OBJS := $(SOURCE_FILES_C:.c=.o)
INCLUDE = -I ${SRCDIR} -I ${CJSONDIR}
vpath %.c ${SRCDIR}
all: tairdoc.so
%.o: %.c
$(CC) ${INCLUDE} $(CFLAGS) $(SHOBJ_CFLAGS) -fPIC -c $< -o $@
tairdoc.so: ${OBJS}
$(CC) $^ -o $@ $(SHOBJ_LDFLAGS) ${LDFLAGS}
clean:
-rm -rf *.so *.o ${OBJS}
-rm -rf ${SRCDIR}/*.gcda ${SRCDIR}/*.gcno ${SRCDIR}/*.gcov
-rm -rf ${CJSONDIR}/*.gcda ${CJSONDIR}/*.gcno ${CJSONDIR}/*.gcov